for building my project setup file\msi in TFS 2015 i use
devenv Command Line task:
solutionPath /build BuildConfiguration /project projectPath
My question is how can i change msi version (if it's possible) from that line like ... $(BuildVersion)
Checked MSDN devenv command line (nothing.)
thanks
Assumning you want to change the ProductVersion
value in .vdproj
file during build. You are correct that there is no command to change this directly.
You need to use powershell or programatically change the version. Here is a code snippet in this case you can refer to:
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();
}
}
Or you can refer to the powershell script that replace AssemblyVersion from AssemblyInfo.cs in this case to change ProductVersion
value in .vdproj
file.