Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get WIX to include references within a project

Tags:

c#

winforms

wix

I'm completely new to WiX and setting up custom installers in general, so I apologise for the topic of the question!

I have a internal business application (a diary), which builds and works well, so I followed tutorials/official documentation as to adding the WiX project and referencing the Diary's csproj to it.

After then building and running this most basic version of a WiX installer, the output directory has a lone exe file, which crashes moments after loading with a File Not Found Exception.

My guess is that it has not built in either Crystal Report or NLog, both of which are referenced in my CSProj.

My question is this, how do I get WIX to include and build those project references to the output???

Any help is greatly appreciated! /Antony

like image 916
AJ McK Avatar asked Oct 30 '13 17:10

AJ McK


2 Answers

Unfortunately you will have to do some manual labor in order to get your projects right. I would take either of the two following approaches which require you to edit the .wixproj file:

  1. Use HeatProject task. You will have to do this for all referenced projects and it will give you separate .wxs files for all of them. After this reference the component groups in those files in a feature of your WIX based setup.

    <Target Name="BeforeBuild">
      <HeatProject ToolPath="$(WixToolPath)" AutogenerateGuids="true" OutputFile="OutputFile.wxs" SuppressFragments="true" Project="ReferencedProject.csproj" ProjectOutputGroups="Binaries" />
    </Target>
    
  2. Use HeatDirectory task. Following will pick up everything in the bin folder of your project, including any binaries for the referenced projects, and give you a single .wxs containing UniqueComponentGroupName which can be included in any feature.

    <Target Name="BeforeBuild">
      <PropertyGroup>
        <DefineConstants>BINFOLDER=PATH\TO\YourProject\bin\$(Configuration)</DefineConstants>
      </PropertyGroup>
      <HeatDirectory OutputFile="OutputFile.wxs" Directory="PATH\TO\YourProject\bin\$(Configuration)" KeepEmptyDirectories="true" DirectoryRefId="INSTALLFOLDER" ComponentGroupName="UniqueComponentGroupName" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.BINFOLDER" />
    </Target>
    
like image 121
Syed Ali Avatar answered Sep 19 '22 00:09

Syed Ali


Unlike the (now defunct) Setup Project project in older versions of Visual Studio, WiX does not do automatic reference detection. You'll have to add each referenced project to the WiX project manually, just as you did for the main project.

like image 31
Adam Robinson Avatar answered Sep 22 '22 00:09

Adam Robinson