dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.66k stars 1.06k forks source link

[dotnet-sdk-9.0.100-rc.1.24413.1] Failed to execute command "dotnet watch run" with error "Hot Reload based watching is only supported in .NET 6.0 or newer apps" #42748

Closed Junjun-zhao closed 1 week ago

Junjun-zhao commented 4 weeks ago

Application Name: Global - tools OS: Windows 10 21H2 CPU: X64 .NET Build Number: dotnet-sdk-9.0.100-rc.1.24413.1 App & Source checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2220902

Verify Scenarios: 1). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.1.24413.1: Fail 2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.1.24409.1: Pass 3). Windows 10 21H2 AMD64 + dotnet-sdk-6.0.425-win-x64: Pass

Description : When run command "dotnet watch run" for a .NET 5.0 APP with the latest .NET 9 build "dotnet-sdk-9.0.100-rc.1.24413.1", it will be throws error "Hot Reload based watching is only supported in .NET 6.0 or newer apps. Update the project's launchSettings.json to disable this feature" . We found it should be related the commit Implement support for multi-process Hot Reload (#41324) · dotnet/sdk@8d0a68e · GitHub. Could you help confirm whether this is expected? If Yes, is this a breaking change?

Repro Steps: (Demo Attatted:DotNETCoreConsole.zip) 1.Go to ...\DotNETCoreConsole\DotNETCoreConsole. 2.Execute command : dotnet watch run.

Expected Result: Run successfully and show "Hello World!".

Actual Result: Show error:Hot Reload based watching is only supported in .NET 6.0 or newer apps. Update the project's launchSettings.json to disable this feature.

Findings : If retarget the app to .NET 6.0 or higher, error will go.

Dotnet Info:

.NET SDK:
 Version:           9.0.100-rc.1.24413.1
 Commit:            2c9444fa24
 Workload version:  9.0.100-manifests.14db7d11
 MSBuild version:   17.12.0-preview-24407-03+6bc91d5e2

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-rc.1.24413.1\

Host:
  Version:      9.0.0-rc.1.24410.5
  Architecture: x64
  Commit:       static

.NET SDKs installed:
  9.0.100-rc.1.24413.1 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-rc.1.24412.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-rc.1.24410.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.1.24409.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@dotnet-actwx-bot @dotnet/compat

Junjun-zhao commented 4 weeks ago

Hi @marcpopMSFT @tmat , could you please take a look at this issue? Thanks.

marcpopMSFT commented 4 weeks ago

Adding @mkArtakMSFT per https://github.com/dotnet/sdk/blob/main/CODEOWNERS#L74

Junjun-zhao commented 2 weeks ago

Thanks @marcpopMSFT.
@mkArtakMSFT @arkalyanms @tmat Could you please take a look at this issue? We are in progress of RC1 validation windows. This also reproduces on the latest RC1 build dotnet-sdk-9.0.100-rc.1.24422.10. Could you help confirm whether this is expected? If yes, is this a breaking change?

MackinnonBuck commented 2 weeks ago

@tmat, it looks like prior to the change here, the default behavior for apps targeting .NET 5 was to restart the app when a change was made. I guess the default is now that dotnet watch performs hot reload-based watching, but this does not work in .NET 5 apps.

Would we be able to fix this for .NET 5 so that the default is not hot reload-based watching?

tmat commented 2 weeks ago

Yes, we can fix it. The workaround is to pass --no-hot-reload.

javiercn commented 2 weeks ago

@tmat is the plan here to provide a fix in the RC2 timeframe?

Should we otherwise update the scenario to target only .NET 6.0 and newer apps?

tmat commented 2 weeks ago

I think we should update the scenario to target .NET 6 app since .NET 5 is not supported anymore.

Junjun-zhao commented 1 week ago

Ok. We will update the test scenario for this. Will this be going to be documented as a breaking change?

javiercn commented 1 week ago

@tmat sounds good to me, let's have the scenario updated to target 6.0 and call it a day.

@Junjun-zhao I don't think we'll have to document this as a breaking change as 5.0 is no longer supported.