.Maui Static Web Asset Build issue

Viewed 638

Severity Code Description Project File Line Suppression State Error Manifest file at 'obj\Debug\net6.0-android\android-x86\staticwebassets.build.json' not found. MauiApp3 C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 680

I am struggling to get the Android application working. My Windows form will build but I receive the above error for arm, arm-64, and x86-64 as well. I just hit create project and try running right after with no changes.

My android SDK should be correctly matching. I have the 31.2.1 Android emulator and Android 11.0 (API 30) O.S. The emulator I create is the Pixel 5 11.0 Android.

4 Answers

Thanks @Thijs for your answer :), but the solution doesn't work for me, so I go to the shared link and performed below steps:

Step 1: Download and install the dotnet-sdk-6.0.400-win-x64 from link

Step 2: Goto SDK folder (C:\Program Files\dotnet\sdk) and rename the folder 6.0.401 to 6.0.401_Backup enter image description here

Then it's worked for me.

Source

I believe you are missing Maui workload execute below command. It should resolve this error.

dotnet workload install maui

you have to add this to your .csproj file to fix this issue. Mind you this is a workaround while microsoft fixes this issue permanently.

<Target Name="TempFixBeforeBuild" BeforeTargets="BeforeBuild">
    <Copy SourceFiles="$(ProjectDir)obj\Debug\net6.0-android\staticwebassets.build.json" DestinationFiles="$(ProjectDir)obj\Debug\net6.0-android\android-arm\staticwebassets.build.json" />
    <Copy SourceFiles="$(ProjectDir)obj\Debug\net6.0-android\staticwebassets.build.json" DestinationFiles="$(ProjectDir)obj\Debug\net6.0-android\android-arm64\staticwebassets.build.json" />
    <Copy SourceFiles="$(ProjectDir)obj\Debug\net6.0-android\staticwebassets.build.json" DestinationFiles="$(ProjectDir)obj\Debug\net6.0-android\android-x64\staticwebassets.build.json" />
    <Copy SourceFiles="$(ProjectDir)obj\Debug\net6.0-android\staticwebassets.build.json" DestinationFiles="$(ProjectDir)obj\Debug\net6.0-android\android-x86\staticwebassets.build.json" />
</Target>

sadly even on github, this is how you solve this. see this link VS 17.3.4 Breaks Android build

Related