[release/10.0.2xx] [dotnet-watch] avoid PlatformNotSupportedException on various platforms#52355
Merged
jonathanpeppers merged 2 commits intorelease/10.0.2xxfrom Jan 8, 2026
Conversation
…orms
In `Microsoft.Extensions.DotNetDeltaApplier.dll`, which is used by
`dotnet-watch`.
Running `StartupHook.Initialize()` on Android results in:
01-07 14:12:27.328 7304 7304 I DOTNET : System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
01-07 14:12:27.328 7304 7304 I DOTNET : ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
01-07 14:12:27.328 7304 7304 I DOTNET : at System.ConsolePal.set_ForegroundColor(ConsoleColor value)
01-07 14:12:27.328 7304 7304 I DOTNET : at System.Console.set_ForegroundColor(ConsoleColor value)
01-07 14:12:27.328 7304 7304 I DOTNET : at StartupHook.Log(String message)
01-07 14:12:27.328 7304 7304 I DOTNET : at StartupHook.Initialize()
If you review the System.Console APIs, you can see they are decorated with:
[UnsupportedOSPlatform("android")]
[UnsupportedOSPlatform("browser")]
[UnsupportedOSPlatform("ios")]
[UnsupportedOSPlatform("tvos")]
* https://github.com/dotnet/runtime/blob/242f7b23752599f22157268de41fee91cb97ef6c/src/libraries/System.Console/src/System/Console.cs#L334-L351
Checking for these platforms makes the exception go away, and we get a
bit further now:
01-07 14:39:37.433 8293 8293 I DOTNET : [HotReload] Environment variable DOTNET_WATCH_HOTRELOAD_NAMEDPIPE_NAME has no value
To be investigated next...
jonathanpeppers
approved these changes
Jan 7, 2026
This was referenced Jan 8, 2026
This was referenced Jan 28, 2026
This was referenced Feb 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #52351 to release/10.0.2xx
/cc @jonathanpeppers