Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Update MSI Version from VS Team Build
 

Update MSI Version from VS Team Build

Is it possible to update the "Product Name" and "Version" of the MSI from Visual Studio Team Build?

Any scripts to update will also help

Thanks

Mamatha

Mamatha  Tuesday, October 07, 2008 4:08 PM

You should be able to add a custom build step into your team build process which calls a jscript to update an existing msi's product name and product version.

The example below shows one such jscript:

Code Snippet

// Constant values from Windows Installer
var msiOpenDatabaseModeTransact = 1;

var msiViewModifyInsert = 1
var msiViewModifyUpdate = 2
var msiViewModifyAssign = 3
var msiViewModifyReplace = 4
var msiViewModifyDelete = 6

if (WScript.Arguments.Length != 3)
{
WScript.StdErr.WriteLine(WScript.ScriptName + " file version name");
WScript.Quit(1);
}

var filespec = WScript.Arguments(0);
var installer = WScript.CreateObject("WindowsInstaller.Installer");
var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact);

try
{
UpdateProperty(database, "ProductVersion", WScript.Arguments(1));
UpdateProperty(database, "ProductName", WScript.Arguments(2));

database.Commit();
}
catch(e)
{
WScript.StdErr.WriteLine(e);
WScript.Quit(1);
}

function UpdateProperty(database, propertyName, propertyValue)
{
var sql
var view
var record

sql = "SELECT `Property`, `Value` FROM `Property` WHERE `Property`='" + propertyName + "'";
view = database.OpenView(sql);
view.Execute();
record = view.Fetch();
record.StringData(2) = propertyValue;
view.Modify(msiViewModifyReplace, record);
view.Close();
}

Mike Wade - MSFT  Wednesday, October 08, 2008 4:11 PM

Since Setup Projects aren't really supported under Team Build, basically the answer is no.

However, there is a workaround to execute a command that uses VS to build the Setup Project. If you are using this, then the way to change those properties are to edit the .vdproj file. That's technically not supported, but it should work.

The alternative is to use WiX from SourceForge. It will take a bit more effort to author up-front, but does have MSBuild tasks, and you'd just have to edit .XML files to change those properties, and might even be able to tokenize the values and pass them in at build time.

HTH

David Guyer MSFT  Wednesday, October 08, 2008 5:24 AM

You should be able to add a custom build step into your team build process which calls a jscript to update an existing msi's product name and product version.

The example below shows one such jscript:

Code Snippet

// Constant values from Windows Installer
var msiOpenDatabaseModeTransact = 1;

var msiViewModifyInsert = 1
var msiViewModifyUpdate = 2
var msiViewModifyAssign = 3
var msiViewModifyReplace = 4
var msiViewModifyDelete = 6

if (WScript.Arguments.Length != 3)
{
WScript.StdErr.WriteLine(WScript.ScriptName + " file version name");
WScript.Quit(1);
}

var filespec = WScript.Arguments(0);
var installer = WScript.CreateObject("WindowsInstaller.Installer");
var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact);

try
{
UpdateProperty(database, "ProductVersion", WScript.Arguments(1));
UpdateProperty(database, "ProductName", WScript.Arguments(2));

database.Commit();
}
catch(e)
{
WScript.StdErr.WriteLine(e);
WScript.Quit(1);
}

function UpdateProperty(database, propertyName, propertyValue)
{
var sql
var view
var record

sql = "SELECT `Property`, `Value` FROM `Property` WHERE `Property`='" + propertyName + "'";
view = database.OpenView(sql);
view.Execute();
record = view.Fetch();
record.StringData(2) = propertyValue;
view.Modify(msiViewModifyReplace, record);
view.Close();
}

Mike Wade - MSFT  Wednesday, October 08, 2008 4:11 PM

Thanks a lot for the reply. Well the code snippet worked. Now I have one more questions, is there a way that I can update the .vdproj file (Setup project file) with a vbscript during the Team Build process, so that I can have the vdproj file under my source control.

Regards

Mamatha

Mamatha  Friday, October 10, 2008 1:53 PM

You can use google to search for other answers

Custom Search

More Threads

• Deploying a WPF App with Click Once Issue
• vs 2008 clickonce .net 3.0 as prerequisite
• ClickOnce Deploy fails due to TimeOut on file download.
• Set values from Registry in the User Interface forms
• ClickOnce Deployment
• Custom application settings
• Non-English Installation Dialogue box
• MSBuild/ClickOnce signing issue
• -> Basic Setup Question
• Setup project removes com reference