3

我试图RemoveFolderEx在卸载应用程序时从我的安装文件夹中删除一个上一级的文件夹。这是我所拥有的,但它不起作用:

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="MyAppBaseFolder" Name="MyAppID">
          <Directory Id="INSTALLFOLDER" Name="MyAppLauncher">
            <Directory Id="UPDATESCRIPTSFOLDER" Name="Scripts" />
            <Component Id="CleanupMainApplicationFolder" Guid="*">
              <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp ID\MyApp ID Windows Client" Name="Path" Type="string" Value="${path::getfullpath(path::combine([INSTALLFOLDER],'..\MyApp'))}" KeyPath="yes" />
              <util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />
            </Component>
          </Directory>
        </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="MyApp ID"/>
      </Directory>
    </Directory>
  </Fragment>

MSI 会构建得很好,但是当我运行设置时,它似乎在RegistryValue元素上失败并抱怨路径中的“..”。我正在制作的字符串就像:"C:\Program Files (X86)\MyApp ID\MyAppLauncher\..\MyApp". 我需要它来解决:"C:\Program Files (X86)\MyApp ID\MyApp".

我对这些${path:: ... }东西不太熟悉。我看到了几个例子,${path::combine()}所以我想我认为这可以getfullpath在 .NET 中使用。也许确实如此,我的语法是错误的?

谢谢!

编辑:对不起,我${path::combine...BUILDING WIX得到了这些东西,但没有完全阅读那篇文章在做什么。它与 wxs 文件无关,它用于 NAnt(如下所述的 Rob)。所以我想我的问题很简单:我如何组合和解析绝对路径和相对路径,如C:\Program files (X86)\MyApp ID\MyAppLauncher\..\MyApp. 谢谢

EDIT2:再次感谢 Rob,我非常专注于解决我什至没有考虑过最明显的解决方案的路径,即简单地引用一个新<Directory元素。我现在使用以下代码清理 2 个文件夹:

  <Property Id="APPLICATIONFOLDER">
    <RegistrySearch Key="SOFTWARE\MyApp ID\MyApp ID Windows Client" Root="HKLM" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
  </Property>

  <Property Id="PRINTERFOLDER">
    <RegistrySearch Key="SOFTWARE\MyApp ID\MyApp ID Printer" Root="HKLM" Type="raw" Id="PRINTERFOLDER_REGSEARCH" Name="Path" />
  </Property>

...

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="MyAppBaseFolder" Name="MyAppID">
          <Directory Id="INSTALLFOLDER" Name="MyAppLauncher">
            <Directory Id="UPDATESCRIPTSFOLDER" Name="Scripts" />
            <Component Id="CleanupMainApplicationFolder" Guid="*">
              <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp ID\MyApp ID Windows Client" Name="Path" Type="string" Value="[LM_INSTALLFOLDER]" KeyPath="yes" />
              <util:RemoveFolderEx On="uninstall" Property="APPLICATIONFOLDER" />

              <RegistryValue Root="HKLM" Key="SOFTWARE\MyApp ID\MyApp ID Printer" Name="Path" Type="string" Value="[LMP_INSTALLFOLDER]" />
              <util:RemoveFolderEx On="uninstall" Property="PRINTERFOLDER" />
            </Component>
          </Directory>
          <Directory Id="LM_INSTALLFOLDER" Name="MyApp" >
          </Directory>
          <Directory Id="LMP_INSTALLFOLDER" Name="MyAppPrinter" >
          </Directory>
        </Directory>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="MyApp ID"/>
      </Directory>
    </Directory>
  </Fragment>
4

1 回答 1

3

您在其中的语法RegistryValue/@Value看起来像 NAnt 或其他东西。目前尚不清楚是什么解释,但 Windows 安装程序不会。您有几个选项可以使该注册表值正确。首先,将RegistryValue元素更改为如下所示:

<RegistryValue Root="HKLM"
               Key="SOFTWARE\MyApp ID\MyApp ID Windows Client"
               Name="Path"
               Type="string"
               Value="[MyAppBaseFolder]MyApp"
               KeyPath="yes" />

或者,您可以在目录树中定义“MyApp”并直接引用它。这看起来有点像将以下内容添加为MyAppBaseFolder(peer of INSTALLFOLDER) 的子项:

 <Directory Id='MyAppFolder' Name='MyApp' />

然后更新你的RegistryValue元素看起来像:

<RegistryValue Root="HKLM"
               Key="SOFTWARE\MyApp ID\MyApp ID Windows Client"
               Name="Path"
               Type="string"
               Value="[MyAppFolder]"
               KeyPath="yes" />

我更喜欢后者,但这只是因为我更喜欢使用不连接字符串的标识符。

于 2013-04-26T21:02:22.600 回答