Updating your Assembly Info files with Southworks SDC tasks
Johnny and Ezequiel had published in they blogs about the Southworks SDC Tasks we published two weeks ago in Google Code. This project is a set of comprehensive MSBuild tasks that we built along with the maturity of our build process.
I’ll give you a walkthrough for these tasks we developed by giving you a sample of each one of them.
In this post you will find how you can easily update your assembly info files with company information by using the UpdateAssemblyinfo task.
This task is pretty much straight-forward, so I will create a simple .proj file to demonstrate how it works.
Reference the SDC assembly in your project file
The first step is to add the assembly reference for this specific task by giving the AssemblyFile and the TaskName values:
<Project DefaultTargets="UpdateAssemblyInfos"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="d:\test\Southworks.Sdc.Tasks.dll"
TaskName="UpdateAssemblyInfo"/>
</Project>
Notice that the DefaultTargets property indicates which target will be first executed, I’m going to include this target later.
Defining the files to be updated
Then, you need to specify which files will be updated and where they’re located. To do that create a new ItemGroup. If you want to know more about including and/or including Items, see http://msdn.microsoft.com/en-us/library/646dk05y.aspx.
<Project DefaultTargets="UpdateAssemblyInfos"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="d:\test\Southworks.Sdc.Tasks.dll"
TaskName="UpdateAssemblyInfo"/>
<ItemGroup>
<AssemblyInfos Include="d:\test\**\AssemblyInfo.cs"/>
</ItemGroup>
</Project>
Configure the UpdateAssemblyinfo target
Finally create and configure a new target by specifying the information to be replaced on the files we defined in the previous step.
<Project DefaultTargets="UpdateAssemblyInfos"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="d:\test\Southworks.Sdc.Tasks.dll"
TaskName="UpdateAssemblyInfo"/>
<ItemGroup>
<AssemblyInfos Include="d:\test\**\AssemblyInfo.cs"/>
</ItemGroup>
<Target Name="UpdateAssemblyInfos">
<UpdateAssemblyinfo Include="@(AssemblyInfos)"
AssemblyCopyright="Southworks (r) copyright"
AssemblyCompany="Southworks"
AssemblyProduct="Sample product " />
</Target>
</Project>
To see if all it’s working as expected, you could run the project file with MSBuild as depicted bellow:
Open the sample AssemblyInfo.cs file and see how it was updated:
thanks, stay tuned!