次の方法で共有


Files are removed from the application folder after upgrading a Setup project from Visual Studio 2008 to Visual Studio 2010

If you migrate a Setup project from Visual Studio 2008 to Visual Studio 2010 and set the property RemovePreviousVersion=True, The upgrade package removes the application folder once it is installed.

This issue occurs because the Component GUID's are changed when setup projects are migrated from Visual Studio 2008 to Visual Studio 2010. InstallValidate Action marks components to be installed locally, RemoveExistingProducts that runs at sequence 6550 ends up removing those components.

There are two solutions:

1. Manually change the component GUID's to be the same as that of VS2008

2. Re-sequence the RemoveExistingProducts Action right after InstallInitialize (sequence number 1500+). This ensures that older files are removed and reinstalled by the newer version.

The second solution can be achieved by running a post build script OR manually editing the MSI package using Orca.exe(It comes with Windows SDK).

You can add the below text into a file next to your .vdproj called "fix.js", and then set your "PostBuildEvent" property to exactly the following string, to run it after every build - cscript.exe "$(ProjectDir)\fix.js" "$(BuiltOuputPath)"

============================================================================================================================================================================

//fix.js File

var newSequence = 1501;

var msiOpenDatabaseModeTransact = 1;

var msiViewModifyReplace = 4

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

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

var sql
var view
var record

try
{
WScript.Echo("Updating the InstallExecuteSequence table...");

    sql = "SELECT `Action`, `Sequence` FROM `InstallExecuteSequence` WHERE `Action`='RemoveExistingProducts'";
view = database.OpenView(sql);
view.Execute();
record = view.Fetch();
if (record.IntegerData(2) == newSequence)
throw "REP sequence doesn't match expected value - this database appears to have been already modified by this script!";
if (record.IntegerData(2) != 6550)
throw "REP sequence doesn't match expected value - this database was either already modified by something else after build, or was not produced by Visual Studio 2010!";
record.IntegerData(2) = newSequence;
view.Modify(msiViewModifyReplace, record);
view.Close();

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

Comments

  • Anonymous
    February 10, 2011
    The comment has been removed

  • Anonymous
    February 10, 2011
    The comment has been removed

  • Anonymous
    March 21, 2011
    Hi, this fix.js worked great for getting the files to install, instead of getting deleted. But now my files don't get registered for com interop.

  • Anonymous
    May 17, 2011
    hi all, i have VS2010, and i created deployment project to generate msi, and everything goes well, but sometime when i run the msi on any client pc it didn't remove the previous version even i set removepreviouspervios property to true, specifically when i updated the config file on pc manulay,.. any advice,,, thnx in advance

  • Anonymous
    June 02, 2011
    You can share the verbose log for the upgrade package.

  • Anonymous
    March 27, 2012
    Kasper, did you ever get your problem resolved?