Using AssemblyMajorVersion to update AssemblyInfo in Team build  
Author Message
Mamatha





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

Hi,

Haivng used the build script according to http://www.hide-link.com/ , I find that the AssemblyMajorVersion is not updated for the binaries that are compiled.

Anybody else who is having the same issue If you know, how to resolve this issue, can you please help me.

Thanks




Visual Studio Team System44  
 
 
Sweed





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

Im having the same problem.

I installed the AssemblyInfoTask code.

I get the following error when it tries to build:

</ItemGroup>
Build FAILED.
C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets(94,5): error MSB4062: The "AssemblyInfo" task could not be loaded from the assembly AssemblyInfoTask, Version=1.0.51130.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. Could not load file or assembly 'AssemblyInfoTask, Version=1.0.51130.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.
0 Warning(s)
1 Error(s)

What am I missing There are over 135 AssemblyInfo. files that need to be changed during every build. I dont want to do it manually.

Please help.

Thanks,

Staffan


 
 
Mamatha





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

I installed the AssemblyInfoTask on the build machine (GAC Install) and used the code as suggested on Gautam's website. The "AssemblyInfo.cs" seems to be updated with the version 1.0.<YYMMDD>.<buildNumber of the day>. Try this, it may help.

Also now I am trying to use the "UpdateVersion" command line, but I do not have any idea how to get the AssemblyInfo.cs path of each project that I want to update, so I am stuck using the other alternate method.

Thanks



 
 
Sweed





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

I got past my error. I decided to use:

<UsingTask AssemblyFile="C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\AssemblyInfoTask.dll" TaskName="AssemblyInfo"/>

instead of :

<UsingTask AssemblyName="AssemblyInfoTask, Version=1.0.51130.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" TaskName="AssemblyInfo"/>

Looks like everything works. At solved my cant find file or dependency problem.

Yeah. Now I need to get it to get the rest of 134 files :-)

If I find the answer, Ill post it here :-D

Thanks for the advice,
Staffan


 
 
Mamatha





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

<UsingTask AssemblyName="AssemblyInfoTask, Version=1.0.51130.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" TaskName="AssemblyInfo"/>

If you use this option, then I think you should have the AssemblyInfotask as a GAC Installation

That is the reason you had the issue.



 
 
Sweed





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

This worked for me:

I added the following to the project file (TFSBuild.proj):

---> Add After the original import statement

<Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets"/>

.

.

<!-- Begin SS Added 08312006 seeing if the Assembly can be modified this way-->

<PropertyGroup>

<!-- Assembly version properties. Add others here -->

<AssemblyMajorVersion>9</AssemblyMajorVersion>

<AssemblyFileMajorVersion>9</AssemblyFileMajorVersion>

<AssemblyBuildNumber>0</AssemblyBuildNumber>

<AssemblyRevision>0</AssemblyRevision>

<AssemblyBuildNumberType>AutoIncrement</AssemblyBuildNumberType>

<AssemblyBuildNumberFormat>0</AssemblyBuildNumberFormat>

<AssemblyRevisionType>NoIncrement</AssemblyRevisionType>

<AssemblyFileBuildNumberType>AutoIncrement</AssemblyFileBuildNumberType>

<AssemblyFileBuildNumberFormat>0</AssemblyFileBuildNumberFormat>

<AssemblyFileRevisionType>NoIncrement</AssemblyFileRevisionType>

<!-- TF.exe -->

<TF>&quot;$(TeamBuildRefPath)\..\tf.exe&quot;</TF>

<!-- AssemblyInfo file spec -->

<AssemblyInfoSpec>AssemblyInfo.cs</AssemblyInfoSpec>

</PropertyGroup>

<!-- 09042006 SS Set the items to build -->

<ItemGroup>

<AssemblyInfoFiles Include="$(SolutionRoot)\daily build\MARS_Platform\AuthenticationUtility\Properties\$(AssemblyInfoSpec)"/>

<AssemblyInfoFiles Include="$(SolutionRoot)\daily build\MARS_Platform\MARS_InterfaceConfiguration\Properties\$(AssemblyInfoSpec)"/>

<AssemblyInfoFiles Include="$(SolutionRoot)\daily build\MARS_Platform\MARS_PresentationLayerController\Properties\$(AssemblyInfoSpec)"/>

<AssemblyInfoFiles Include="$(SolutionRoot)\daily build\MARS_Platform\Matching\Properties\$(AssemblyInfoSpec)"/>

</ItemGroup>

<!-- Set this to non-existent file to force rebuild. -->

<ItemGroup>

<IntermediateAssembly Include="$(SolutionRoot)\foobar.dll"/>

</ItemGroup>

<!-- End SS Added 08312006 seeing if the Assembly can be modified this way-->

.

.

<!-- Start 09042006 SS Attempting to make AssemblyInfo.cs's writeable-->

<!-- http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=183479&SiteID=1 -->

<Target Name="AfterGet" Condition="'$(IsDesktopBuild)'!='true'">

<Exec WorkingDirectory="$(SolutionRoot)"

Command="$(TF) checkout /recursive $(AssemblyInfoSpec)"/>

</Target>

<Target Name="BeforeBuild">

<Exec Command="attrib -r Properties\AssemblyInfo.cs" />

</Target>

<!-- End 09042006 SS Attempting to make AssemblyInfo.cs's writeable-->

<!-- Added 07/12/2006 to package product after building -->

<Target Name="AfterCompile">

<!-- Start 09042006 SS Check in new code -->

<Exec WorkingDirectory="$(SolutionRoot)"

Command="$(TF) checkin /comment:&quot;Auto-Build: Version Update&quot; /noprompt /override:&quot;Auto-Build: Version Update&quot; /recursive $(AssemblyInfoSpec)"/>

<!-- End 09042006 SS Check in new code -->

 In the Microsoft.VersionNumber.targets file, I had to use:

     <UsingTask AssemblyFile="C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\AssemblyInfoTask.dll" TaskName="AssemblyInfo"/>

instead of :

     <UsingTask AssemblyName="AssemblyInfoTask, Version=1.0.51130.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" TaskName="AssemblyInfo"/>

This modifies the AssemblyInfo.cs mentioned.   Now, I need to see if it can do it for all AssemblyInfo.cs without having to write my own task.

Is there a task out there already

 

Cheers,

Staffan

 

 


 
 
Mamatha





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

Ok, I just tried what you suggested and it is working. Thanks.

Also, I have this code in the

<Target Name="AfterGet" >

<Exec Command="attrib -r c:\Serenity\TestBuild\*.* /d /s">

</Exec>

<!-- Set the AssemblyInfoFiles items dynamically -->

<CreateItem Include="$(SolutionRoot)\**\$(AssemblyInfoSpec)">

<Output TaskParameter="Include" ItemName="AssemblyInfoFiles" />

</CreateItem>

<Message Text="These AssemblyInfo.cs files were found:"/>

<Message Text =" "/>

</Target>

(Currently I am not doing check out and checkin, so I removed read-only attribute)

If you use this, this will update all the assemblyinfo.cs files and also you can remove/comment these lines in your script. I am sure this will solve this problem.

---------------------------------

<ItemGroup>

<AssemblyInfoFiles Include="$(SolutionRoot)\daily build\MARS_Platform\AuthenticationUtility\Properties\$(AssemblyInfoSpec)"/>

<AssemblyInfoFiles Include="$(SolutionRoot)\daily build\MARS_Platform\MARS_InterfaceConfiguration\Properties\$(AssemblyInfoSpec)"/>

<AssemblyInfoFiles Include="$(SolutionRoot)\daily build\MARS_Platform\MARS_PresentationLayerController\Properties\$(AssemblyInfoSpec)"/>

<AssemblyInfoFiles Include="$(SolutionRoot)\daily build\MARS_Platform\Matching\Properties\$(AssemblyInfoSpec)"/>

</ItemGroup>

-------------------------------------

Thanks



 
 
Sweed





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

Actually, this appears to work too:

<ItemGroup>

     <AssemblyInfoFiles Include="**\AssemblyInfo.cs"/>

</ItemGroup>

It didnt like the variable for some reason  

Now just trying to get the checkin portion to work :-(  

Im trying to hard code the path to see if that helps.  I was getting exit code -1 with the original.

<Target Name="AfterCompile">

<!-- Start 09042006 SS Check in new code -->

<Exec WorkingDirectory="$(SolutionRoot)"

Command="$(TF) checkin /comment:&quot;Auto-Build: Version Update&quot; /noprompt /override:&quot;Auto-Build: Version Update&quot; /recursive D:\DMDB_CODE\&quot;MARS Branch Project&quot;\DailyBuild2\Sources\&quot;daily build&quot;\MARS_Platform\**\AssemblyInfo.cs"/>

<!--Command="$(TF) checkin /comment:&quot;Auto-Build: Version Update&quot; /noprompt /override:&quot;Auto-Build: Version Update&quot; /recursive $(SolutionRoot)\&quot;daily build&quot;\MARS_Platform\**\AssemblyInfo.cs\"/>-->

<!--Command="$(TF) checkin /comment:&quot;Auto-Build: Version Update&quot; /noprompt /override:&quot;Auto-Build: Version Update&quot; /recursive $(AssemblyInfoSpec)"/>-->

<!-- End 09042006 SS Check in new code -->

Any suggestions

Cheers,

Staffan


 
 
Mamatha





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

Have you tried

Command="$(TF) checkin /comment:&quot;Auto-Build: Version Update&quot; /noprompt /override:&quot;Auto-Build: Version Update&quot; /recursive $(AssemblyInfoFiles)"/>

I think it used the variable "AssemblyInfoFiles" as this is what you have used in the ItemGroup

Cheers



 
 
Sweed





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

That didnt work since "AssemblyInfoFiles" is an array.

Is there a way to foreach loop in XML

Maybe have to create a custom task to take the array and checkin the code.

I guess back to more researching :-(

Cheers,
Staffan


 
 
Aaron Hallberg





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

tf checkin. MSBuild, by default, displays the contents of an item group collection as a semicolon separated list, but you can override the separator using this syntax.

Alternatively, there is, in fact, a way to simulate a foreach loop in MSBuild, using batching. See http://msdn2.microsoft.com/en-us/library/ms171473.aspx for more info on this topic. You would want to do something like:

<Exec Command="$(TF) checkin /noprompt %(AssemblyInfoFiles.Identity)" />

I would recommend the first option, however, as it should be more efficient to call tf.exe once with a list of files rather than calling it multiple times on individual files.

-Aaron



 
 
Mamatha





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

Thanks Aaron, the first option suggested by you worked for me.

Thanks



 
 
Sweed





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

Ill try that.

Why does this not grab all files with AssemblyInfoFiles within the level

<CreateItem Include="$(SolutionRoot)\*\*\*\*\AssemblyInfo.cs">

<Output ItemName="AssemblyInfoFiles" TaskParameter="Include" />

</CreateItem>

It only grabs one when there are about 15 in different directories. How do I get 135 files to be placed in the array And checked in ( i havent tried what you half mentioned above yet)

This one, just errors in the UpdateAssembly...task:

<CreateItem Include="$(SolutionRoot)\**\**\**\**\AssemblyInfo.cs">

<Output ItemName="AssemblyInfoFiles" TaskParameter="Include" />

</CreateItem>


 
 
Aaron Hallberg





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

I believe you just want:

<CreateItem Include="$(SolutionRoot)\**\AssemblyInfo.cs">

This should grab all files named AssemblyInfo.cs under $(SolutionRoot) (in any subdirectory).

-Aaron



 
 
Sweed





PostPosted: Team Foundation Server - Build Automation, Using AssemblyMajorVersion to update AssemblyInfo in Team build Top

Thanks. That populated the array, but I get the followign error:

Target UpdateAssemblyInfoFiles:
C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets(93,5): error MSB4018: The "AssemblyInfo" task failed unexpectedly.
C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets(93,5): error MSB4018: System.ArgumentException: version
C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets(93,5): error MSB4018: Parameter name: The specified string is not a valid version number
C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets(93,5): error MSB4018: at Microsoft.Build.Extras.Version.ParseVersion(String version) in C:\Program Files\MSBuild\AssemblyInfoTask_Source\AssemblyInfoTask\Version.cs:line 71
C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets(93,5): error MSB4018: at Microsoft.Build.Extras.Version..ctor(String version) in C:\Program Files\MSBuild\AssemblyInfoTask_Source\AssemblyInfoTask\Version.cs:line 61
C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets(93,5): error MSB4018: at Microsoft.Build.Extras.AssemblyInfo.Execute() in C:\Program Files\MSBuild\AssemblyInfoTask_Source\AssemblyInfoTask\AssemblyInfoTask.cs:line 976
C:\Program Files\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets(93,5): error MSB4018: at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)
Done building target "UpdateAssemblyInfoFiles" in project "TFSBuild.proj" -- FAILED.
Target GetChangeSetsOnBuildBreak:

What does this mean

PLeaes help,

Thanks,

Staffan