Skip to content

Cannot multi-target to netcoreapp < 3.0 and use WindowsDesktop SDK unconditionally #327

Closed
@nguerrera

Description

@nguerrera
  • .NET Core Version: 3.0 Preview 2
  • Windows version: (winver): N/A, build time error
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: N/A

Problem description:

If a project targets netcoreapp1.x or netcoreapp2.x in addition to netcoreapp3.0, and uses WindowsDesktop SDK in order to use WPF conditionally on 3.0, it fails to build. (Importing SDKs conditionally is possible, but difficult to get right and hard to maintain.)

The implicit framework reference is conditioned only on TargetFrameworkIdentifier being .NETCoreApp. It ignores TargetFrameworkVersion.

Minimal repro:
dotnet build this:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
   <TargetFrameworks>netcoreapp1.0;netcoreapp3.0</TargetFrameworks>
   <UseWPF Condition="'$(TargetFramework)' == 'netcoreapp3.0'">true</UseWPF>
  </PropertyGroup>
</Project>

Actual behavior:

error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop.App' was not recognized

Expected behavior:

Successful build

cc @AArnott @dsplaisted @vatsan-madhavan

Metadata

Metadata

Labels

BugProduct bug (most likely)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions