aspnetcore: Blazor: macOS quarantine may cause "Specified cast is not valid." error in GenerateBlazorBootJson target

Describe the bug

The GenerateBlazorBootJson target may show a “Specified cast is no valid.” error, causing Blazor builds to fail. It’s not clear where the actual error occurs, but it’s also not very actionable to the user.

In my particular case, the problem was solved by removing the com.apple.quarantine file attribute.

To Reproduce

  1. on a Mac, download a zip archive of a Blazor app; in my case, https://drive.google.com/open?id=1MnWAzjHcMT60wbBlUhh_haIkTLM88vbo from https://github.com/dotnet/aspnetcore/issues/20256.
  2. unzip the archive
  3. open it in VS4Mac (VS Code will probably work) and build

Expected results

The build should succeed, or the error should be actionable.

Actual results

The build fails as described above.

If you run xattr * inside the directory, you will see the culprit:

> xattr *
nuget.config: com.apple.quarantine
SwitchStream.Client: com.apple.quarantine
SwitchStream.Server: com.apple.quarantine
SwitchStream.sln: com.apple.macl
SwitchStream.sln: com.apple.quarantine

macOS has applied the com.apple.quarantine attribute to the directories, limiting MSBuild’s abilities.

Now, remove this attribute recursively inside the directory (don’t do this to your entire Downloads folder):

xattr -dr com.apple.quarantine .

…and build again. The build will succeed.

Further technical details

VS4Mac 8.5, Blazor 3.2p3

> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.201
 Commit:    b1768b4ae7

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.201/

Host (useful for support):
  Version: 3.1.3
  Commit:  4a9f85e9f8

.NET Core SDKs installed:
  3.1.201 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

This is now fixed in vsmac with mono being bumped to the above mentioned fix, so will be available in the next 8.6 preview

This is being fixed as part of https://github.com/mono/mono/issues/19466

Speaking to @rodrmoya, VS4Mac uses mono as the runtime to invoke msbuild. Our task uses DataContractJsonSerializer to serialize JSON content and the error that @rainersigwald discovered here - https://github.com/dotnet/aspnetcore/issues/20259#issuecomment-607214332 - suggests that the error is thrown from Mono’s implementation of the serializer.

@rodrmoya could you follow up with the Mono team to figure out how to address this?