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.

3.1.401 SDK fails to resolve correct available runtimes with 2.2.x

See original GitHub issue

Describe the bug

I have a have a single target project with the following config:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <IsPackable>false</IsPackable>
  </PropertyGroup>
</Project>

The build machine has dotnet core SDK. 2.2.402 and 3.1.401 installed. When I attempt to build this project, the following error is emitted and the build fails:

##[error]C:\hostedtoolcache\windows\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): Error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.

If I instead install SDKs 2.2.402 and 3.1.302 this error does not occur and the build succeeds.

To Reproduce

  1. Install SDKs 2.2.402 and 3.1.401
  2. Run msbuild.exe" "D:\a\1\s\MySolution.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.166.2\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=|SolutionDir=D:\a\1\s"*ForwardingLogger,"D:\a\_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.166.2\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:PublishProfile=WebDeployPackage /p:configuration="Release" /p:_MSDeployUserAgent="VSTS_4522ee20-b1c7-418b-b3de-2bf24bb4eccd_build_43_0"
  3. Error (see above)

Expected Result

The build should succeed.

Additional information

This was discovered on Azure DevOps. Nothing changes between the two builds other changing the Use .NET Core task to target 3.1.302 instead of 3.1.x.

Was there a breaking change in the last patch build or is this a bug?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
wli3commented, Sep 13, 2020

Sorry, we are closing to net5.0 release. Please expect a very long delay.

0reactions
wli3commented, Oct 6, 2020

Are you saying that we can compile 2.2 dotnetcore web apps using only the 3.1 sdk?

Yes.

If so, does that mean the test step in our pipeline would then be the one to fail because it does need to run with the 2.2 runtime.

If you test, yes, it will fail to run. However I tried the following pipeline. If you install runtime and the SDK both in the same location. SDK will be able to find the runtime and run it.

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '3.1.402'
    installationPath: '$(Agent.ToolsDirectory)/dotnet1'
- task: UseDotNet@2
  inputs:
    packageType: 'runtime'
    version: '2.2.8'
    installationPath: '$(Agent.ToolsDirectory)/dotnet1'

dotnet --info result image

Read more comments on GitHub >

github_iconTop Results From Across the Web

NETSDK1141: Unable to resolve the .NET SDK version as ...
The SDK version specified in global.json could not be found, due to an incorrect path. How to fix the error. Install the SDK...
Read more >
The current .NET SDK does not support targeting . ...
This happened to me after installing 2.2.100-preview3-009430 and then updating to Visual Studio 15.9.2. I resolved by enabling the "Use previews ...
Read more >
Visual Studio 2019 unable to locate .Net Core SDK
Step 1) First run dotnet --list-sdks from the command line (as in Grzegorz Smulko's answer). Take note of the greatest version number.
Read more >
Incompatible versions of Mono MSBuild and .NET Core ...
NET Core SDK are incompatible on Linux and macOS. If you use such... ... 5): [MSB4018] The "ResolvePackageAssets" task failed unexpectedly. System.
Read more >
Why don't any of these methods work for installing .Net ...
I went to the following official Microsoft link to install .NET Core 6.x (SDK & runtime) and they would not work.
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