question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot build a supported target when an unsupported target exists in `<TargetFrameworks>`

See original GitHub issue

Steps to reproduce

  1. On Windows, install .NET Core 2.0 SDK and .NET Framework 4.7 SDK
  2. dotnet new console -o test
  3. cd test
  4. In test.csproj, replace <TargetFramework>... with <TargetFrameworks>net47;netcoreapp3.0</TargetFrameworks>
  5. 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:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
firelizzard18commented, Jan 23, 2019

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.

0reactions
dsplaistedcommented, Apr 22, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found