Search code examples
c#.netpublishmaui-blazormaui-windows

Can't publish Maui App for Windows. Error: "Manifest file at 'obj\Release\net8.0\staticwebassets.build.json' not found"


My Project consists of a "Razor Class Library", a "Blazor App" and a ".Net Maui Blazor App", the latter two with a project reference to the "Razor Class Library". I've just created it. Everything's fine until I try to publish my Project für Windows (Method of publishing: Sideload).

First Visual Studio complained about not knowing a "RuntimeIdentifier" "win10-x64". Manually changing it to "win-x64" solved this (as strange as this error was), but now it says "Manifest file at 'obj\Release\net8.0\staticwebassets.build.json' not found" and here I'm stuck.

Publishing for any other platform (android and web are the ones I've tested) works without any problem. Compiling as an "exe"-File also works (after following this answer: https://stackoverflow.com/a/75589936/21748409). Only publishing via right click on the project and "publish" doesn't work. My PC runs on Windows 10, my Visual Studio is "Community 2022" Version 17.10.2, newest Version.

  • Tried to delete all "obj"- and "bin"-Folders in my project.
  • Tried to clean and rebuild the entire solution
  • Tried installing the newest .net SDK (.Net 8.0.6).
  • Tried installing the newest Maui Workloads.
  • Publishing a new Project that only consists of a ".Net Maui Blazor App"-Project works.
  • Tried copying said file from another path in my project into the "net8.0" folder. This error was seemingly solved, but other errors occured right after and I think I'm missing something. This new error says, that "project.assets.json" does not contain any Target for "net8.0-windows10.0.19041.0".
  • Publishing using the VS CMD and executing "dotnet publish --framework net8.0-windows10.0.19041.0" doesn't work. After the previous step, the error message here says, that "project.assets.json" does not contain a target for "net8.0-windows10.0.19041.0" in the TargetFrameworks.

I would be grateful for any help.

Edit:

The "csproj"-File of the ".Net Maui Blazor App" contains these TargetFrameworks:

<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>

There I tried adding "net8.0;" as the first entry to the first line, but that also didn't help.

Edit 2

Actually, after running "dotnet clean" and "dotnet restore", VS is giving me another error message instead of the previous one. "NETSDK1005: Assets file '[..]\RazorClassLibrary1\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". This error occurs, whether "net8.0" is included to the TargetFrameworks of the ".Net Maui Blazor App" or not. Besides of that, "Publish" keeps failing, running the App from VS still works.

Edit 3

Tried to publish via cli, both packaged and unpackaged. Both results in the error mentionen unter "Edit 2".


Solution

  • dotnet publish -f net8.0-windows10.0.19041.0 -p:WindowsPackageType=None
    

    The command can publish the MAUI project only but if you contain any razor class libs or other libs you should specify the project within the publish command.

    Here is the command you can use to publish the maui project contains the libs.

     dotnet publish -f net8.0-windows10.0.19041.0 -p:WindowsPackageType=None src\package name.MAUI.Project\package name.MAUI.Project.csproj
    

    You can refer to this thread [8.0.100-rc.1.23455.8] dotnet build for windows fails with error NETSDK1083: The specified RuntimeIdentifier "win10-x64" is not recognized for more information.