简体   繁体   English

TFS版本管理和GlobalAssemblyInfo

[英]TFS Release Management and GlobalAssemblyInfo

My Visual Studio Solution has a GlobalAssemblyInfo.cs to assign version info to the binaries etc... 我的Visual Studio解决方案具有GlobalAssemblyInfo.cs,可将版本信息分配给二进制文件等。

The build number I use for example is 3.4.* which means 3 is the major version, 4 is the minor version and the wildcard gives me an automated build and iteration number. 例如,我使用的内部版本号是3.4。*,这意味着3是主要版本,4是次要版本,而通配符为我提供了一个自动的内部版本和迭代编号。

My Test environments can have multiple versions of my application deployed at any one time. 我的测试环境可以一次部署多个版本的应用程序。

This was controlled manually in the past by appending the major and minor version numbers to the application pool name and web application names, eg 过去,通过在应用程序池名称和Web应用程序名称后附加主要和次要版本号来手动控制此操作。

  • ApplicationPool_3_2 ApplicationPool_3_2
  • ApplicationPool_3_3 ApplicationPool_3_3
  • ApplicationPool_3_4 ApplicationPool_3_4
  • .... ....

I'm attempting to get all of this into TFS Release Management and have got my build working and firing a release which creates the application pool and web application etc... But I can't work out how to get the major and minor version numbers into TFS Release Management so that I can name the application pool and web application correctly. 我正在尝试将所有这些都放入TFS发行管理中,并让我的构建工作并启动一个发行版,该发行版创建了应用程序池和Web应用程序等。但是我不知道如何获得主要版本和次要版本TFS版本管理中的编号,以便我可以正确命名应用程序池和Web应用程序。

I'm using Visual Studio 2013.4, TFS 2013.4 and Release Management 2013.4. 我正在使用Visual Studio 2013.4,TFS 2013.4和版本管理2013.4。 All of which are on premise. 所有这些都是前提条件。

You can create major and minor version numbers by adding variables in Variables tab of Build Definition. 您可以通过在“构建定义”的“变量”选项卡中添加变量来创建主要和次要版本号。 Then use these variables for Version Number by adding 'Version .NET Assemblies' build step like AssemblyVersion("$(VersionMain).$(VersionSub1).$(VersionSub2).$(VersionSub3)"), AssemblyFileVersion("$(VersionMain).$(VersionSub1).$(VersionSub2).$(VersionSub3)") 然后通过添加“ Version .NET Assemblies”构建步骤,将这些变量用于版本号,例如AssemblyVersion(“ $(VersionMain)。$(VersionSub1)。$(VersionSub2)。$(VersionSub3)”),AssemblyFileVersion(“ $(VersionMain) 。$(VersionSub1)。$(VersionSub2)。$(VersionSub3)“)

I ended up writing a powershell script and calling that at the start of my build :- 我最终写了一个powershell脚本,并在构建开始时就调用了它:

$splitbuildNumber = $env:BUILD_BUILDNUMBER.Split(".")
$ApplicationVersionMajor = $splitbuildNumber[0]
$ApplicationVersionMinor = $splitbuildNumber[1]
$ApplicationVersionBuild = $splitbuildNumber[2]
$ApplicationVersionRevision = $splitbuildNumber[3]

Write-Host “##vso[task.setvariable variable=ApplicationVersionMajor]$ApplicationVersionMajor”
Write-Host “##vso[task.setvariable variable=ApplicationVersionMinor]$ApplicationVersionMinor”
Write-Host “##vso[task.setvariable variable=ApplicationVersionBuild]$ApplicationVersionBuild”
Write-Host “##vso[task.setvariable variable=ApplicationVersionRevision]$ApplicationVersionRevision”`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM