question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
rodrmoyacommented, Apr 27, 2020

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

1reaction
pranavkmcommented, Apr 21, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor - 'Specified cast is not valid' on IHttpClientFactory. ...
CreateHttpClient gets executed it fails with the error "Specified cast is not valid". What cast is not valid? EDIT 1 Injecting HttpClient ...
Read more >
Specified cast is not valid in Blazor WebAssembly
I am getting Unhandled exception rendering component: Specified cast is not valid. System.InvalidCastException: Specified cast is not valid.
Read more >
Specified cast is not valid. in Scheduler in UI for Blazor | ...
System.InvalidCastException: Specified cast is not valid. in Scheduler · Incorporate a new string property into the model. · Create a DTO model ...
Read more >
System.InvalidCastException: Specified cast is not valid.
When I add it to DATABASE I do following Dim wwctetime1 As Date wwctetime1=RadDateTimePicker1.Text cmd.Parameters.Add( "@wtime1", SqlDbType.
Read more >
Can't get RadzenDropDown to bind to a list of strings ' ...
Unhandled exception rendering component: Specified cast is not valid. System.InvalidCastException: Specified cast is not valid. at Radzen.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found