0

I have a Windows service built in .NET 6 and want it installed with WiX. My project file looks like this:

<Project Sdk="WixToolset.Sdk/4.0.0">
  <PropertyGroup>
    <OutputName>Jenkins Log Collector Installer</OutputName>
    <EnableProjectHarvesting>false</EnableProjectHarvesting>
    <HarvestFileSuppressUniqueIds>false</HarvestFileSuppressUniqueIds>
    <HarvestFileGenerateGuidsNow>true</HarvestFileGenerateGuidsNow>
  </PropertyGroup>
  <ItemGroup>
    <Content Include="Variables.wxi" />
  </ItemGroup>
  <ItemGroup>
    <HarvestDirectory Include="JenkinsLogCollector">
      <ComponentGroupName>LogCollectorFiles</ComponentGroupName>
      <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
      <SuppressRootDirectory>true</SuppressRootDirectory>
    </HarvestDirectory>
    <BindPath Include="JenkinsLogCollector" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="WixToolset.Heat" Version="4.0.0" />
    <PackageReference Include="WixToolset.Netfx.wixext" Version="4.0.1" />
    <PackageReference Include="WixToolset.UI.wixext" Version="4.0.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\JenkinsLogCollector\JenkinsLogCollector.csproj" />
  </ItemGroup>
</Project>

And my Package.wxs looks like this:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui" xmlns:netfx="http://wixtoolset.org/schemas/v4/wxs/netfx">
  <?include Variables.wxi ?>
  <Package Name="$(var.ProductName)" Manufacturer="$(var.Manufacturer)" Version="1.0.0.0" UpgradeCode="5d382d34-9f2f-42ed-a243-97bc91346970">
    <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />

    <netfx:DotNetCompatibilityCheck
      Property="DOTNETRUNTIMECHECK"
      Platform="x64"
      RollForward="major"
      RuntimeType="desktop"
      Version="6.0.0.0"
    />
    <Feature Id="Main">
      <ComponentGroupRef Id="LogCollectorFiles" />
    </Feature>
    <ui:WixUI
      Id="WixUI_InstallDir"
      InstallDirectory="INSTALLFOLDER"
      />
  </Package>
</Wix>

My issues are, well, many.

  1. If I opt for project harvesting, I get the results of the build, not publishing. That means my main executable is a DLL and there's a whole lotta stuff added that I don't care about.
  2. I can't find any information as to how to correctly define the path in <HarvestDirectory>. Using things like $(JenkinsLogCollector.TargetPath), inspired by this page from the official documentation, causes Visual Studio to fail to load the project file.
  3. In spite of the above, I would at least expect an error or an empty component group, but the <HarvestDirectory> tag does not even produce this much. As a result, the build complains that

The identifier 'WixComponentGroup:LogCollectorFiles' could not be found.

What do I do? For a project that was so many years in development, it's silly that there's no usable documentation for building an installer, and I like to think that I'm not doing anything particularly odd here either.

Haxton Fale
  • 564
  • 1
  • 4
  • 13

1 Answers1

0

It looks like you're telling HarvestDirectory to look for the files in the Setup project and not the JenkinsLogCollector project. Try changing

<HarvestDirectory Include="JenkinsLogCollector">
      <ComponentGroupName>LogCollectorFiles</ComponentGroupName>
      <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
      <SuppressRootDirectory>true</SuppressRootDirectory>
    </HarvestDirectory>
    <BindPath Include="JenkinsLogCollector" />

to

<HarvestDirectory Include="..\JenkinsLogCollector\bin\Release\net6.0\publish">
      <ComponentGroupName>LogCollectorFiles</ComponentGroupName>
      <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
      <SuppressRootDirectory>true</SuppressRootDirectory>
    </HarvestDirectory>
    <BindPath Include="..\JenkinsLogCollector\bin\Release\net6.0\publish" />

in the project file.