使用WIX和.build文件的TFS构建定义

时间:2017-11-29 14:56:04

标签: msbuild wix tfsbuild

我试图让一个构建工作在TFS服务器上来吐出我们的.msi。在当地我会跑:

C:\Dev\Installer>msbuild /t:Build;PublishWebsite;Harvest;WIX setup.build

使用' setup.build':

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build"
       xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup >
    <WebSiteSource>..\FrontEnd\</WebSiteSource>
    <SetupF>..\Setup\</SetupF>
    <PublishF>publish\</PublishF>
    <Publish>$(SetupF)$(PublishF)</Publish>
    <WebSiteContentCode>WebSiteContent.wxs</WebSiteContentCode>
  <WebSiteContentObject>WebSiteContent.wixobj</WebSiteContentObject>
     <EnableProjectHarvesting>True</EnableProjectHarvesting>
  <MsiOut>bin\Release\Dashboard.msi</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="ProductUI.wxs" />
        <WixCode Include="IISConfiguration.wxs" />

  </ItemGroup>

   <ItemGroup>
    <WixObject Include="Product.wixobj" />
    <WixObject Include="$(WebSiteContentObject)" />
      <WixObject Include="ProductUI.wixobj" />
        <WixObject Include="IISConfiguration.wixobj" />

  </ItemGroup>

   <Target Name="Build">
    <!-- Compile whole solution in release mode -->
    <MSBuild
        Projects="..\WebDashboard.sln"
        Targets="ReBuild"
        Properties="Configuration=Release;Platform=Any CPU" />
  </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="..\\FrontEnd\WebDashboard.csproj"
            Targets="ResolveReferences;_CopyWebApplication"
            Properties="OutDir=$(Publish)bin\;WebProjectOutputDir=
                            $(Publish);Configuration=Release;Platform=AnyCPU" />
    </Target>
     <Target Name="Harvest">
    <!-- Harvest all content of published result -->
        <Exec
            Command='"$(WiX)bin\heat" dir $(Publish) -dr INSTALLFOLDER -ke -srd -cg MyWebWebComponents -var var.publishDir -gg -out $(WebSiteContentCode)'
            ContinueOnError="false"
            WorkingDirectory="." />
    </Target>
    <Target Name="WIX">
        <Exec
            Command='"$(WiX)bin\candle" -ext WixIISExtension -dpublishDir=$(Publish) -dMyWebResourceDir=. @(WixCode, &apos; &apos;)'
            ContinueOnError="false"
            WorkingDirectory="." />
        <Exec
            Command='"$(WiX)bin\light" -ext WixIISExtension -ext WixUIExtension -out $(MsiOut) @(WixObject, &apos; &apos;)'
            ContinueOnError="false"
            WorkingDirectory="." />


  <!-- A message at the end -->
  <Message Text="Install package has been created." />
    </Target>
    <Target Name="DeleteTmpFiles">
        <RemoveDir Directories="$(Publish)" ContinueOnError="false" />
        <RemoveDir Directories="$(SetupF)" ContinueOnError="false" />
        <Delete Files="@(WixObject);@(WebSiteContent)" />
    </Target>
</Project>

如何在TFS上的构建定义中运行它?我已尝试使用正常的命令提示符,但它说msbuild无法识别。还有什么我可以使用或者有没有人知道msbuild工具的完整路径?

1 个答案:

答案 0 :(得分:0)

使用命令行任务并将“工具”设置为

来修复它
C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe

的论据
 /t:Build;PublishWebsite;Harvest;WIX setup.build

然后将'Working Folder'高级设置为setup.build文件的位置。