将 Wix 属性设置为 TFS 构建位置 [英] Set Wix property to TFS build location

查看:20
本文介绍了将 Wix 属性设置为 TFS 构建位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图找到我的问题的答案,但没有找到;因此我将把解决方案放在这里.我希望它对其他人有帮助.

I have been trying to find an answer to my question and could not find it; hence I will put the solution here. I hope it is helpful to others.

我希望我的 Wix 项目在 TFS 2010 构建过程中构建.作为其中的一部分,我希望 Wix 的源文件位置指向 TFS 的构建位置.例如,我想要:

I want my Wix project to build in TFS 2010 build process. As part of this, I want the source files location for my Wix to point to the build location of the TFS. For example, I want:

<File Id="ABC" KeyPath="yes" source="C:\Builds\1\MyBuild\assembly.dll" />

成为:

<File Id="ABC" KeyPath="yes" source="$(var.TFSLOCATION)\assembly.dll" />

TFSLOCATION"是一个需要填充 TFS 构建位置的 wix 属性.这需要在构建过程中发生,构建位置路径传递给 Wix 项目.

The 'TFSLOCATION' is a wix property that needs to be populated with the location of TFS build. This needs to happen during the build process, where the build location path is passed to the Wix project.

我阅读了以下文章:

http://www.ageektrapped.com/blog/setting-properties-for-wix-in-msbuild/

这就是我对 Wix 项目文件 (wixproj) 所做的:

So this is what I did to my Wix project file (wixproj):

为了从 TFS MSBuild 过程中设置 wix 属性,wix 项目文件需要两个更改:

In order to set wix property from TFS MSBuild process the wix project file needs two changes:

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <ProductVersion>3.5</ProductVersion>
    <SourceLocation Condition="'$(SourceLocation)' == '' ">UNKNOWN</SourceLocation>
    <ProjectGuid>{cae7e273-2de5-4a60-9c4f-9da5f094caf5}</ProjectGuid>
    <SchemaVersion>2.0</SchemaVersion>
    <OutputName>N4S.MSO.BAM.Installer</OutputName>
    <OutputType>Package</OutputType>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> 
  <OutputPath>bin\$(Configuration)\</OutputPath> 
  <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
  <DefineConstants>LOCATION=$(SourceLocation)</DefineConstants>
</PropertyGroup>

在上面的xml中,请注意以下两行:

In the above xml, please note the following two lines:

<SourceLocation Condition="'$(SourceLocation)' == '' ">UNKNOWN</SourceLocation>

<DefineConstants>LOCATION=$(SourceLocation)</DefineConstants>

第一行指定属性SourceLocation"并将其设置为默认的UNKNOWN"值(如果未设置).第二行在发布"配置中定义了一个名为LOCATION"的常量.此常量的值设置为SourceLocation"属性的值.

The first line specifies a property 'SourceLocation' and sets it to a default 'UNKNOWN' value, if is is not set. The second line defines a constant called 'LOCATION' in the 'Release' configuration. The value of this constant is set to the value of 'SourceLocation' property.

现在,您需要对 Product.wxs 文件(或任何 wxs 文件的名称)进行以下更改.

Now, you need to make the following changes to your Product.wxs file (or whatever the name of your wxs file is).

  • 首先定义一个 wix 属性.
<?define TFSLOCATION="$(var.LOCATION)"?>

  • 现在,更新 File 元素.
  • <File Id="ABC" KeyPath="yes" source="$(var.TFSLOCATION)\assembly.dll" />
    

    TFS 2010 构建模板更改

    • 打开 TFS 2010 构建模板.
    • 寻找为项目运行 MSBuild"任务.
    • 打开此任务的属性并转到CommandLineArguments"属性.
    • 将此属性的值设置为:
    • String.Format("/p:SourceLocation={0}", BinariesDirectory)
      

      完成

      您现在有一个从 TFS 构建过程填充的 wix 属性.

      Done

      You now have a wix property populated from your TFS build process.

      推荐答案

      如果您在 wixproj 文件中设置了对正在构建的项目的引用,则可以引用它们的目标路径.因此,如果您有两个项目 MyProject 和 MyProjectInstaller,请将 MyProjectInstaller 中的引用设置为 MyProject.

      If you set a reference in your wixproj file to the project(s) you are building you can reference their target paths. So if you have two projects MyProject and MyProjectInstaller, set a reference in MyProjectInstaller to MyProject.

      现在在 product.wxs 文件中,您的 File 元素将如下所示:

      Now in the product.wxs file your File elements would look like this:

      <File Id='EXE' Name='$(var.MyProject.TargetDir)\MyProject.exe' />
      <File Id='DLL' Name='$(var.MyProject.TargetDir)\MyProject.dll' />
      ...
      

      这样做的好处是无论您是在本地构建还是在构建服务器上构建,目标目录都是正确的.

      The benefit to this is that the target dir is correct regardless of whether you're building locally or on a build server.

      这篇关于将 Wix 属性设置为 TFS 构建位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆