How to include a configuration-dependent project output in WiX 3.6
Asked Answered
O

3

7

I'm wondering, how to include a configuration-dependent project output in WiX Setup Project? For example, let's look at Visual Studio solution with one .NET application and one Wix Setup Project.

I've added a reference to .NET app in Setup project and created component in setup source:

  <Component Guid="EB0CBC32-5AE5-41B3-A343-FEBE044AC30A">
    <File Source="$(var.MyApp.TargetPath)" KeyPath="yes"/>
  </Component>

So, I expect, that WiX will include a release version of MyApp in its release setup msi, and debug version in debug msi respectively. Otherwise, reference to the project output makes no sense for me.

But there's always debug version. What am I doing wrong?

UPDATE.

Here's candle's command prompt from VS output window:

------ Rebuild All started: Project: MySetup, Configuration: Release x86 ------
C:\Program Files\WiX Toolset v3.6\bin\candle.exe -d"DevEnvDir=C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\" -dSolutionDir=D:\Projects\Research\Wix_ProjectOutput\ -dSolutionExt=.sln -dSolutionFileName=Wix_ProjectOutput.sln -dSolutionName=Wix_ProjectOutput -dSolutionPath=D:\Projects\Research\Wix_ProjectOutput\Wix_ProjectOutput.sln -dConfiguration=Release -dOutDir=..\Release\ -dPlatform=x86 -dProjectDir=D:\Projects\Research\Wix_ProjectOutput\MySetup\ -dProjectExt=.wixproj -dProjectFileName=MySetup.wixproj -dProjectName=MySetup -dProjectPath=D:\Projects\Research\Wix_ProjectOutput\MySetup\MySetup.wixproj -dTargetDir=D:\Projects\Research\Wix_ProjectOutput\Release\ -dTargetExt=.msi -dTargetFileName=MySetup.msi -dTargetName=MySetup -dTargetPath=D:\Projects\Research\Wix_ProjectOutput\Release\MySetup.msi -dMyApplication.Configuration=Debug -d"MyApplication.FullConfiguration=Debug|x86" -dMyApplication.Platform=x86 -dMyApplication.ProjectDir=D:\Projects\Research\Wix_ProjectOutput\MyApplication\ -dMyApplication.ProjectExt=.csproj -dMyApplication.ProjectFileName=MyApplication.csproj -dMyApplication.ProjectName=MyApplication -dMyApplication.ProjectPath=D:\Projects\Research\Wix_ProjectOutput\MyApplication\MyApplication.csproj -dMyApplication.TargetDir=D:\Projects\Research\Wix_ProjectOutput\Debug\ -dMyApplication.TargetExt=.exe -dMyApplication.TargetFileName=MyApplication.exe -dMyApplication.TargetName=MyApplication -dMyApplication.TargetPath=D:\Projects\Research\Wix_ProjectOutput\Debug\MyApplication.exe -out obj\Release\ -arch x86 Product.wxs

Why for the release build of MySetup was used debug configuration of MyApplication??

UPDATE 2.

And here's candle's command prompt, when using msbuild from command line:

%windir%\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe /verbosity:d /t:rebuild /fileLogger /p:Configuration=Release  Wix_ProjectOutput.sln 

In msbuild.log:

C:\Program Files\WiX Toolset v3.6\bin\candle.exe -d"DevEnvDir=Undefined if not building from within Visual Studio" -dSolutionDir=D:\Projects\Research\Wix_ProjectOutput\ -dSolutionExt=.sln -dSolutionFileName=Wix_ProjectOutput.sln -dSolutionName=Wix_ProjectOutput -dSolutionPath=D:\Projects\Research\Wix_ProjectOutput\Wix_ProjectOutput.sln -dConfiguration=Release -dOutDir=..\Release\ -dPlatform=x86 -dProjectDir=D:\Projects\Research\Wix_ProjectOutput\MySetup\ -dProjectExt=.wixproj -dProjectFileName=MySetup.wixproj -dProjectName=MySetup -dProjectPath=D:\Projects\Research\Wix_ProjectOutput\MySetup\MySetup.wixproj -dTargetDir=D:\Projects\Research\Wix_ProjectOutput\Release\ -dTargetExt=.msi -dTargetFileName=MySetup.msi -dTargetName=MySetup -dTargetPath=D:\Projects\Research\Wix_ProjectOutput\Release\MySetup.msi -dMyApplication.Configuration=Release -d"MyApplication.FullConfiguration=Release|x86" -dMyApplication.Platform=x86 -dMyApplication.ProjectDir=D:\Projects\Research\Wix_ProjectOutput\MyApplication\ -dMyApplication.ProjectExt=.csproj -dMyApplication.ProjectFileName=MyApplication.csproj -dMyApplication.ProjectName=MyApplication -dMyApplication.ProjectPath=D:\Projects\Research\Wix_ProjectOutput\MyApplication\MyApplication.csproj -dMyApplication.TargetDir=D:\Projects\Research\Wix_ProjectOutput\Release\ -dMyApplication.TargetExt=.exe -dMyApplication.TargetFileName=MyApplication.exe -dMyApplication.TargetName=MyApplication -dMyApplication.TargetPath=D:\Projects\Research\Wix_ProjectOutput\Release\MyApplication.exe -out obj\Release\ -arch x86 Product.wxs

So, under msbuild all is OK.

UPDATE 3.

Looks like WiX uses active build configuration (see combobox at VS toolbar).
I mean, if Debug is selected there, WiX projects will include debug output of referenced projects. If Release is selected, WiX projects will include release output.

This behavior isn't correct from my point of view. Debug installer must include debug output of referenced projects. Release installer - release output.

Posted bug here, but now it is closed without any explanation.

Any ideas?

Oof answered 16/8, 2012 at 8:38 Comment(0)
M
10

You may use $(var.Configuration), which is set to solution configuration (Debug, Release, etc...):

<File Id="MyApp.exe" KeyPath="yes" Source="..\MyApp\$(var.Configuration)\MyApp.exe" />
Monday answered 14/4, 2013 at 9:12 Comment(2)
The method might be right, but the details seem wrong: 1.) Built binaries are placed in (projectdir)\bin(configuration). The above example missed the bin directory. 2.) By default, only Debug and Release builds are built under bin, others are built under bin\x86(configuration). The example can't cater for this possible difference in directory depth. I'm using $(var.(projectname).TargetDir)Meingoldas
You are probably right about the project path, and after closer inspection I can tell my answer was wrong anyway, or at most could only be used as a temporary workaround. Looks like TC problem was indeed a lack of knowledge about Configuration Manager, like mheyman noted below.Monday
I
0

Try adding a variable of MyApplication.Configuration and set it to Release by following steps:

  1. Right-click on the References node of the project in the Solution Explorer and choose Add Reference...
  2. In the Add WiX Library Reference dialog, click on the Projects tab.
  3. Select the desired project(s) and click the Add button, then click OK to dismiss the dialog.

Details here.

Inheritable answered 24/8, 2012 at 9:31 Comment(1)
This variable is already defined, and its value is Debug. I've posted a bug at WiX tracker, but now it is closed without any explanation. Updated my question.Oof
U
0

Since I do exactly what you are attempting regularly with success, I suspect you are confusing the solution configuration with the project configuration. A solution configuration of foo can use a project configuration of bar - they are just names and they do not have to match. Check the configuration manager (BUILD → Configuration Manager... in VS2012) and verify that when your solution configuration is "Release" that your project configuration is also "Release".

Ukulele answered 11/4, 2013 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.