Jun 15
- Download MSBuild Community Task
- Add the following to the .csproj file of the project you want to follow the svn build numbering. Add just before </Project>
<!-- Import of the MSBuildCommunityTask targets -->
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<!-- to manage version number -->
<Target Name="Version">
<Version VersionFile="version.txt" RevisionType="Increment">
<Output TaskParameter="Major" PropertyName="Major" />
<Output TaskParameter="Minor" PropertyName="Minor" />
<Output TaskParameter="Build" PropertyName="Build" />
<Output TaskParameter="Revision" PropertyName="Revision" />
</Version>
</Target>
<!-- to generate our personnal version info -->
<Target Name="AssemblyInfo">
<SvnVersion LocalPath="$(MSBuildProjectDirectory)" Condition="Exists('$(ProgramFiles)\subversion\bin\svn.exe')">
<Output TaskParameter="Revision" PropertyName="Build" />
</SvnVersion>
<AssemblyInfo
CodeLanguage="CS"
OutputFile="Properties\AssemblyInfo.cs"
AssemblyTitle="WindScanner"
AssemblyDescription=""
AssemblyCompany="Risø"
AssemblyProduct="windscanner"
AssemblyCopyright="Copyright © 2010"
ComVisible="false"
Guid="88812638-9547-4480-3bf4-4fe25103b35c"
AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"
AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"
Condition="$(Revision) != '0' "/>
</Target>
<!-- We launch these two targets -->
<Target Name="BeforeBuild">
<CallTarget Targets="Version" />
<CallTarget Targets="AssemblyInfo" />
</Target>
<Target Name="AfterBuild">
</Target>
Change the path of your svn installation if necessary.
You can now use stuff like
public static String Version
{
get
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
And the the changes reflecting the svn build!

(4.90 out of 5)