Cannot build a supported target when an unsupported target exists in `<TargetFrameworks>`
See original GitHub issueSteps to reproduce
- On Windows, install .NET Core 2.0 SDK and .NET Framework 4.7 SDK
dotnet new console -o test
cd test
- In
test.csproj
, replace<TargetFramework>...
with<TargetFrameworks>net47;netcoreapp3.0</TargetFrameworks>
dotnet build -f net47
Expected behavior
The CLI builds and runs the project using the specified target framework. The fact that there are other valid target frameworks is ignored.
Actual behavior
Microsoft (R) Build Engine version 15.6.84.34536 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files\dotnet\sdk\2.1.104\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(135,5): error : The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 3.0. [C:\Source\temp\build-test\build-test.csproj]
The build failed. Please fix the build errors and run again.
Environment data
dotnet --info
output:
.NET Command Line Tools (2.1.104)
Product Information: Version: 2.1.104 Commit SHA-1 hash: 48ec687460
Runtime Environment: OS Name: Windows OS Version: 10.0.14393 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.104\
Microsoft .NET Core Shared Framework Host
Version : 2.0.6 Build : 74b1c703813c8910df5b96f304b0f2b78cdf194d
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
(C#) Error with building multiple target frameworks
I am following this guide to automatically generate an API client with NSwag. But this client needs to support multiple target frameworks:
Read more >NETSDK1045: The current .NET SDK does not support ...
This error occurs when the build tools can't find the version of the .NET SDK that's needed to build a project. This is...
Read more >Target frameworks in SDK-style projects - .NET
A target framework is typically referenced by a TFM. The following table shows the target frameworks supported by the .NET SDK and the...
Read more >Building a project that target .NET Framework 4.5 in Visual ...
I maintain a few libraries that still target .NET Framework 4.5 (among others). .NET 4.5 has long been out of support, but I...
Read more >Multi-targetting .Net Framework and .Net Core in a single project
(Optional) Support building the netframework target on mono for linux or macos. In my case working on a Mac, my next error is....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I shouldn’t need SDK 3.0.100 if I’m not building the netcoreapp3.0 target. I consider it a bug that passing a single framework evaluates the plural verison. If I pass a single framework to the build tool, it should evaluate that single framework.
The reason this happens is we still run restore for all the target frameworks, even if you are only building for one. I don’t think we should change this, as that’s what lets NoOp restore work. This will also probably be less of an issue for the .NET 5 SDK, as it will automatically bring in the .NET Framework targeting pack packages as necessary, so on non-Windows machines you won’t run into this for projects targeted between .NET Framework and .NET Core.