Blazor: macOS quarantine may cause "Specified cast is not valid." error in GenerateBlazorBootJson target
See original GitHub issueDescribe 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
- 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.
- unzip the archive
- 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:
- Created 3 years ago
- Comments:19 (11 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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