No idea where I found this. But I found this on the internet "somewhere".
This updates all the AssemblyInfo.cs files before the build takes place.
Works like a charm. All my exe's and dll's show up as 1.2.3.333 (If "333" were the SVN revision at the time.) (And the original version in the AssemblyInfo.cs file was listed as "1.2.3.0")
$(ProjectDir) (Where my .sln file resides)
$(SVNToolPath) (points to svn.exe)
are my custom variables, their declarations/definitions are not defined below.
http://msbuildtasks.tigris.org/
and/or
https://github.com/loresoft/msbuildtasks
has the ( FileUpdate and SvnVersion ) tasks.
<Target Name="SubVersionBeforeBuildVersionTagItUp">
<ItemGroup>
<AssemblyInfoFiles Include="$(ProjectDir)\**\*AssemblyInfo.cs" />
</ItemGroup>
<SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(SVNToolPath)">
<Output TaskParameter="Revision" PropertyName="MySubVersionRevision" />
</SvnVersion>
<FileUpdate Files="@(AssemblyInfoFiles)"
Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
ReplacementText="$1.$2.$3.$(MySubVersionRevision)" />
</Target>
EDIT --------------------------------------------------
The above may start failing after your SVN revision number reaches 65534 or higher.
See:
Turn off warning CS1607
Here is the workaround.
<FileUpdate Files="@(AssemblyInfoFiles)"
Regex="AssemblyFileVersion\("(\d+)\.(\d+)\.(\d+)\.(\d+)"
ReplacementText="AssemblyFileVersion("$1.$2.$3.$(SubVersionRevision)" />
The result of this should be:
In Windows/Explorer//File/Properties…….
Assembly Version will be 1.0.0.0.
File Version will be 1.0.0.333 if 333 is the SVN revision.