MSB4018 The "GenerateStaticWebAsssetsPropsFile" task failed unexpectedly - but the project path name is short

Niko Kreuzer 0 Reputation points
2024-04-04T09:18:52.3733333+00:00

I'm unable to perform a Build or publish a Blazor Hybrid App for iOS Targets. Initially stumbled upon this while working on a bigger app where the IPA should be triggered by a Windows machine calling msbuild.exe (and/or dotnet publish), but it's easily reproducable using Visual Studio 2022 with its template, default setup and built-in mechanisms. I will rely on this to describe how I reproduce the issue.

I'm getting the following error message:

Error MSB4018 The "GenerateStaticWebAsssetsPropsFile" task failed unexpectedly.

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\T2\StaticWebAssetTest\StaticWebAssetTest\obj\Release\net8.0-ios\ios-arm64\staticwebassets\msbuild.StaticWebAssetTest.Microsoft.AspNetCore.StaticWebAssets.props'.

Steps to reproduce:

  1. Create a new .NET MAUI Blazor Hybrid App from the VS2022 template in a relatively short root path (in my case C:\T2 )
  2. follow the steps described here: https://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/publish-app-store?view=net-maui-8.0&tabs=vs
  3. You will need to do some extra work before pairing to Mac because of existing bugs, i.e. copy C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.2.8043 to the remote Mac ~/Library/Caches/Xamarin/XMA/SDKs/sdk-manifests/8.0.100/microsoft.net.sdk.ios/17.2.8043
  4. In VS, change the target to "iOS Remote Devices - Remote Device" and the "Release" Configuration as described in the article, and from that point forward you are not able to build the app anymore. The Provisioning Profile has been set as described in the step afterwards, but you cannot "Publish" (endless loop while displaying "Archiving App Bundle 'MyAppName') and I guess this is because you cannot perform a Build.

Versions used:
VS2022 17.9.5

dotnet 8.0.3

maui: manifest: 8.0.7/8.0.100 SDK: 8.0.200

ios 17.2.8043

XCode 15.3

I did not find a workaround. The often reported solution is to use a shorter path name, but I tried that - the file path in this example has a length of 134.

Playing around I noticed that sometimes the following folder exists and contains files:

(ProjectFolder)\obj\Release\net8.0-ios\iossimulator-x64\staticwebassets

while this folder is created but left empty:

(ProjectFolder)\obj\Release\net8.0-ios\ios-arm64\staticwebassets

I also tried this while being paired to either an Intel-based Mac and a M1-based Mac, the error remains the same.

When starting the build the "SayHello" Task is started twice before the error shows up, even when net8.0-maccatalyst and all other targetframeworks are removed and I only have this in my csproj:

<TargetFrameworks>net8.0-ios</TargetFrameworks>

I also noticed that immediately after this error occurs, in Debug mode you can sometimes just press play and the Debug session will start, and in Release mode you may call dotnet publish and it will go through (only managed to do this once with a template app, not my full app). It appears that the files arrive too late and the build will fail, but the subsequent Debug or Publish can sometimes pick up the files.

Seeing that no one else reporting this I'm afraid there is a fault in my setup, but I'm stuck.


Build Output:
Build started at 10:48...

1>------ Build started: Project: StaticWebAssetTest, Configuration: Debug Any CPU ------

1>Executing SayHello Task to establish a connection to a Remote Server.

1> Properties:

1> SessionId=37b852617c6c3ada3377890c49173eae6cf174b353b50bbdd1f4a401e4fe03bb,

1> Addresss=10.102.30.17,

1> SshPort=22,

1> TcpPort=58931,

1> User=xxxxx,

1> AppName=StaticWebAssetTest,

1> VisualStudioProcessId=16320,

1> ContinueOnDisconnected=False

1>Executing SayHello Task to establish a connection to a Remote Server.

1> Properties:

1> SessionId=37b852617c6c3ada3377890c49173eae6cf174b353b50bbdd1f4a401e4fe03bb,

1> Addresss=10.102.30.17,

1> SshPort=22,

1> TcpPort=58931,

1> User=xxxxx,

1> AppName=StaticWebAssetTest,

1> VisualStudioProcessId=16320,

1> ContinueOnDisconnected=False

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: The "GenerateStaticWebAsssetsPropsFile" task failed unexpectedly.

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\T2\StaticWebAssetTest\StaticWebAssetTest\obj\Debug\net8.0-ios\iossimulator-x64\staticwebassets\msbuild.StaticWebAssetTest.Microsoft.AspNetCore.StaticWebAssets.props'.

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: at System.IO.File.InternalWriteAllBytes(String path, Byte[] bytes, Boolean checkHost)

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: at Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAsssetsPropsFile.ExecuteCore()

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

1>C:\Program Files\dotnet\sdk\8.0.203\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Pack.targets(136,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

1>Done building project "StaticWebAssetTest.csproj" -- FAILED.

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

========== Build completed at 10:49 and took 06,139 seconds ==========

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,895 questions
{count} votes