这是我的assemblyinfo.cs版本字符串在预构建时的样子:
[assembly: AssemblyVersion("2.0.0920.10")]
[assembly: AssemblyFileVersion("2.0.0920.10")]
在构建期间,修补程序执行我想要的操作,修改文件:
[assembly: AssemblyVersion("2.0.0.1146")]
[assembly: AssemblyFileVersion("2.0.0.1146")]
但是在构建期间的某些时候它也会这样做:
[assembly: AssemblyVersion("2.0.0921.00")]
[assembly: AssemblyFileVersion("2.0.0921.00")]
然后当构建完成时,它再次看起来像这样:
[assembly: AssemblyVersion("2.0.0920.10")]
[assembly: AssemblyFileVersion("2.0.0920.10")]
当我在Windows资源管理器中右键单击生成的DLL时,点击Properties,然后转到Details选项卡,File Version是“2.0.921.0”,Product version是“2.0.921.00”。
我还使用Assembly.GetExecutingAssembly().GetName().Version.ToString()
My Build有2个Build步骤,一个是VS Solution Build,另一个是命令行步骤,只是将DLL复制到开发服务器。
我不想粘贴整个构建日志,因为它很大,但我认为这是亮点:
[14:24:54]: Step 1/2: Visual Studio 2010 Build (Visual Studio (sln)) (27s)
[14:24:54]: [Step 1/2] Update assembly versions: scanning checkout directory for AssemlyInfo files to update version
[14:24:54]: [Update assembly versions] ... for all of our assemblies
[14:24:55]: [Step 1/2] Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\677e8e784c19cc26 /msbuildPath:C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
[14:24:55]: [Step 1/2] in directory: C:\TeamCity\buildAgent\work\677e8e784c19cc26
[14:25:01]: [Step 1/2] main\solution.sln: Build target: Rebuild (20s)
[14:25:01]: [main\solution.sln] ValidateSolutionConfiguration
[14:25:01]: [ValidateSolutionConfiguration] Building solution configuration "Release|Mixed Platforms".
[14:25:02]: [Step 1/2] main\SolutionDir\solution.csproj: Build target: Rebuild (7s)
...
[14:25:21]: [Step 1/2] Process exited with code 0
[14:25:21]: Step 2/2: Copy Dlls and Templates to Sohodev (Command Line) (3s)
[14:25:21]: [Step 2/2] "BuildAndCopyDllsAndTemplatesv2.cmd" is not present in directory C:\TeamCity\buildAgent\work\677e8e784c19cc26
[14:25:21]: [Step 2/2] Starting: C:\Windows\system32\cmd.exe /c BuildAndCopyDllsAndTemplatesv2.cmd
[14:25:21]: [Step 2/2] in directory: C:\Scripts\Build
[14:25:21]: [Step 2/2] 1 file(s) copied.
[14:25:21]: [Step 2/2] 1 file(s) copied.
[14:25:24]: [Step 2/2] Process exited with code 0
[14:25:24]: Reverting patched assembly versions
[14:25:24]: [Reverting patched assembly versions] Restoring ... for all of our assemblies
[14:25:24]: Publishing internal artifacts (2s)
[14:25:27]: [Publishing internal artifacts] Sending build.finish.properties file
[14:25:27]: Build finished
修改 我们的TeamCity版本号:6.5.1(build 17834)
修改 我刚升级到6.5.4(建立18046)。行为没有变化。
答案 0 :(得分:2)
正如所料,一切都按配置工作。
我们有一个摆弄了assemblyinfo.cs文件的VersionNumber.targets文件
<Import Project="$(MSBuildExtensionsPath)\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.targets"/>
评论这一点使一切都按预期工作。