【问题标题】:TFS 2015 pass variable to Wix at buildTFS 2015 在构建时将变量传递给 Wix
【发布时间】:2017-01-20 19:45:38
【问题描述】:

我正在努力在 TFS 2015 上创建构建定义。我们有 *.sln 文件并引用了 *.wixprojthere。在 Wix proj 中,我们使用如下变量: <File Id="MyFile" Name="MyFile.dll" Source="$(var.SourceLocation)" Vital="yes"/> 这个变量$(var.SourceLocation) 被传递给candle.exe

C:\Program Files (x86)\WiX Toolset v3.10\bin\candle.exe -d"SourceLocation=D:\agent_work\2\SomeLocation\bin\Debug\"

它在本地工作,因为我们在那里有这样的代码:

    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>3.8</ProductVersion>
    <ProjectGuid>{63f50ecb-3c8f-448c-ad0d-43739e6ad5f1}</ProjectGuid>
    <SchemaVersion>2.0</SchemaVersion>
    <OutputName>Setup AddIn</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>
    <SourceLocation Condition="$(SourceLocation) == '' ">$(SolutionDir)SomeLocation\bin\$(Configuration)\</SourceLocationAddIn>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <OutputPath>$(SolutionDir)OutPutpathLocation\bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
    <DefineConstants>SourceLocation=$(SourceLocation)</DefineConstants>
    <SuppressIces>ICE30;ICE91</SuppressIces>
    <Cultures>
    </Cultures>
    <LinkerAdditionalOptions>-cultures:en-us%3b</LinkerAdditionalOptions>
    <CompilerAdditionalOptions>
    </CompilerAdditionalOptions>
    <SuppressValidation>True</SuppressValidation>
  </PropertyGroup>

当我尝试在 TFS 2015 中运行它时,我通过 /p: 参数传递 SourceLocation:

如果我查看它评估的 msbuild 参数:

但是失败了。

2017-01-19T13:39:47.3202914Z 57>D:\agent_work\2\s\Setup\Installation\Installation\Sequences.wxs(11): 错误 LGHT0103: 系统找不到文件 '$(Build .BinariesDirectory)MyFile.dll'。 [D:\agent_work\2\s\Setup\Installation\Installation\Installation.wixproj]

如何在 TFS 2015 (vNext) 构建中将我自己的变量传递给 wixproj?


更新: 最后我修好了。正如 Arkady 建议的那样,我刚刚无条件创建了新的 &lt;PropertyGroup&gt;,并从其他地方删除了 &lt;DefineConstants&gt;

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>3.8</ProductVersion>
    <ProjectGuid>{63f50ecb-3c8f-448c-ad0d-43739e6ad5f1}</ProjectGuid>
    <SchemaVersion>2.0</SchemaVersion>
    <OutputName>Setup AddIn</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>
    <SourceLocation Condition="$(SourceLocation) == '' ">$(SolutionDir)SomeLocation\bin\$(Configuration)\</SourceLocationAddIn>
  </PropertyGroup>
  <PropertyGroup>
   <DefineConstants>$(DefineConstants);SourceLocationAddIn=$(SourceLocationAddIn);SourceLocationCA=$(SourceLocationCA)</DefineConstants>
  </PropertyGroup>
   ...

看起来$(DefineConstants); 成功了。没有这个,我的构建没有任何参数。 此外,我在 *.wxs 文件中的所有项目上添加了额外的斜杠,如下所示:

<File Id="MyFile" Name="MyFile.dll" Source="$(var.SourceLocation)\" Vital="yes"/>

看看$(var.SourceLocation)\(我尝试在 VS 构建步骤中更改此设置,但没有任何效果)。 现在,我在我的 PC 和构建服务器上的 CI 上有了开发工作的解决方案。

【问题讨论】:

    标签: visual-studio-2015 wix tfs-2015 azure-pipelines


    【解决方案1】:

    你可以在没有配置和平台条件的情况下添加它。

     <PropertyGroup>
        <DefineConstants>
          $(DefineConstants);SourceLocation=$(SourceLocation)
        </DefineConstants>
     </PropertyGroup>
    

    这样它总是适用于所有配置。

    【讨论】:

    • 是的,它不使用任何构建属性,TFS 在后台运行 msbuild,因此这是将属性从 msbuild 传递到 wix 的常用方式。
    • 我不太明白为什么它应该起作用。我必须将 buid 服务器上的参数传递给我的 wix 项目的问题。我的问题是,当我通过它时,msbuild 任务确实评估变量,但我的 wix proj 获取变量名称而不是评估值。
    • 你是对的。有用。我将接受这个答案并在我原来的问题中添加一些细节。感谢您指出这一点!
    • 谢谢!这是有用的解决方案
    猜你喜欢
    • 1970-01-01
    • 2016-01-31
    • 2018-03-06
    • 2016-03-06
    • 1970-01-01
    • 2017-08-06
    • 2018-05-01
    • 1970-01-01
    • 2016-12-28
    相关资源
    最近更新 更多