How to change location of .InstallState file in Visual Studio generated by MSI

I have an MSI file that I created using a Visual Studio installation project. Installed creates an .InstallState file in the application directory. Is there a way to create this file in a different place than the default?

+3
source share
2 answers

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

+2
source

, /InstallStateDir = "c:\myfolder" (. KB946503). InstallContext , AssemblyInstaller, :

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;
}

Context["InstallStateDir"], , ; , , Uninstall , , Microsoft AssemblyInstaller.GetInstallStatePath.

+1

Source: https://habr.com/ru/post/1699217/


All Articles