Настраиваемое действие - ошибка 1001: не удалось найти файл myApp.InstallState

Я попытался создать настраиваемое действие для проекта установщика Visual Studio, чтобы изменить разрешения для файла конфигурации.

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

Затем я добавляю основной вывод (класс установщика = true) в раздел «Фиксация» настраиваемых действий проекта установки.

Когда я запускаю установщик, я получаю следующую ошибку:

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

Очистка web Я нашел несколько примеров подобного опыта, но ни одно из предложенных решений у меня не сработало.

Есть идеи?

32
задан CJM 9 November 2011 в 10:16
поделиться