I have two projects: ConsoleApp1 and Package1. Both are the "empty" project templates for a net7.0 and wix4 setup project respectively. ConsoleApp1 is modified to have <TargetFrameworks>net7.0</TargetFrameworks>
. Adding a project reference from Package1 and trying to access via preprocessor, binding, or otherwise the files from ConsoleApp1 is unsuccessful.
ConsoleApp1.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0</TargetFrameworks>
</PropertyGroup>
</Project>
Package1.wixproj
<Project Sdk="WixToolset.Sdk/4.0.0-rc.1">
<ItemGroup>
<ProjectReference Include="..\ConsoleApp1\ConsoleApp1.csproj"/>
</ItemGroup>
</Project>
ExampleComponents.wxs
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="ExampleComponents" Directory="INSTALLFOLDER">
<Component>
<File Source="ExampleComponents.wxs" />
<File Source="$(var.ConsoleApp1.TargetPath)" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Things that don't work:
TargetFramework
or TargetFrameworks
in the wixprojAdditionalProperties="TargetFramework=net7.0"
in the wixproj ProjectReference
If I use <TargetFramework>
instead of <TargetFrameworks>
in the console project, the error resolves - but I need to multi-target. How can I depend with a ProjectReference
on a multi-targeted project with wix4?
Use SetTargetFramework
to avoid multi-targeting in the project reference. I'm not sure why AdditionalProperties
fails but SetTargetFramework
succeeds.
Updated Package1.wixproj:
<Project Sdk="WixToolset.Sdk/4.0.0-rc.1">
<ItemGroup>
<ProjectReference Include="..\ConsoleApp1\ConsoleApp1.csproj">
<SetTargetFramework>TargetFramework=net7.0</SetTargetFramework>
</ProjectReference>
</ItemGroup>
</Project>