I am in the process of building a WiX Toolset 5 installer for a .NET 8 Web API project. I am familiar with older versions of WiX.
The problem I have is that when I do a dotnet publish
this creates additional required files (most notably the web.config) that are NOT created with a dotnet build
In my WiX project how can I reference the publish directory of a the Web API project? Previously I would always TargetDir variable, but this is the build output and therefore I get a missing file error.
<Component>
<File Source="$(var.MyWebApiProject.TargetDir)web.config" />
</Component>
I want to avoid hard-coding any directories as this will need to run in a DevOps Pipeline also. Ideally I also want to avoid any manual copying too.
Add Publish='true'
to the ProjectReference
item in your .wixproj and the WiX build will publish and reference the target project. Note this publishes to a known location (in the .msi project) so pre-processor variables can be set.
You can then simply remove the variable from the file source.
<Component>
<File Source="web.config" />
</Component>