locked
Problem with AssemblyInfo task in MSBuild ExtensionPack RRS feed

  • Question

  • Hello,

    I am trying to use the Assembylnfo task which is part of the MSBuild ExtensionPack and I am having issues with an unexpected behavior from the AssemblyInfo task.  I was previously using the earlier version of the MSBuild ExtensionPack (prior to v. 3.5.70), but now that I have upgraded to the latest version, I am not sure I completely understand the behavior. 

    I have several projects all with their own dedicated AssemblyInfo.cs files.  In addition, I have a shared GlobalAssemblyInfo.cs file.  The GlobalAssemblyInfo.cs file contains all of the AssemblyVersioning attributes while all of the other AssemblyInfo.cs files only contain AssemblyTitles, AssemblyDescriptions etc.

     

    This is the MSBuild Task that I am using:

    	<Target Name="AssemblyVersioning">
    		<PropertyGroup>
    			<MajorVersion>1</MajorVersion>
    			<MinorVersion>0</MinorVersion>
    			<BuildVersion>0</BuildVersion>
    			<RevisionNumber>1</RevisionNumber>
    		</PropertyGroup>
    		<ItemGroup>
    			<AssemblyInfoFiles Include="$(MSBuildProjectDirectory)\GlobalAssemblyInfo.cs" />
    		</ItemGroup>
    		<MSBuild.ExtensionPack.Framework.AssemblyInfo SkipVersioning="True" UpdateAssemblyInformationalVersion="True" AssemblyInfoFiles="@(AssemblyInfoFiles)" AssemblyBuildNumber="$(BuildVersion)" AssemblyFileBuildNumber="$(BuildVersion)" AssemblyFileMajorVersion="$(MajorVersion)" AssemblyFileMinorVersion="$(MinorVersion)" AssemblyFileRevision="$(RevisionNumber)" AssemblyMajorVersion="$(MajorVersion)" AssemblyMinorVersion="$(MinorVersion)" AssemblyRevision="$(RevisionNumber)" AssemblyFileVersion="$(MajorVersion).$(MinorVersion).$(BuildVersion).$(RevisionNumber)" AssemblyVersion="$(MajorVersion).$(MinorVersion).$(BuildVersion).$(RevisionNumber)" />
    	</Target>
    

    However, when I attempt to execute the code, I am now getting this error message: 

      Unable to update the AssemblyVersion for Automation\Properties\AssemblyInfo.cs: No stub entry for AssemblyVersion was found in the AssemblyInfo file.

    How do I get around this behavior?  I am using MSBuild v. 4.0 with the Tools version set to v. 3.5 and I have installed MSBuild Extension Pack v. 3.5.7.0.

     

    Thanks.

     

    Friday, September 17, 2010 4:14 AM

Answers

  • I corrected this problem by removing the ItemGroup and converting it to a PropertyGroup.  For some reason, with the usage of an ItemGroup, the system attempts to iterate over all of the AssemblyInfo.cs files in each directory and subdirectory.  By simply specifying a property value defined within a PropertyGroup, the issue is resolved. 
    • Marked as answer by vs2015junkie Tuesday, September 21, 2010 4:31 PM
    Tuesday, September 21, 2010 4:31 PM

All replies

  • Hi,

    The error message shows you don't have [assembly: AssemblyVersion("x.x.x.x")] or [assembly: AssemblyFileVersion("x.x.x.x")] in AssemblyInfo.cs.

    I notice you use GlobalAssemblyInfo.cs as source file. Please check you don't pass wrong file as source file in your side, if it does not help,could you share you GlobalAssemblyInfo.cs here for me to reproduce this issue.

    If I misunderstood you, or you have any comments, please feel free to let me know.

     

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Mike Fourie [MVP] Friday, September 17, 2010 10:37 AM
    • Unproposed as answer by vs2015junkie Tuesday, September 21, 2010 4:31 PM
    Friday, September 17, 2010 10:23 AM
  • Yes, I removed those attributes explicitly from the AssemblyInfo.cs, which is the reason for the error message.  These values are solely included within the GlobalAssemblyInfo.cs.  This error message is also originating from the MSBuild Extension Pack rather than from Visual Studio.  I believe it is something which needs to be addressed by someone knowledgeable and familiar with the MSBuild Extension Pack.

     

    Thanks.

    Friday, September 17, 2010 6:33 PM
  • I corrected this problem by removing the ItemGroup and converting it to a PropertyGroup.  For some reason, with the usage of an ItemGroup, the system attempts to iterate over all of the AssemblyInfo.cs files in each directory and subdirectory.  By simply specifying a property value defined within a PropertyGroup, the issue is resolved. 
    • Marked as answer by vs2015junkie Tuesday, September 21, 2010 4:31 PM
    Tuesday, September 21, 2010 4:31 PM