views:

560

answers:

2

I have an MSI file that I have created using a Visual Studio Setup Project. The installed generates an .InstallState file in the application directory. Is there a way to have this file generated in a different location rather than the default location?

+1  A: 

You need to set the value of InstallStateDir.
You need to override the Commit/Install/Rollback/Uninstall and set the value of InstallStateDir (I.E. Context["InstallStateDir"] = @"c:\mydir") .

Shay Erlichmen
A: 

This should also work by specifying /InstallStateDir="c:\myfolder" from the commandline (see KB946503). However, InstallContext is converting all parameter names to lowercase which breaks the following code from AssemblyInstaller, expecting to find the mixed case parameter name:

private string GetInstallStatePath(string assemblyPath)
{
    string str2 = base.Context.Parameters["InstallStateDir"];
    assemblyPath = Path.ChangeExtension(assemblyPath, ".InstallState");
    if (!string.IsNullOrEmpty(str2))
    {
        return Path.Combine(str2, Path.GetFileName(assemblyPath));
    }
    return assemblyPath;
}

Setting Context["InstallStateDir"] would possibly work for saving the state; however, as the state is loaded before Uninstall can modify the context, this is no viable solution until Microsoft fixes the above AssemblyInstaller.GetInstallStatePath method.