Skip to content

[release/10.0.2xx] [dotnet-watch] avoid PlatformNotSupportedException on various platforms#52355

Merged
jonathanpeppers merged 2 commits intorelease/10.0.2xxfrom
backport/pr-52351-to-release/10.0.2xx
Jan 8, 2026
Merged

[release/10.0.2xx] [dotnet-watch] avoid PlatformNotSupportedException on various platforms#52355
jonathanpeppers merged 2 commits intorelease/10.0.2xxfrom
backport/pr-52351-to-release/10.0.2xx

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Jan 7, 2026

Backport of #52351 to release/10.0.2xx

/cc @jonathanpeppers

…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 jonathanpeppers enabled auto-merge (squash) January 8, 2026 14:25
@jonathanpeppers jonathanpeppers merged commit 79e5fa6 into release/10.0.2xx Jan 8, 2026
26 checks passed
@jonathanpeppers jonathanpeppers deleted the backport/pr-52351-to-release/10.0.2xx branch January 8, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant