0

My .Net MAUI project builds and runs fine when in the debug configuration. However, when I switch to Release configuration I get the following errors

1>------ Build started: Project: MyProject, Configuration: Release Any CPU ------ NuGet package restore failed. Please see Error List window for detailed warnings and errors. 1>C:\Program Files\dotnet\sdk\7.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1005: Assets file 'C:\Users\XXXX\source\repos\MyProject\MyProject\obj\project.assets.json' doesn't have a target for 'net7.0'. Ensure that restore has run and that you have included 'net7.0' in the TargetFrameworks for your project. 1>Done building project "MyProject.csproj" -- FAILED. 1>C:\Program 1>C:\Program Files\dotnet\sdk\7.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1005: Assets file 'C:\Users\XXXX\source\repos\MyProject\MyProject\obj\project.assets.json' doesn't have a target for 'net7.0-android'. Ensure that restore has run and that you have included 'net7.0-android' in the TargetFrameworks for your project. 1>Done building project "MyProject.csproj" -- FAILED.

The project.assets.json targets section is empty.

If I build the app from the PowerShell, using dotnet build -c RELEASE, the app builds fine.

Any suggestions?

  • https://stackoverflow.com/questions/72280776/assets-file-project-assets-json-doesnt-have-a-target-for-net6-0-vs2022 – Hans Passant Apr 08 '23 at 14:49
  • Per the link Hans posted and [.Net - error NETSDK1005: Assets file "project.assets.json" doesn't have a target for](https://peterdaugaardrasmussen.com/2021/02/20/dot-net-error-netsdk1005-assets-file/), the issue may occur because of problems with restoring NuGet Packages, you can try to execute the `dotnet restore --force` command (with the force) parameter. – Alexandar May - MSFT Apr 10 '23 at 09:11
  • Also you can report Visual Studio tooling issues is via Visual Studio's "Report a Problem" menu and then follow them on the developer community site. Please see [How to report a problem with Visual Studio - Visual Studio | Microsoft Learn](https://learn.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2022&viewFallbackFrom=vs-201). – Alexandar May - MSFT May 19 '23 at 06:30

0 Answers0