AnKing
AnKing

Reputation: 2174

ASP.NET Core - Assets file doesn't have a target for .NETCoreApp 3.1

I'm trying to compile my application to run on Core 3.0 (NOT 3.1)

And I'm able to compile and run fine locally, but when I do a publish it gives me:

Error NETSDK1005: Assets file 'C:\dev...\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v3.1'. Ensure that restore has run and that you have included 'netcoreapp3.1' in the TargetFrameworks for your project.

But I'm not trying to make it run on 3.1, I need 3.0 (To maintain compatibility with other projects)

Is it possible to find out what causes it to look for 3.1 instead of 3.0?

Upvotes: 18

Views: 19575

Answers (8)

Rickovick
Rickovick

Reputation: 3

This is for those who have a MAUI project and are getting this error; this was happening to my project when I edited the csproj in a Mac with vs code and came back to Windows, I just switched the target and changed it back, and it works, seems like an encoding error between OSs

Upvotes: 0

Saad Khan
Saad Khan

Reputation: 313

I had the same problem but I faced this while updating from .Net core 3.1 to .Net 6. So I edited my publish profile and set the Target Framework to .Net6 and it resolved the problem for me and API got published. enter image description here

Upvotes: 1

mohaa8844
mohaa8844

Reputation: 441

The fastest way for me was deleting the assets file and running a dotnet restore command in the NuGet "package manager console" and had everything run smooth

Upvotes: 9

JasonV
JasonV

Reputation: 329

I had the same issue after upgrading from 3.1 to Net 6.0 where it will Build but not Publish. I then updated my existing Publish profiles to Net 6.0 as well and everything is working now.

Publish Profile Setting to change as well

Upvotes: 22

JEuvin
JEuvin

Reputation: 1039

Update visual studio this was a Microsoft bug and they fixed the issue.

Upvotes: 2

Luiz Lelis
Luiz Lelis

Reputation: 514

Updating the nuget version fixed it for me:

nuget update -self

If you prefer to update the nuget version in Visual Studio, just follow this steps.

Upvotes: 6

Glenio Labeca Filho
Glenio Labeca Filho

Reputation: 131

  1. Update all DLLs to version 3.0

  2. Check your build configuration

  3. Edit FolderProfile.pubxml and change <TargetFramework>netcoreapp3.1</TargetFramework> to <TargetFramework>netcoreapp3.0</TargetFramework>

Upvotes: 7

deco
deco

Reputation: 137

Please check your build configuration

Upvotes: 8

Related Questions