I have a multi-targeting C# project built for net framework 4.7.2 and for net 7.0. TargetFrameworks element of the project is set to:
<TargetFrameworks>net472;net7.0-windows</TargetFrameworks>
Now I need to include both net framework and net 7 build outputs to my installer (different folders).
I try to follow steps described in this WiX discussion: https://github.com/wixtoolset/issues/issues/7241
Initially I do it the "old" way described there: to wixproj I insert 2 project references with different BindName explicitly specified:
<ProjectReference Include="..\MyProject\MyProject.csproj" SetTargetFramework="TargetFramework=net472" BindName="MyProject.net472"/>
<ProjectReference Include="..\MyProject\MyProject.csproj" SetTargetFramework="TargetFramework=net7.0-windows" BindName="MyProject.net7.0-windows"/>
And then in wxs file I include files in components:
...
<File Id="MyFile" Name="MyProject.dll" Source="!(bindpath.MyProject.net472)\MyProject.dll" />
...
<File Id="MyFile" Name="MyProject.dll" Source="!(bindpath.MyProject.net7.0-windows)\MyProject.dll" />
This seems to work. The files are found and packed. But it requires 2 ProjectReference entries in wixproj file. The way it described in WiX discussion it should be possible to add only one:
<ProjectReference Include="..\MyProject\MyProject.csproj" TargetFrameworks="net472,net7.0-windows"/>
which should automatically generate BindName.
However after I do it like this the file with MyProject.net472 bindpath is found, but the one with MyProject.net7.0-windows bindpath is not. I also tried it without -windows in the end, the same result. What's wrong?
The -
is not a valid identifier character somewhere in the build pipeline (MSBuild, I think, or maybe the preprocessor variables), so it must be changed to an _
when used in the .wxs code.
<File Id="MyFile Name="MyProject.dll"
Source="!(bindpath.MyProject.net7.0_windows)\MyProject.dll" />