本文介绍了自定义操作 - 错误1001:找不到文件myApp.InstallState的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试创建一个Visual Studio安装项目修改权限配置文件自定义操作

I have tried to create a custom action for a Visual Studio Installer project to modify the permissions for a config file.

Installer.cs如下:

The Installer.cs is as follows:

public override void Commit(IDictionary savedState)
{
    base.Commit(savedState);

    // Get path of our installation (e.g. TARGETDIR)
    //string configPath = System.IO.Path.GetDirectoryName(Context.Parameters["AssemblyPath"]) + @"\config.xml";
    string configPath = @"C:\Program Files\Blueberry\Serial Number Reservation\config.xml";

    // Get a FileSecurity object that represents the current security settings.
    FileSecurity fSecurity = File.GetAccessControl(configPath);

    //Get SID for 'Everyone' - WellKnownSidType works in non-english systems
    SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);

    // Add the FileSystemAccessRule to the security settings.
    fSecurity.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.Modify | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));

    // Set the new access settings.
    File.SetAccessControl(configPath, fSecurity);

}

public override void Install(IDictionary stateSaver)
{
    base.Install(stateSaver);
}

public override void Rollback(IDictionary savedState)
{
    base.Rollback(savedState);
}

public override void Uninstall(IDictionary savedState)
{
    base.Uninstall(savedState);
}



然后我添加主输出(Installer类=真)进入提交节。的安装项目的自定义操作

Then I add the Primary Output (Installer class = true) into the Commit section of the setup project's Custom Actions.

当我运行安装程序,我收到以下错误:

When I run the installer, I get the following error:

Error 1001: Could not find file 'c:\mypath\myapp.InstallState'

网上淘我发现的相似经历的几个例子,但没有提供的解决方案都为我工作。

Scouring the web I've found a few examples of similar experiences, but none of the solutions offered have worked for me.

任何想法?

推荐答案

找到解决报价:

问题是微星的基础设施正在寻找这通常是在安装
阶段创建的安装状态文件。如果自定义操作不参加安装阶段,
没有文件被创建。

解决的办法是添加自定义操作都安装和
提交阶段,虽然它在安装阶段什么都不做。

The solution is to add the custom action to both the Install and the Commit phases, although it does nothing during the install phase.

这篇关于自定义操作 - 错误1001:找不到文件myApp.InstallState的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:37