Skip to content

Conversation

wes-sleeman
Copy link

Add an environment variable to permit deterministic and user-controlled selection of the browser refresh port when using the hot reload feature of dotnet watch.

This PR adds a new environment variable named DOTNET_WATCH_AUTO_RELOAD_WS_PORT to provide the other half of the functionality provided by DOTNET_WATCH_AUTO_RELOAD_WS_HOSTNAME. This is particularly useful in situations such as container-based development workflows as it allows for specific port forwarding rules to be hard-coded in advance.

First-time contribution, so any tips on how I can get this backported as far as we usually support would be appreciated.

Closes dotnet/aspnetcore#33823

Copy link
Contributor

github-actions bot commented Sep 4, 2025

This PR is targeting main, which is now for .NET 11-facing work. If you intended to target .NET 10, either retarget this PR to release/10.0.1xx or make sure you backport the change to release/10.0.1xx after merging. See #50394 for more details.

@github-actions github-actions bot added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Sep 4, 2025
Copy link
Contributor

Thanks for your PR, @@wes-sleeman.
To learn about the PR process and branching schedule of this repo, please take a look at the SDK PR Guide.

@wes-sleeman
Copy link
Author

@dotnet-policy-service agree

@wes-sleeman
Copy link
Author

@dotnet/domestic-cat
I think this is ready for review and (hopefully) merge. Let me know if anything else needs to be done to get this ready.

@baronfel
Copy link
Member

baronfel commented Sep 4, 2025

@wes-sleeman All Watch stuff goes to @tmat, so we'll wait for him to chime in.

Thanks for making your contribution! We're technically still open for SDK-level changes for a couple more weeks, so it's possible this could make it to .NET 10. That would require a backport (which we can trigger) once this merges - since main is technically .NET 11 already!

It's very unlikely that we would backport this to 8.x or 9.x SDKs without a really compelling customer use case, or some kind of external partner to justify the work + ongoing maintenance. The SDK is mostly a fix-forward kind of component for features - majorly-impactful bug fixes and security updates are the main category of thing that would be backported.

@wes-sleeman
Copy link
Author

wes-sleeman commented Sep 4, 2025

@baronfel, thanks for the quick reply! Would enjoy this making it into .NET 10 as this has been a blocker for me leveraging .NET with my team at work (enough to make me file this PR in my spare time!), so happy to hear there's a chance on that.

@wes-sleeman wes-sleeman requested a review from baronfel September 4, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch Area-Watch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't set a static port/endpoint of auto reload script when running dotnet watch run.
2 participants