How to resolve .net core build error NETDSDK1061 and warning MSB3277

I’ve tried to find any help on that issue, finding some GitHub issues (e.g. this one) looking pretty similar, but were actually different.
I’ve found a descriptive doc, but that didn’t really helped me.

I found a pretty helpful blog post from Rick Strahl, explaining what packages are available and what the purpose of each package is. That was a good thing to start.

This is my solution:

Step 1:
Execute Install-Package Microsoft.AspNetCore.App -Version [VersionOfYourChoice] and/or execute Install-Package Microsoft.NETCore.App -Version [VersionOfYourChoice] in package manager console.

Step 2:
Edit .csproj as shown below:

<PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeFrameworkVersion>2.1.4</RuntimeFrameworkVersion>  <- add this line
    <!--<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> --> <- alternative
</PropertyGroup>

One more takeaway: If you work with Win10, do yourself a favor and check the installed .NET Core SDK/Runtimes etc. Uninstall every SDK/Runtimes you do not need (again: Check Rick’s blog post for that).
You only need those you are currently targeting in one of your projects.

For example: If you’re working on one .NET Core project, and you just did those 2 steps with Versions 2.1.4 – as time of writing you only need Microsoft .NET Core SDK 2.1.402. To clean up a little, I uninstalled every .NET Core SDK/Runtimes/Packages and just took the latest from here.

Note: I followed this blog post from Jeff Atwood to answer a question, which took me too long to resolve. I hope that helps.

EDIT:
Good news for .NET Core 2.2: You just have to edit the .csproj as follows:

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
  <RuntimeFrameworkVersion>2.2.0</RuntimeFrameworkVersion>
</PropertyGroup>

EDIT:
The metapackages should not be updated manually anymore. This is the recommendation for updating AspNetCore. The version of the metapackage depends on the installed SDK.

Leave a Comment