none
How to get AssemblyInfo task to update a single AssemblyInfo file

    Question

  • I'm using CruiseControl.net as my integration server.  I want to set my CommonAssemblyInfo.cs -> AssemblyVersion to 5.0.123 where 123 is the build number provided by CC in the CCNetLabel variable.  I have installed the MSBuild Extensions Pack from CodePlex but I can't suss out how to make it work.

    Here's my MSBuild file:

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets"/>


      <Target Name="UpdateCommonAssemblyInfo">
        <ItemGroup>
          <AssemblyInfoFiles Include="CommonAssemblyInfo.cs"/>
        </ItemGroup>
        <AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles)"
                      AssemblyVersion="5.0.$(CCNetLabel)"/>
      </Target>
    </Project>

    Here's the command I'm using to run it:

    msbuild /target:UpdateCommonAssemblyInfo /property:CCNetLabel=123 MyProj.xml

    I'm getting an error saying the "input" parameter cannot be null.  Any ideas on what I'm missing here?

    jeudi 23 février 2012 23:02

Réponses

  • CCNetLabel=123 is not a valid input since it missing a delimiter. CCNetLabe="1.2.3" will work though.

    You may want to break down the label as follows:

        <AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles)"
                      AssemblyMajorVersion="5" 
                      AssemblyMinorVersion="$(AssemblyMinorVersion)" 
                      AssemblyBuildNumber="$(AssemblyBuildNumber)"
                      AssemblyRevision="$(AssemblyRevision)"/>

    Called with:

    msbuild /target:UpdateCommonAssemblyInfo /p:AssemblyMinorVersion=1;AssemblyBuildNumber=2;AssemblyRevision=3

    Result:

    [assemblyAssemblyVersion("5.1.2.3")]
    


    vendredi 24 février 2012 02:16
  • Hi Doug,

    The Assembly version is formatted as AssemblyMajorVersion, AssemblyMinorVersion, AssemblyBuildNumber, and AssemblyRevision properties, which should looks like 1.2.3.4. AssemblyVersion is used to modify the entire version, but it still requires the same format. In above sample, your code want to revise the version as 5.0.123 which is not an accepted format.

    I run the following code with your command and it works.

      <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
    
      <Target Name="UpdateCommonAssemblyInfo">
        
        <ItemGroup>
          <AssemblyInfoFiles Include="AssemblyInfo1.cs"/>
        </ItemGroup>
    
        <MSBuild.ExtensionPack.Framework.AssemblyInfo 
            AssemblyInfoFiles="@(AssemblyInfoFiles)"  
            AssemblyVersion="5.0.0.$(CCNetLabel)"/>
          
      </Target>
    </Project>

    If you need to modify the some digit of the version, you may use
    AssemblyMajorVersion, AssemblyMinorVersion, AssemblyBuildNumber, and AssemblyRevision directly rather than AssemblyVersion.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us

    vendredi 24 février 2012 02:25
    Modérateur

Toutes les réponses

  • CCNetLabel=123 is not a valid input since it missing a delimiter. CCNetLabe="1.2.3" will work though.

    You may want to break down the label as follows:

        <AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles)"
                      AssemblyMajorVersion="5" 
                      AssemblyMinorVersion="$(AssemblyMinorVersion)" 
                      AssemblyBuildNumber="$(AssemblyBuildNumber)"
                      AssemblyRevision="$(AssemblyRevision)"/>

    Called with:

    msbuild /target:UpdateCommonAssemblyInfo /p:AssemblyMinorVersion=1;AssemblyBuildNumber=2;AssemblyRevision=3

    Result:

    [assemblyAssemblyVersion("5.1.2.3")]
    


    vendredi 24 février 2012 02:16
  • Hi Doug,

    The Assembly version is formatted as AssemblyMajorVersion, AssemblyMinorVersion, AssemblyBuildNumber, and AssemblyRevision properties, which should looks like 1.2.3.4. AssemblyVersion is used to modify the entire version, but it still requires the same format. In above sample, your code want to revise the version as 5.0.123 which is not an accepted format.

    I run the following code with your command and it works.

      <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
    
      <Target Name="UpdateCommonAssemblyInfo">
        
        <ItemGroup>
          <AssemblyInfoFiles Include="AssemblyInfo1.cs"/>
        </ItemGroup>
    
        <MSBuild.ExtensionPack.Framework.AssemblyInfo 
            AssemblyInfoFiles="@(AssemblyInfoFiles)"  
            AssemblyVersion="5.0.0.$(CCNetLabel)"/>
          
      </Target>
    </Project>

    If you need to modify the some digit of the version, you may use
    AssemblyMajorVersion, AssemblyMinorVersion, AssemblyBuildNumber, and AssemblyRevision directly rather than AssemblyVersion.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us

    vendredi 24 février 2012 02:25
    Modérateur
  • Hi

    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us

    mercredi 29 février 2012 03:02
    Modérateur