novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Targeting uap in a multi-targeting library breaks in-IDE restore and build

AArnott opened this issue · comments

Given a class library with:

<Project Sdk="MSBuild.Sdk.Extras">

  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;uap10.0.17763</TargetFrameworks>
  </PropertyGroup>

</Project>

And a global.json with:

{
  "msbuild-sdks": {
    "MSBuild.Sdk.Extras": "2.1.2"
  }
}

The build at the command line is ok, although it produces a few warnings. But the IDE is totally shot. It claims fatal nuget restore errors:

1>------ Build started: Project: UWPTargetingTest, Configuration: Debug Any CPU ------
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
1>C:\Users\andarno\.nuget\packages\msbuild.sdk.extras\2.1.2\Sdk\Sdk.props(25,3): warning MSB4011: "C:\Program Files\dotnet\sdk\5.0.100-preview.8.20412.11\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\5.0.100-preview.8.20412.11\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.props (134,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj]
1>C:\Users\andarno\.nuget\packages\msbuild.sdk.extras\2.1.2\Sdk\Sdk.props(25,3): warning MSB4011: "C:\Program Files\dotnet\sdk\5.0.100-preview.8.20412.11\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\5.0.100-preview.8.20412.11\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.props (134,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj]
1>C:\Users\andarno\.nuget\packages\msbuild.sdk.extras\2.1.2\Sdk\Sdk.props(25,3): warning MSB4011: "C:\Program Files\dotnet\sdk\5.0.100-preview.8.20412.11\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\5.0.100-preview.8.20412.11\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.props (134,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj]
1>You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
1>C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj : error NU1202: Package System.Numerics.Vectors.WindowsRuntime 4.0.1 is not compatible with netcore50 (.NETCore,Version=v5.0). Package System.Numerics.Vectors.WindowsRuntime 4.0.1 supports: uap10.0 (UAP,Version=v10.0)
1>C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj : error NU1202: Package System.Numerics.Vectors.WindowsRuntime 4.0.1 is not compatible with netcore50 (.NETCore,Version=v5.0) / win10-arm. Package System.Numerics.Vectors.WindowsRuntime 4.0.1 supports: uap10.0 (UAP,Version=v10.0)
1>C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj : error NU1202: Package System.Numerics.Vectors.WindowsRuntime 4.0.1 is not compatible with netcore50 (.NETCore,Version=v5.0) / win10-arm-aot. Package System.Numerics.Vectors.WindowsRuntime 4.0.1 supports: uap10.0 (UAP,Version=v10.0)
1>C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj : error NU1202: Package System.Numerics.Vectors.WindowsRuntime 4.0.1 is not compatible with netcore50 (.NETCore,Version=v5.0) / win10-arm64-aot. Package System.Numerics.Vectors.WindowsRuntime 4.0.1 supports: uap10.0 (UAP,Version=v10.0)
1>C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj : error NU1202: Package System.Numerics.Vectors.WindowsRuntime 4.0.1 is not compatible with netcore50 (.NETCore,Version=v5.0) / win10-x64. Package System.Numerics.Vectors.WindowsRuntime 4.0.1 supports: uap10.0 (UAP,Version=v10.0)
1>C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj : error NU1202: Package System.Numerics.Vectors.WindowsRuntime 4.0.1 is not compatible with netcore50 (.NETCore,Version=v5.0) / win10-x64-aot. Package System.Numerics.Vectors.WindowsRuntime 4.0.1 supports: uap10.0 (UAP,Version=v10.0)
1>C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj : error NU1202: Package System.Numerics.Vectors.WindowsRuntime 4.0.1 is not compatible with netcore50 (.NETCore,Version=v5.0) / win10-x86. Package System.Numerics.Vectors.WindowsRuntime 4.0.1 supports: uap10.0 (UAP,Version=v10.0)
1>C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\UWPTargetingTest.csproj : error NU1202: Package System.Numerics.Vectors.WindowsRuntime 4.0.1 is not compatible with netcore50 (.NETCore,Version=v5.0) / win10-x86-aot. Package System.Numerics.Vectors.WindowsRuntime 4.0.1 supports: uap10.0 (UAP,Version=v10.0)
1>Done building project "UWPTargetingTest.csproj" -- FAILED.
1>C:\Program Files\dotnet\sdk\5.0.100-preview.8.20412.11\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1005: Assets file 'C:\Users\andarno\source\repos\UWPTargetingTest\UWPTargetingTest\obj\project.assets.json' doesn't have a target for 'UAP,Version=v10.0.17763'. Ensure that restore has run and that you have included 'uap10.0.17763' in the TargetFrameworks for your project.
1>Done building project "UWPTargetingTest.csproj" -- FAILED.
1>Done building project "UWPTargetingTest.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

If I add an SDK pin to the global.json:

{
  "msbuild-sdks": {
    "MSBuild.Sdk.Extras": "2.1.2"
  },
  "sdk": {
    "version": "3.1.302"
  }
}

Then the build warnings at the CLI go away, but VS is still just as broken.

Did this just start happening? This used to work and I wonder if something in the SDK or VS broke.

I don't know when it might have worked in the past. I only recently picked up this project after several years and wanted to modernize it with uap support.