wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
129 stars 36 forks source link

Nuget restore fails when referencing winforms or wpf projects #7034

Closed zdavidsen closed 1 year ago

zdavidsen commented 1 year ago

Bugs

If this issue is a bug:

4.0.0-preview.1

17.3.4

N/A? (heatwave 4.0.0-preview.1)

6.0.401

N/A

Create a new dotnet 6 application (winforms or wpf). Create a wixproj with a reference to the application project. Run dotnet restore on the wixproj. Error: "Project wpf is not compatible with native"

I expected the restore operation to work as well as it does for other project types.

robmen commented 1 year ago

@zdavidsen Can you please provide the full error message? You cut off an important part of the message. The full error message should look something like this:

your.wixproj : error NU1201: Project WpfProject is not compatible with native (native,Version=v0.0) / win-x86. Project WpProject supports: net5.0-windows7.0 (.NETCoreApp,Version=v5.0)
tstaec commented 1 year ago

I have the same issue. Here the full text in case OP doesn't provide his. C:\Repos\tems-platform\Tems\Setups\Ectn.Tems.TemsRecorderEmulatorInstaller\Ectn.Tems.TemsRecorderEmulatorInstaller.wixp roj : error NU1201: Project Ectn.Tems.TemsRecorderEmulator is not compatible with native (native,Version=v0.0). Project Ectn.Tems.TemsRecorderEmulator supports: net5.0-windows7.0 (.NETCoreApp,Version=v5.0)

Command: dotnet build .\Ectn.Tems.TemsRecorderEmulatorInstaller.wixproj -c Debug If build in VS, restore fails but build continues. msi file is being generated.

zdavidsen commented 1 year ago

Pretty much same error that tstaec posted:

W:\WixModuleInstallTemplate\Code\Package\content\Code\Install\Install.wixproj : error NU1201: Project TemplateModuleInstantiator is not compatible with native (native,Version=v0.0). Project TemplateModuleInstantiator supports: net6.0-windows7.0 (.NETCoreApp,Version=v6.0)
  Failed to restore W:\WixModuleInstallTemplate\Code\Package\content\Code\Install\Install.wixproj (in 1.17 sec).
  1 of 2 projects are up-to-date for restore.

It's really easy to setup a failing case, you don't even need anything in the wpf or wix projs. (please excuse the powershell escape syntax)

mkdir wpf
mkdir install
cd wpf
dotnet new wpf
cd ../install
echo "<Project Sdk=`"WixToolset.Sdk/4.0.0-preview.1`">`n`t<ItemGroup><ProjectReference Include=`"../wpf/wpf.csproj`"/></ItemGroup>`n</Project>" > install.wixproj
dotnet restore

Incidentally, while writing that script I found out that dotnet add complains about incompatible frameworks as well, presumably it's the same root cause?

robmen commented 1 year ago

@tstaec try adding the following snippet to your .wixproj:

<PropertyGroup>
  <AssetTargetFallback>$(AssetTargetFallback);net5.0-windows7.0</AssetTargetFallback>
</PropertyGroup>

@zdavidsen try adding the following snippet to your .wixproj:

<PropertyGroup>
  <AssetTargetFallback>$(AssetTargetFallback);net6.0-windows7.0</AssetTargetFallback>
</PropertyGroup>

Let me know if that work around works.

zdavidsen commented 1 year ago

So that lets the restore complete, but it still says "1 of 2 projects are up-to-date for restore." I don't know if that's actually an issue yet, just wanted to chime back in quickly