msbuild - 我应该让热量产生 guids 吗?在编译期间尝试自动生成时出错,因为我没有使用标准目录

标签 msbuild wix

我的第一个问题是,我应该努力让编译器使用自动生成的 guid 吗?

我正在尝试使用 WiX 为网站创建安装程序。请原谅我的无知,这是我的第一个 WiX 项目。我正在关注这篇文章:

http://blog.bartdemeyer.be/2013/10/create-an-installer-for-website-with-wix-part-1/

该过程使用 msbuild 调用多个 WiX 工具以最终创建 MSI。该示例在调用 heat 时使用“Generate guids now”(“-gg”开关):

<Target Name="Harvest">
    <!-- Harvest all content of published result -->
    <Exec
        Command='"$(WiX)bin\heat.exe" dir $(Publish) -dr INSTALLFOLDER -ke -srd -cg MgrWebComponents -var var.publishDir -gg -out $(WebSiteContentCode)'
        ContinueOnError="false"
        WorkingDirectory="." />
</Target>

我在别处阅读最佳做法是使用自动生成的 guid(-ag 开关)来确保正确安装产品更新。我注意到每次运行加热时 guid 都会发生变化。
<Fragment>
    <ComponentGroup Id="MgrWebComponents">
        <Component Id="cmp56294569B275493319100C26538BA16C" Directory="INSTALLFOLDER" Guid="{A43DA07B-C4CD-4FE0-AC09-EEA693AB2BA7}">
            <File Id="fil93D55732EC03C2B809F21B9423BF5550" KeyPath="yes" Source="$(var.publishDir)\BrandImageService.ashx" />
        </Component>
        <Component Id="cmp6BD39B2D572EA73C29A81AE5D1C3F0C4" Directory="INSTALLFOLDER" Guid="{99B7B916-AEC0-4EE9-B17F-E7B325E93A4D}">
            <File Id="filE861424851E26D456D43F5D1855B3E7B" KeyPath="yes" Source="$(var.publishDir)\Dashboard.aspx" />
        </Component>
...

如果我应该使用自动生成的 guid,我需要让编译器正常工作。我在编译时尝试使用自动生成的 guid 时,每个文件都会出错。

LGHT0231: The component 'cmp2BE6B5C092821452E1438D39A5110DDB' has a key file with path 'TARGETDIR\inetpub\manager\tools\toolshome.aspx'. Since this path is not rooted in one of the standard directories (like ProgramFilesFolder), this component does not fit the criteria for having an automatically generated guid. (This error may also occur if a path contains a likely standard directory such as nesting a directory with name "Common Files" under ProgramFilesFolder.)



我的目录片段是:
<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="INETPUB" Name="Inetpub">
            <Directory Id="INSTALLFOLDER" Name="Manager" />
        </Directory>
    </Directory>
</Fragment>

产生的热量片段看起来像:
<Fragment>
    <ComponentGroup Id="MgrWebComponents">
        <Component Id="cmp56294569B275493319100C26538BA16C" Directory="INSTALLFOLDER" Guid="*">
            <File Id="fil93D55732EC03C2B809F21B9423BF5550" KeyPath="yes" Source="$(var.publishDir)\BrandImageService.ashx" />
        </Component>
        <Component Id="cmp6BD39B2D572EA73C29A81AE5D1C3F0C4" Directory="INSTALLFOLDER" Guid="*">
            <File Id="filE861424851E26D456D43F5D1855B3E7B" KeyPath="yes" Source="$(var.publishDir)\Dashboard.aspx" />
        </Component>
...

msbuild 的目标:
<Target Name="Build">
    <!-- Compile whole solution in release mode -->
    <MSBuild
        Projects="..\Manager.sln"
        Targets="ReBuild"
        Properties="Configuration=Release" />
</Target>

<Target Name="PublishWebsite">
    <!-- Remove complete publish folder in order to 
            be sure that everything will be newly compiled -->
    <Message Text="Removing publish directory: $(SetupF)"/>
    <RemoveDir Directories="$(SetupF)" ContinueOnError="false" />
    <Message Text="Start to publish website" Importance="high" />
    <MSBuild
        Projects="..\\Manager\UI\Manager.UI.csproj"
        Targets="ResolveReferences;_CopyWebApplication"
        Properties="OutDir=$(Publish)bin\;WebProjectOutputDir=$(Publish);Configuration=Release" />
</Target>

<Target Name="Harvest">
    <!-- Harvest all content of published result -->
    <Exec
        Command='"$(WiX)bin\heat.exe" website $(Publish) -dr INSTALLFOLDER -ke -srd -cg MgrWebComponents -var var.publishDir -ag -out $(WebSiteContentCode)'
        ContinueOnError="false"
        WorkingDirectory="." />
</Target>

<Target Name="WIX">
    <!--     At last create an installer -->
    <Message Text="TEST: @(WixCode)"/>
    <Exec
        Command='"$(WiX)bin\candle.exe" -dpublishDir=$(Publish) -dMgrWebResourceDir=. @(WixCode, &apos; &apos;)'
        ContinueOnError="false"
        WorkingDirectory="." />
    <Exec
        Command='"$(WiX)bin\light.exe" -spdb -out $(MsiOut) @(WixObject, &apos; &apos;)'
        ContinueOnError="false"
        WorkingDirectory="." />

    <!-- A message at the end -->
    <Message Text="Install package has been created." />
</Target>

构建命令是:msbuild /t:Build;PublishWebsite;Harvest;WIX setup.build
我知道生成的 guid 使用目录的种子。我应该更改目录的位置吗?

谢谢!!

最佳答案

感谢@CheGueVerra,他为我指明了正确的方向。我只是将目录位置更改为 ProgramFiles 并且它能够编译。

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="Manager" />
      </Directory>
    </Directory>
  </Fragment>

后来我找到了一种更好的方法,即使用“ComponentGuidGenerationSeed”属性将目录保存在 inetpub 文件夹中。
<Directory Id='TARGETDIR' Name='SourceDir'>
    <Directory Id="IISMain" Name='inetpub'>
        <Directory Id="WWWMain" Name='wwwroot' 
           ComponentGuidGenerationSeed='{Put-your-own-generated-guid-here}'>
            <Directory Id='INSTALLFOLDER' Name='Manager'>
            </Directory>
        </Directory>
    </Directory>
</Directory>

关于msbuild - 我应该让热量产生 guids 吗?在编译期间尝试自动生成时出错,因为我没有使用标准目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28181501/

相关文章:

windows - 配置安装程序以在 Windows 启动时启用/禁用启动

visual-studio - MSBuild 失败,但在 VisualStudio 中加载项目后,它可以与 MSBuild 一起使用

.net - 在 NAnt 中从 <solution> 到 <exec program=msbuild>

user-interface - 如何向安装程序添加两个许可协议(protocol)?

installation - 如果在 wix 中回滚,则向用户显示错误消息

xml - 通过Xslt修改heat生成的WXS文件

c# - 加快 MSBuild 构建过程

visual-studio - MSBuild 删除不需要的文件

.net - 在没有Visual Studio的情况下构建.net应用程序

windows - 如何创建 Windows 8 风格的安装程序