Menu

#1201 Variable Names Require Unique Project Names in Solution

v3.0
closed
msbuild (104)
2014-04-17
2008-05-15
ross613
No

In a large Visual Studio solution, there are these two projects called "Common.csproj", each referring to logic in different namespaces, each in different physical folders. When setting the File tag's Source attribute to a WiX variable, we run into a problem. The syntax for the variable for both projects is as follows:

 $(var.Common.TargetDir)

In order to solve this problem, we looked at the .wixproj file's schema, wherein we have a series of ProjectReference tags. Beneath the ProjectReference node, there's a Name tag – presumed to contain the string referred to by the WiX toolset to identify the project name within the WiX variable syntax. Consequently, we changed our .wixproj as follows (note the <name> tag content):</name>

58 <projectreference include="..\..\..\src\Service\Common\Common.csproj">
59 <name>ServiceCommon</name>
60 <project>{7b6ebb1f-3b75-4497-85fb-e524fc9486fc}</project>
61 <private>True</private>
62 </projectreference>
63 <projectreference include="..\..\..\src\Shared\Common\Common.csproj">
64 <name>SharedCommon</name>
65 <project>{13736794-cc44-4834-86a6-9733ba4c2089}</project>
66 <private>True</private>
67 </projectreference>

Ordinarily, the <name> tags would have contained strings like "Common (Shared\Common)" and "Common (Service\Common)"; and these strings would have appeared within the References node of the WiX project. Instead "SharedCommon" and "ServiceCommon" now appear in the References folder, as they do in the listing above.</name>

However, when building the WiX project from within Visual Studio, we're still seeing the same original error we had when we'd first started building using diplicate $(var.Common.TargetDir) strings in our .wxs file:

candle.exe(0,0): error CNDL0001: Item has already been added. Key in dictionary: 'Common.Configuration' Key being added: 'Common.Configuration'
Done building project "Sonora.wixproj" -- FAILED.

The –d arugments used when candle.exe is run by the build still use the "Common" string, suggesting that WiX is actually not looking at the .wixproj file's ProjectReference\Name nodes for the strings used as WiX variable names – it's simply using the project file name, looks like.

The proposal is that the behaviour should be that WiX variables should use the .wixproj ProjectReferences\Name node strings in order to indicate a reference to a project. Thus....

 $(var.MyProject.TargetDir)

...would refer to the $(TargetDir) of the project called "MyProjct" and output the pertinent string in place of the variable.

Discussion

  • Jason Ginchereau

    Logged In: YES
    user_id=2086430
    Originator: NO

    Fixed in build 3.0.4206.

    Generated variables for project references now use the reference name instead of the project name. VS will try to ensure unique reference names, however it does that by appending the solution folder path in parentheses, which can't work inside variable names. So the variable names have the parentheses replaced by underscores... it's a bit ugly but users should rarely encounter it. (You can also edit the project file manually to change a reference name, and VS will keep it intact.)

     
  • ross613

    ross613 - 2008-06-08

    Logged In: YES
    user_id=1659426
    Originator: YES

    Nicely done! Keep up the great work, guys!

     
MongoDB Logo MongoDB