- 基于 MachineName 创建一个属性。
- 在构建之前使用该属性更新 AssemblyInfo.cs 文件。
我在下面有“SubVersionRevision”,但只需使用替代语法来获取 TFS 版本(来自您在原始帖子中的链接)......
解决方案的关键是:设置和使用“MyCustomProperty001”
<Choose>
<When Condition=" '$(Computername)'=='MyDevMachine' ">
<PropertyGroup>
<MyCustomProperty001>0</MyCustomProperty001>
</PropertyGroup>
</When>
<When Condition=" '$(Computername)'=='MyQaMachine' ">
<PropertyGroup>
<MyCustomProperty001>1</MyCustomProperty001>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<MyCustomProperty001>9</MyCustomProperty001>
</PropertyGroup>
</Otherwise>
</Choose>
<ItemGroup>
<AssemblyInfoFiles Include="$(ProjectDir)\**\*AssemblyInfo.cs" />
</ItemGroup>
<SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(SVNToolPath)">
<Output TaskParameter="Revision" PropertyName="MySubVersionRevision" />
</SvnVersion>
<FileUpdate Files="@(AssemblyInfoFiles)"
Regex="AssemblyFileVersion\("(\d+)\.(\d+)\.(\d+)\.(\d+)"
ReplacementText="AssemblyFileVersion("$1.$2.$(MyCustomProperty001).$(SubVersionRevision)" />