我试图为Visual Studio Installer项目创建自定义操作,以修改配置文件的权限。

Installer.cs如下:

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 class = true)添加到安装项目的“自定义操作”的“提交”部分。

运行安装程序时,出现以下错误:
Error 1001: Could not find file 'c:\mypath\myapp.InstallState'

搜寻网络时,我发现了一些类似经历的例子,但是所提供的解决方案中没有一个对我有用。

有任何想法吗?

最佳答案

You can find a solution here

去引用:

关于c# - 自定义操作-错误1001 : Could not find file myApp. InstallState,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8063485/

10-13 07:02