dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.82k stars 1.66k forks source link

Cannot Build net8.0-ios via msbuild or Paired Mac #21657

Open nikokreuzer opened 2 months ago

nikokreuzer commented 2 months ago

Description

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 to 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'.

As you can see, the project root resides in a delibaretly short file path as to not exceed path limits on Windows.

Steps to Reproduce

  1. Create a new .NET MAUI Blazor Hybrid App from the VS2022 template in a relatively short folder 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 either leave the Debug Configuration in place or set the "Release" Configuration as needed to publish an add. From then on, the build will fail. 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.

Link to public reproduction project repository

No response

Version with bug

8.0.3 GA

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS

Did you find any workaround?

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 133. I also have the registry setting for long path names on (1).

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 empty: (ProjectFolder)\obj\Release\net8.0-ios\ios-arm64\staticwebassets

This fact made me try 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 use the files.

Relevant log 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 ==========
drasticactions commented 2 months ago

The Visual studio team maintains this tooling and can't be addressed in this repo. If you file your issue through VSFeedback, it can be triaged by the appropriate team.

dotnet-policy-service[bot] commented 2 months ago

Thanks for the issue report @nikokreuzer! This issue appears to be a problem with Visual Studio, so we ask that you use the VS feedback tool to report the issue. That way it will get to the routed to the team that owns this experience in VS.

If you encounter a problem with Visual Studio, we want to know about it so that we can diagnose and fix it. By using the Report a Problem tool, you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks.

  1. Go to the Visual Studio for Windows feedback tool or Visual Studio for Mac feedback tool to report the issue
  2. Close this bug, and consider adding a link to the VS Feedback issue so that others can follow its activity there.
nikokreuzer commented 2 months ago

Sent Visual Studio for Windows bug report https://developercommunity.visualstudio.com/t/Unable-to-perform-a-Build-or-publish-a-B/10633316?port=1025&fsid=9c4b8cfc-f097-45d1-81eb-c76a56a5c4b6

techscx commented 3 weeks ago

I can confirm the exact same Problem.