Visual studio 2015 如何更改安装项目版本(在TFS 2015[vNext build]中)

Visual studio 2015 如何更改安装项目版本(在TFS 2015[vNext build]中),visual-studio-2015,msbuild,tfs-2015,vnext,Visual Studio 2015,Msbuild,Tfs 2015,Vnext,在TFS 2015中生成项目设置文件\msi时,我使用 devenv命令行任务: solutionPath /build BuildConfiguration /project projectPath 我的问题是,我如何才能改变msi版本(如果可能的话)从这行像$(构建版本) 已选中MSDN devenv命令行(无) 谢谢假设您想在生成过程中更改.vdproj文件中的ProductVersion值。没有直接更改此项的命令,您是正确的 您需要使用powershell或通过编程更改版本。以下是中的

在TFS 2015中生成项目设置文件\msi时,我使用

devenv命令行任务:

solutionPath /build BuildConfiguration /project projectPath
我的问题是,我如何才能改变msi版本(如果可能的话)从这行像$(构建版本)

已选中MSDN devenv命令行(无)


谢谢

假设您想在生成过程中更改
.vdproj
文件中的
ProductVersion
值。没有直接更改此项的命令,您是正确的

您需要使用powershell或通过编程更改版本。以下是中的代码片段,您可以参考:

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(); 
    } 
 }
static void Main(字符串[]args)
{
字符串setupFileName=@“”;
StreamReader=File.OpenText(setupFileName);
string file=string.Empty;
尝试
{ 
正则表达式=新正则表达式(@“(?:\“ProductCode\”)=
\“8.{([\d\w-]+)}”);
正则表达式1=新正则表达式(@“(?:\“UpgradeCode\”)=
\“8.{([\d\w-]+)}”);
file=reader.ReadToEnd();
file=expression.Replace(文件“\”ProductCode\”=\“8:{”+
Guid.NewGuid().ToString().ToUpper()+“}”);
file=expression1.Replace(文件“\”升级代码“=”8:{”
+Guid.NewGuid().ToString().ToUpper()+“}”);
} 
最后
{ 
//关闭文件,否则编译可能无法工作
reader.Close();
} 
TextWriter tw=新的StreamWriter(设置文件名);
尝试
{ 
tw.Write(文件);
} 
最后
{ 
//关闭小溪
tw.Close();
} 
}
或者,您可以参考中的AssemblyInfo.cs中替换AssemblyVersion的powershell脚本,以更改
.vdproj
文件中的
ProductVersion