msbuildwixwix4

Trying to use ProjectReference to publish app as self-contained for use in WiX v4 project


I'm trying to create installed with WiX v4 that would publish another C# project, harvest its files, and then package those into the installer. I was able to get that to work, but the issue is that the project is getting published as framework-dependant when I need it to be self-contained.

I'm currently using the following in my wixproj file to handle this:

  <ItemGroup>
    <ProjectReference Include="$(SolutionDir)\App.csproj" Publish="true" />
  </ItemGroup>
  <ItemGroup>
    <HarvestDirectory Include="$(PublishFolder)">
      <ComponentGroupName>HarvestedComponents</ComponentGroupName>
      <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
      <SuppressRootDirectory>true</SuppressRootDirectory>
      <SuppressRegistry>true</SuppressRegistry>
    </HarvestDirectory>
    <BindPath Include="$(PublishFolder)" />
  </ItemGroup>

As mentioned, this works, but performs the publish as framework-dependent when I need self-contained.

I found docs on doing this for MSBuild, but it doesn't seem to work for Wix; I've tried doing both the PropertyGroup approach described there as well as putting a PublishSelfContained="true" attribute onto the ProjectReference element, and I've tried both with just SelfContained as well. None of those seem to have any effect on the published files.

I can't seem to find any documentation from Wix on doing this either, though I also couldn't find any on using the Publish attribute and that one only came from another StackOverflow post, so I'm not sure if it's not possible through this approach or just not well-documented.


Solution

  • Put the self-contained publish information (the MSBuild Properties, you want) in your .csproj, not the . wixproj.

    Specifically for publishing self contained, set <SelfContained>true</SelfContained> in the referenced projects .csproj file. Setting PublishSelfContained will have no effect.