Reputation: 2759
I'm working on creating build definition on TFS 2015. We have *.sln
file and referenced *.wixproj
there. In Wix proj we are using variables as follows:
<File Id="MyFile" Name="MyFile.dll" Source="$(var.SourceLocation)" Vital="yes"/>
This variable $(var.SourceLocation)
is passed to candle.exe
:
C:\Program Files (x86)\WiX Toolset v3.10\bin\candle.exe -d"SourceLocation=D:\agent_work\2\SomeLocation\bin\Debug\"
It work locally because we have such code there:
<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>
When I try run this in TFS 2015 I pass SourceLocation via /p:
arguments:
If I look at msbuild arguments it evaluated:
But it failed.
2017-01-19T13:39:47.3202914Z 57>D:\agent_work\2\s\Setup\Installation\Installation\Sequences.wxs(11): error LGHT0103: The system cannot find the file '$(Build.BinariesDirectory)MyFile.dll'. [D:\agent_work\2\s\Setup\Installation\Installation\Installation.wixproj]
How to pass my own variables to wixproj in TFS 2015 (vNext) build?
Update:
Finally I fixed it. As suggested Arkady I just created new <PropertyGroup>
without conditions and removed <DefineConstants>
from other places:
<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>
...
It looks $(DefineConstants);
did the trick. Without this my build doesn't get any parameters.
In addition, I added extra slash at all items in *.wxs file as follows:
<File Id="MyFile" Name="MyFile.dll" Source="$(var.SourceLocation)\" Vital="yes"/>
Look at $(var.SourceLocation)\
.
(I tried changed this in VS build step but it didn't take any effect).
Now I have working solution for development at my PC and CI at build server.
Upvotes: 0
Views: 1296
Reputation: 1886
You can add this without the condition of configuration and platform.
<PropertyGroup>
<DefineConstants>
$(DefineConstants);SourceLocation=$(SourceLocation)
</DefineConstants>
</PropertyGroup>
This way it apply always to all configurations.
Upvotes: 3