Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I cannot answer all your questions, as I don't have experience with TFS.</p> <p>But I can recommend a better approach to use for updating your AssemblyInfo.cs files than using the AssemblyInfo task. That task appears to just recreate a standard AssemblyInfo file from scratch, and loses any custom portions you may have added.</p> <p>For that reason, I suggest you look into the FileUpdate task, from the MSBuild Community Tasks project. It can look for specific content in a file and replace it, like this:</p> <pre><code>&lt;FileUpdate Files="$(WebDir)\Properties\AssemblyInfo.cs" Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)" ReplacementText="$(Major).$(ServicePack).$(Build).$(Revision)" Condition="'$(Configuration)' == 'Release'" /&gt; </code></pre> <p>There are several ways you can control the incrementing of the build number. Because I only want the build number to increment if the build is completely successful, I use a 2-step method:</p> <ul> <li>read a number from a text file (the only thing in the file is the number) and add 1 without changing the file;</li> <li>as a final step in the build process, if everything succeeded, save the incremented number back to the text file.</li> </ul> <p>There are tasks such as ReadLinesFromFile, that can help you with this, but I found it easiest to write a small custom task:</p> <pre><code>using System; using System.IO; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace CredibleCustomBuildTasks { public class IncrementTask : Task { [Required] public bool SaveChange { get; set; } [Required] public string IncrementFileName { get; set; } [Output] public int Increment { get; set; } public override bool Execute() { if (File.Exists(IncrementFileName)) { string lines = File.ReadAllText(IncrementFileName); int result; if(Int32.TryParse(lines, out result)) { Increment = result + 1; } else { Log.LogError("Unable to parse integer in '{0}' (contents of {1})"); return false; } } else { Increment = 1; } if (SaveChange) { File.Delete(IncrementFileName); File.WriteAllText(IncrementFileName, Increment.ToString()); } return true; } } } </code></pre> <p>I use this before the FileUpdateTask to get the next build number:</p> <pre><code>&lt;IncrementTask IncrementFileName="$(BuildNumberFile)" SaveChange="false"&gt; &lt;Output TaskParameter="Increment" PropertyName="Build" /&gt; &lt;/IncrementTask&gt; </code></pre> <p>and as my final step (before notifying others) in the build:</p> <pre><code>&lt;IncrementTask IncrementFileName="$(BuildNumberFile)" SaveChange="true" Condition="'$(Configuration)' == 'Release'" /&gt; </code></pre> <p>Your other question of how to update the version number only when source code has changed is highly dependent on your how your build process interacts with your source control. Normally, checking in source file changes should initiate a Continuous Integration build. That is the one to use to update the relevant version number.</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.
    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