【问题标题】:How to change setup project version (in TFS 2015 [vNext build])如何更改设置项目版本(在 TFS 2015 [vNext build] 中)
【发布时间】:2017-02-05 09:51:59
【问题描述】:
用于在我使用的 TFS 2015 中构建我的项目设置文件\msi
devenv 命令行任务:
solutionPath /build BuildConfiguration /project projectPath
我的问题是如何从该行更改 msi 版本(如果可能),例如 ... $(BuildVersion)
检查了 MSDN devenv 命令行(什么都没有。)
谢谢
【问题讨论】:
标签:
visual-studio-2015
msbuild
tfs-2015
vnext
【解决方案1】:
假设您想在构建期间更改 .vdproj 文件中的 ProductVersion 值。您是正确的,没有命令可以直接更改它。
您需要使用 powershell 或以编程方式更改版本。这是this case中的代码sn-p,可以参考:
static void Main(string[] args)
{
string setupFileName = @"<Replace the path to vdproj file>";
StreamReader reader = File.OpenText(setupFileName);
string file = string.Empty;
try
{
Regex expression = new Regex(@"(?:\""ProductCode\"" =
\""8.){([\d\w-]+)}");
Regex expression1 = new Regex(@"(?:\""UpgradeCode\"" =
\""8.){([\d\w-]+)}");
file = reader.ReadToEnd();
file = expression.Replace(file, "\"ProductCode\" = \"8:{" +
Guid.NewGuid().ToString().ToUpper() + "}");
file = expression1.Replace(file, "\"UpgradeCode\" = \"8:{"
+ Guid.NewGuid().ToString().ToUpper() + "}");
}
finally
{
// Close the file otherwise the compile may not work
reader.Close();
}
TextWriter tw = new StreamWriter(setupFileName);
try
{
tw.Write(file);
}
finally
{
// close the stream
tw.Close();
}
}
或者您可以参考powershell脚本,将this case中的AssemblyInfo.cs中的AssemblyVersion替换为.vdproj文件中的ProductVersion值。