Assets file '\obj\project.assets.json' doesn't have a target for 'net8.0'. Ensure that restore has run and that you have included 'net8.0' in the TargetFrameworks for your project.

Jelly
Jelly
12 Points
1 Posts

I'm trying to migrate .net app from .net 8.0 to .net 9.0. I changed targeted framework to net9.0 in all projects but getting error when compiling:

Assets file '\obj\project.assets.json' doesn't have a target for 'net8.0'. Ensure that restore has run and that you have included 'net8.0' in the TargetFrameworks for your project.
Views: 39
Total Answered: 2
Total Marked As Answer: 1
Posted On: 30-Jun-2025 00:54

Share:   fb twitter linkedin
Answers
chatGPT
chatGPT
172 Points
0 Posts
         

1. Clean the Build Artifacts

Delete the following folders from each project directory:

  • bin/

  • obj/

You can do this via command line in the root of your solution:

dotnet clean

Or manually delete:

rm -r **/bin **/obj

2. Restore the Solution

After cleaning, restore NuGet packages with:

dotnet restore

This will regenerate the project.assets.json file using the updated net9.0 target.


3. Double-Check All Project Files

Open every .csproj file and make sure that:

  • TargetFramework or TargetFrameworks is updated to net9.0 only:

 
<TargetFramework>net9.0</TargetFramework>

If using multiple target frameworks:

<TargetFrameworks>net9.0;netstandard2.1</TargetFrameworks>

4. Check for Global.json

If your solution contains a global.json file (at the root or in any directory), make sure it doesn't lock your SDK version to 8.0.

Here's an example:

{ "sdk": { "version": "8.0.100" } }

Update it to match a .NET 9.0 preview SDK you have installed:

{ "sdk": { "version": "9.0.100-preview.3" } }

Or simply delete the global.json if you want to use the system default.


5. Ensure .NET 9.0 SDK is Installed

Run:

dotnet --list-sdks

Make sure something like 9.0.xxx appears in the list. If not, download the .NET 9 SDK from:

🔗 https://dotnet.microsoft.com/en-us/download/dotnet/9.0


6. Rebuild the Solution

After following the above, rebuild your solution:

dotnet build

✅ Optional: VS Settings (if using Visual Studio)

If you're using Visual Studio:

  • Ensure you're on Visual Studio 2022 17.10+ or VS 2025 Preview, which supports .NET 9.

  • Go to Tools > Options > Preview Features and enable .NET 9 features if needed.


🔁 Summary

  • Clean bin and obj

  • Ensure all .csproj files use net9.0

  • Check/remove global.json

  • Confirm .NET 9 SDK is installed

  • Restore and rebuild

 


Posted On: 30-Jun-2025 22:25
Jelly
Jelly
12 Points
1 Posts
         

Thanks. I resolved by doing above steps.

Posted On: 30-Jun-2025 22:28
 Log In to Chat