我在TFS上设置CI构建。团队成员开发人员不喜欢卸载 .wixproj 文件以编辑msbuild定义(因为它是“隐藏”)并且我类同意这一点的想法。
所以他创建了一个单独的 setup.build 文件,他打电话给:
msbuild /t:Build;PublishWebsite;Harvest;WIX setup.build
其内容如下:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebSiteSource>..\InstoreApplications\</WebSiteSource>
<SetupF>..\Setup\</SetupF>
<PublishF>publish\</PublishF>
<Publish>$(SetupF)$(PublishF)</Publish>
<WebSiteContentCode>WebSiteContent.wxs</WebSiteContentCode>
<WebSiteContentObject>WebSiteContent.wixobj</WebSiteContentObject>
<!--<MsiOut>bin\\Release\\INT SMK Coles Store WebApi 1.0.1.msi</MsiOut>-->
<MsiName>INT SMK Instore Applications 1.0.2.msi</MsiName>
<MsiOut>bin\Release\$(MsiName)</MsiOut>
</PropertyGroup>
<!-- Defining group of temporary files which is the content of the web site. -->
<ItemGroup>
<WebSiteContent Include="$(WebSiteContentCode)" />
</ItemGroup>
<!-- The list of WIX input files -->
<ItemGroup>
<WixCode Include="Product.wxs" />
<WixCode Include="$(WebSiteContentCode)" />
<WixCode Include="WebAPIDlg.wxs" />
<WixCode Include="IISConfiguration.wxs" />
<WixCode Include="WixUI_InstallDirNoLicense.wxs" />
</ItemGroup>
<!-- The list of WIX after candle files -->
<ItemGroup>
<WixObject Include="Product.wixobj" />
<WixObject Include="$(WebSiteContentObject)" />
<WixObject Include="WebAPIDlg.wixobj" />
<WixObject Include="IISConfiguration.wixobj" />
<WixObject Include="WixUI_InstallDirNoLicense.wixobj" />
</ItemGroup>
<!-- Define default target with name 'Build' -->
<Target Name="Build">
<!-- Compile whole solution in release mode -->
<MSBuild
Projects="..\InstoreApplications.sln"
Targets="ReBuild"
Properties="Configuration=Release" />
</Target>
<Target Name="PublishWebsite">
<!-- Remove complete publish folder in order to
be sure that evrything 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="..\\InstoreApplications\InstoreApplications.csproj"
Targets="ResolveReferences;_CopyWebApplication"
Properties="Configuration=Release;WebProjectOutputDir=$(Publish)\;OutDir=$(Publish)bin\;" />
</Target>
<!-- Define creating installer in another target -->
<Target Name="Harvest">
<!-- Harvest all content of published result -->
<Exec
Command='"$(Wix)bin\heat" dir $(Publish) -dr INSTALLDIR -ke -srd -cg ApplicationComponents -var var.publishDir -gg -out $(WebSiteContentCode)'
ContinueOnError="false"
WorkingDirectory="." />
</Target>
<Target Name="WIX">
<!-- At last create an installer -->
<Exec
Command='"$(Wix)bin\candle" -ext WixIISExtension -ext WixUtilExtension -ext WixSqlExtension -dpublishDir=$(Publish) -dMyWebResourceDir=. @(WixCode, ' ')'
ContinueOnError="false"
WorkingDirectory="." />
<Exec
Command='"$(Wix)bin\light" -ext WixIISExtension -ext WixUIExtension -ext WixUtilExtension -ext WixSqlExtension -out "$(MsiOut)" @(WixObject, ' ')'
ContinueOnError="false"
WorkingDirectory="." />
<!-- A message at the end -->
<Message Text="Install package has been created." />
</Target>
<!-- Optional target for deleting temporary files. Usually after build -->
<Target Name="DeleteTmpFiles">
<RemoveDir Directories="$(Publish)" ContinueOnError="false" />
<RemoveDir Directories="$(SetupF)" ContinueOnError="false" />
<Delete Files="@(WixObject);@(WebSiteContent)" />
</Target>
</Project>
这在本地机器上运行得非常好。
对于TFS构建,我直接在构建定义中引用setup.build文件,并在高级&gt; MSBuild参数中传入:“/ t:Build; PublishWebsite; Harvest; WIX”...这会产生“成功”然而,构建不再产生MSI。
我 相信 问题出现在HEAT生成文件和WIX挑选这些文件之间,请注意变量:
<SetupF>..\Setup\</SetupF>
<PublishF>publish\</PublishF>
<Publish>$(SetupF)$(PublishF)</Publish>
HEAT命令 生成一个包含构建服务器上文件的文件夹,该文件夹最终位于/ src而不是/ bin下,这在逻辑上与本地构建相同
然而,由于路径是相对的,我猜WIX蜡烛和/或光命令需要更改其WorkingDirectory?...有没有办法做到这一点,而不是破坏本地构建而不是硬编码路径?
答案 0 :(得分:0)
是的,与TFS Team Build相比,使用条件让属性在桌面版本上使用不同的值(请参阅documentation)。
如果您的脚本是在Visual Studio中运行的,请检查BuildingInsideVisualStudio MSBuild属性。
在TFS 20102中,您通常会自定义构建工作流以传递MSBuild脚本工作流变量(例如Pass Relative Path Arguments to MSBuild in TFS2010 Team Build)。在TFS 2013中,由于您拥有大量有用的环境属性,因此更加容易(请参阅documentation)。