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

8

18

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?

Pigeontoed answered 31/3, 2020 at 18:51 Comment(0)
C
8

Please check your build configuration

Crackup answered 2/4, 2020 at 2:15 Comment(1)
It happened to be the publish configuration, but i have to manually change the publish profile file as oppose to changing it in UI. Because UI showed all correct values despite incorrect ones in publish profilePigeontoed
E
21

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

Emmott answered 16/12, 2021 at 17:0 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Leaved
O
9

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

Oxeyed answered 20/12, 2021 at 8:6 Comment(0)
C
8

Please check your build configuration

Crackup answered 2/4, 2020 at 2:15 Comment(1)
It happened to be the publish configuration, but i have to manually change the publish profile file as oppose to changing it in UI. Because UI showed all correct values despite incorrect ones in publish profilePigeontoed
U
7
  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>

Ultraconservative answered 15/5, 2020 at 1:5 Comment(0)
D
6

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.

Downhaul answered 24/11, 2020 at 15:1 Comment(0)
D
2

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

Darondarooge answered 18/6, 2021 at 3:39 Comment(1)
I have the same problem with the current version of VS 2022.Honig
H
0

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

Hetrick answered 8/12, 2023 at 10:53 Comment(0)
C
0

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

Covariance answered 12/6 at 9:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.