• Updating your Assembly Info files with Southworks SDC tasks

    Published by jpgarcia on July 11th, 2008 11:28 am under Code Quality, Continuous Integration, MSBuild

    No Comments

    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:

    image

    Open the sample AssemblyInfo.cs file and see how it was updated:

    image

    thanks, stay tuned!

  • Leave a comment

    Your email address will not be published.

Map

Locations of visitors to this page
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); var pageTracker = _gat._getTracker("UA-491797-5"); pageTracker._trackPageview();