Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes you can. At some point, possibly at AfterGet, you can use the BuildNumber and create a custom task to update the AssemblyInfo.cs files in your source code.</p> <p>We've hooked into AfterGet and caused our target to be dependant:</p> <pre><code>&lt;Target Name="AfterGet" DependsOnTargets="VersionAssemblies" /&gt; </code></pre> <p>Our VersionAssemblies Target pulls all of the AssemblyInfo.cs files from $(SolutionRoot):</p> <pre><code>&lt;CreateItem Include="$(SolutionRoot)\**\AssemblyInfo.cs;"&gt; &lt;Output TaskParameter="Include" ItemName="AssemblyInfos"/&gt; &lt;/CreateItem&gt; </code></pre> <p>checks them out:</p> <pre><code>&lt;Exec Command="$(TfCommand) checkout &amp;quot;AssemblyInfo.cs&amp;quot; -r" WorkingDirectory="$(MSBuildProjectDirectory)\..\sources" ContinueOnError="true"/&gt; </code></pre> <p>edits them and replaces the file version with the $(BuildNumber):</p> <pre><code>&lt;File.Replace Path="%(AssemblyInfos.FullPath)" NewValue="AssemblyFileVersion(&amp;quot;$(BuildNumber)&amp;quot;)" RegularExpression="AssemblyFileVersion\(\&amp;quot;(\d+.\d+.\d+.\d+)\&amp;quot;\)" IgnoreCase="true" Force="true"/&gt; </code></pre> <p>and then checks the files back in:</p> <pre><code>&lt;Exec Command="$(TfCommand) checkin /override:&amp;quot;Automated&amp;quot; /comment:&amp;quot;Update AssemblyInfo files to version number $(BuildNumber) - $(NoCICheckinComment) &amp;quot; /noprompt &amp;quot;AssemblyInfo.cs&amp;quot; /recursive" WorkingDirectory="$(MSBuildProjectDirectory)\..\sources" ContinueOnError="false"/&gt; </code></pre> <p>For the replacement of the file versions I use the File.Replace task that comes with the Microsoft <a href="http://www.codeplex.com/sdctasks" rel="noreferrer">SDC tasks</a> on CodePlex.</p> <p>Also note, that if you have a build that is triggered on a checkin, when checking in the AssemblyInfo.cs files, make sure the comment includes $(NoCICheckinComment) as this causes TFS not to trigger another build otherwise you'll end up in an infinite build loop.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload