Visual studio 2015 TFS 2015在构建时将变量传递给Wix

Visual studio 2015 TFS 2015在构建时将变量传递给Wix,visual-studio-2015,wix,tfs-2015,azure-pipelines,Visual Studio 2015,Wix,Tfs 2015,Azure Pipelines,我正在TFS 2015上创建构建定义。我们有*.sln文件,在那里引用了*.wixproj。在Wix项目中,我们使用的变量如下: 此变量$(var.SourceLocation)被传递到candle.exe: C:\ProgramFiles(x86)\WiX工具集v3.10\bin\candle.exe-d“SourceLocation=d:\agent\u work\2\SomeLocation\bin\Debug\” 它在本地工作,因为我们有这样的代码: <Project

我正在TFS 2015上创建构建定义。我们有
*.sln
文件,在那里引用了
*.wixproj
。在Wix项目中,我们使用的变量如下:

此变量
$(var.SourceLocation)
被传递到
candle.exe

C:\ProgramFiles(x86)\WiX工具集v3.10\bin\candle.exe-d“SourceLocation=d:\agent\u 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>
它看起来
$(DefineConstants)成功了。没有这个,我的构建就不会得到任何参数。
此外,我在*.wxs文件中的所有项上添加了额外的斜杠,如下所示:

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

查看
$(var.SourceLocation)\
。 (我尝试在VS构建步骤中更改此选项,但没有任何效果)。
现在,我在PC上有了开发工作解决方案,在build server上有了CI。

您可以添加此解决方案,而无需配置和平台条件

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

美元(定义常量);SourceLocation=$(SourceLocation)

这样,它始终适用于所有配置。

您可以添加此选项,而无需配置和平台条件

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

美元(定义常量);SourceLocation=$(SourceLocation)

这样,它将始终应用于所有配置。

是的,它不使用任何生成属性,TFS在后台运行msbuild,因此这是将属性从msbuild传递到wix的常用方法。我不太明白为什么它会起作用。我的问题是,我必须将buid服务器上的参数传递给我的wix项目。我的问题是,当我传递它时,msbuild任务对变量求值,但我的wix proj得到的是变量名而不是求值值。您是对的。它起作用了。我将接受这个答案,并在我原来的问题中添加一些细节。谢谢你指出这一点!非常感谢。这是一个有用的解决方案是的,它不使用任何生成属性,TFS在后台运行msbuild,因此这是将属性从msbuild传递到wix的常用方法。我不太明白为什么它应该工作。我的问题是,我必须将buid服务器上的参数传递给我的wix项目。我的问题是,当我传递它时,msbuild任务对变量求值,但我的wix proj得到的是变量名而不是求值值。您是对的。它起作用了。我将接受这个答案,并在我原来的问题中添加一些细节。谢谢你指出这一点!非常感谢。这是一个有用的解决方案