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.

dotnet build doesn't work when filtered to a supported framework for current SDK

See original GitHub issue

I am wanting to build a project with the .NET Core 2.2 SDK. The project targets .NET Core 3.0 and 2.2. It should work, but instead, it makes me sad.

C:\git\testapps\cpumath>type cpumath.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>netcoreapp3.0;net472;netcoreapp2.2</TargetFrameworks>
    <RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.ML.CpuMath" Version="0.11.0" />
  </ItemGroup>

</Project>
C:\git\testapps\cpumath>dotnet build -f netcoreapp2.2
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\2.2.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0. [C:\git\testapps\cpumath\cpumath.csproj]

C:\git\testapps\cpumath>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.105
 Commit:    7cecb35b92

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.105\

Host (useful for support):
  Version: 3.0.0-preview4-27529-09
  Commit:  0a688d1b7e

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dsplaistedcommented, Apr 2, 2019

Basically, NuGet restores for all target frameworks even if you specify a given framework to build / publish for. This avoids having to re-restore each time and thrashing the assets file each time you specify a different target framework. So that would be the trade-off if we wanted to enable this scenario.

Note that I think you could do something like what you want by specifying /p:TargetFrameworks=netcoreapp2.2 instead of -f netcoreapp2.2.

0reactions
dsplaistedcommented, Dec 9, 2019

We recommend using the latest SDK even for projects targeting earlier runtimes. Probably the instructions for building the TS3AudioBot project weren’t updated when it added .NET Core 3.0 support.

We recommend using the latest SDK because that’s where all of our fixes and improvements go. For example, even if we were to do as you suggest and skip restoring frameworks that aren’t supported, that change would go in a future SDK (ie the .NET 5 SDK or later), and wouldn’t help in the case where the 2.2 SDK was trying to restore assets for .NET Core 3.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NETSDK1045: The current .NET SDK does not support ...
Open the Solution Properties window (ctrl-click the solution in the Solution window and select Properties), select Build - General, and uncheck ...
Read more >
dotnet build command - .NET CLI
The dotnet build command builds a project and all of its dependencies.
Read more >
SDK Resolver Failure - Net 7 - Net 6
Just downloaded and installed SDK Net 7.0.100 and it broke existing applications and they won't load any more in VS 2022 or Rider....
Read more >
Remove the .NET runtime and SDK
This article describes how to uninstall .NET. You'll need to determine which versions of the .NET Runtime and SDK are currently installed, ...
Read more >
dotnet restore command - .NET CLI
Learn how to restore dependencies and project-specific tools with the dotnet restore command.
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