我的第一个问题是,我应该努力让编译器使用自动生成的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>
我正在其他地方阅读最佳做法是使用自动生成的guids(-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:组件'cmp2BE6B5C092821452E1438D39A5110DDB'有一个 路径'TARGETDIR \ inetpub \ manager \ tools \ toolshome.aspx'的密钥文件。 由于此路径未植根于其中一个标准目录中 (如ProgramFilesFolder),此组件不符合标准 有一个自动生成的guid。 (这个错误也可能 如果路径包含可能的标准目录(例如嵌套a),则会发生 ProgramFilesFolder下名为“Common Files”的目录。)
我的目录片段是:
<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, ' ')'
ContinueOnError="false"
WorkingDirectory="." />
<Exec
Command='"$(WiX)bin\light.exe" -spdb -out $(MsiOut) @(WixObject, ' ')'
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使用目录的种子。我应该更改目录的位置吗?
谢谢!
答案 0 :(得分:1)
感谢@CheGueVerra,他指出了我正确的方向。我刚刚将目录位置更改为ProgramFiles,并且能够编译。
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Manager" />
</Directory>
</Directory>
</Fragment>
后来我发现了使用&#34; ComponentGuidGenerationSeed&#34;更好的方法。将目录保存在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>