dotnet watch chooses the wrong `HotReloadProfile` and doesn't work
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Describe the bug
I have dual mode blazor project and want to use hot reload feature. Because I have `Microsoft.AspNetCore.Components.WebAssembly.Server` in references `dotnet watch` chooses the wrong profile
`BlazorHosted` instead of `Default` for the blazor server mode.
```
watch : Process id 23276 ran for 2415ms
watch : Running MSBuild target 'GenerateWatchList' on 'C:\code\****\dotnet\Host\Host.csproj'
watch : Started 'C:\Program Files\dotnet\dotnet.exe' '' with process id 16868
watch : Process id 16868 ran for 731ms
watch : Watching 592 file(s) for changes
watch : dotnet-watch is configured to launch a browser on ASP.NET Core application startup.
watch : Configuring the app to use browser-refresh middleware.
watch : Refresh server running at wss://localhost:63959,ws://localhost:63960.
watch : HotReloadProfile: BlazorHosted. C:\code\****\dotnet\Host\Host.csproj references BlazorWebAssembly project C:\code\****\UI.Blazor.Host\UI.Blazor.Host.csproj.
watch : Started 'C:\code\****\artifacts\bin\\****.exe' '' with process id 14168
watch : Running **** with the following arguments: run
watch : Started
watch : Application supports the following capabilities Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters.
```
I tried to explicitly specify profile in `launchSettings.json`:
```js
{
"profiles": {
"default": {
"commandName": "Project",
"launchBrowser": true,
"hotReloadProfile": "aspnetcore",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:7081;http://localhost:7080"
}
}
}
```
But if I set `--launch-profile` then `dotnet watch` uses legacy behavior:
```
dotnet watch -v run --launch-profile default
watch : Did not find a HotReloadProfile or running a non-default command. Watching with legacy behavior.
```
So I can't choose hot reload profile at all and it doesn't work because of it:
```
watch : File changed: C:\code\**\src\dotnet\UI.Blazor.Host\App.razor.
watch : No deltas modified. Applying changes to clear diagnostics.
watch : Received 1 from browser in [Count: 1, MessageType: Binary, EndOfMessage: True].
watch : No hot reload changes to apply.
watch : Hot reload change handled in 1089,8098ms.
```
### Further technical details
* ASP.NET Core version 6.0.100-rc.1
* `dotnet --version`: 6.0.100-rc.1.21463.6
* `dotnet watch --version`: 6.0.100-rc.1.21462.3+24bd270cd4a87721bc81bdaa4bd225d298b561d1
сс: @danroth27 @mkArtakMSFT
Contributor guide
Assessment
This issue has not been assessed yet.