views:

88

answers:

1

I'm using Vs2010 and Wix 3.6.0917.0, for the record. I use the $(SolutionDir) property quite a bit in my .wixproj file, since I only ever build the installer as part of a solution build or as part of a team build, and never by itself. However, while building from the command line works just fine (both from cmd on the desktop and when building on build agents), when I attempt to reload the .wixproj file into the IDE, I get errors because all the $(SolutionDir) variables are resolving to the project directory, not the solution directory. Consider:

C:\workspace\projectCollection\teamProject\branch\solution.sln C:\workspace\projectCollection\teamProject\branch\source\installer\installer.wixproj

and assume a shared custom targets file:

C:\workspace\projectCollection\teamProject\branch\build\shared.targets

which is referenced inside installer.wixproj with:

<Import Project="$(SolutionDir)build\shared.targets">

Command line builds work fine...

C:\workspace\projectCollection\teamProject\branch\> MSBuild /t:build /property:Platform=x64;Configuration=Debug solution.sln
0 Errors
0 Warnings

Build succeeded!

But load into vs2010 and you see...

The imported project "C:\workspace\projectCollection\teamProject\branch\source\installer\build\shared.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\workspace\projectCollection\teamProject\branch\source\installer\installer.wixproj

You can see here that the resolved result of $(SolutionDir)build\shared.targets is getting the project directory and not the solution directory. What gives?

A: 

My guess would be that $(SolutionDir) resolves to nothing when the wixproj is being loaded into VS2010. In this case the imported file becomes "build\shared.targets". Since the path is relative it is assumed to be relative to the project directory. Using ".." or some other path could get you around the problem.

I verified this failed with WiX 3.5.2222.0 in VS2010. A C# console application project (csproj) worked as expected.

Have you filed a bug against WiX for this?

I looked at the WiX vs2010 addin code a little bit and the Solution properties are only created when doing a build and not when the project is loaded.

daddyman
Oh awesome! What code is that? I wouldn't be above going in there and trying to hack my way through to get it to execute on load, as well; I just had no idea where to look/how to start.
bwerks
In the WiX source: Votive\votive2010\WixProjectNode.cs is the file to track a WiX project. It seems to me by looking at the source that somewhere during the setup of WixProjectNode (like in SetBuildProject, overridden from the base class) the Solution properties need to be configured (like they are in WixBuildMacroCollection.cs)
daddyman