I'm attempting to build a .net application on linux and when I do dotnet restore it is ignoring my TargetFramework from my .csproj and attempting to build an older version of .net

Phillip Davis 1 Reputation point

As noted in the title. I set the TargetVersion in the .csproj to net60 and when I do a dotnet restore to get the nuget packages it gets them and then fails saying that the nuget libraries I'm attempting to use are for net451 or greater and I'm attempting to build net40 I don't see how/where I am getting overridden. (BTW this is an older .net35 app I'm attempting to migrate to newer .net and on linux etc. Not even sure if anyone's done that before.

Here's the detailed output of the things I see that's showing it 'worked' to select net60:

Target "_GetRestoreTargetFrameworksOutput" in file "/usr/share/dotnet/sdk/6.0.200/NuGet.targets" from project "/home/pdavis/src/myapp/src/myapp/myapp.csproj" (target "_GenerateResto
reProjectSpec" depends on it):
Using "GetProjectTargetFrameworksTask" task from assembly "/usr/share/dotnet/sdk/6.0.200/NuGet.Build.Tasks.dll".
Task "GetProjectTargetFrameworksTask"
(in) ProjectPath '/home/pdavis/src/myapp/src/myapp/myapp.csproj'
(in) TargetFrameworkMoniker '.NETFramework,Version=v4.0'
(in) TargetPlatformIdentifier 'Windows'
(in) TargetPlatformVersion '7.0'
(in) TargetPlatformMinVersion '7.0'
(in) TargetFrameworks ''
(in) TargetFramework 'net60'
(out) ProjectTargetFrameworks 'net60'

I got a bit confused if I should use 'net60' or 'net6.0' but tried both and get the same behavior.

Why is it setting the TargetFrameworkMoniker incorrectly when I set the targetframework to net60?

A cross-platform toolchain for developing, building, running, and publishing .NET applications.
325 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,389 questions
{count} votes