Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet watch file-watching has regressed in 9.0 #44912

Open
willdean opened this issue Nov 17, 2024 · 2 comments
Open

dotnet watch file-watching has regressed in 9.0 #44912

willdean opened this issue Nov 17, 2024 · 2 comments
Labels
Area-Watch untriaged Request triage from a team member

Comments

@willdean
Copy link

Describe the bug

I am using "dotnet watch" to launch and watch an extremely simple asp.net application which, for the purposes of this bug report, simply serves up a static index.html file. I have a browser open on that page, and I edit the file in VS (17.12.0).

The app targets .NET 8.0 - The machine has both 8.0 and 9.0 SDKs installed, and the version of dotnet watch which runs is determined by a global.json file.

With the 8.0 SDK, if I make a simple modification to index.html, dotnet watch displays the following:

dotnet watch ⌚ File changed: .\wwwroot\index.html.
dotnet watch 🔥 Hot reload of static file succeeded.

The browser is automatically refreshed, and the update is immediately visible.

With the 9.0 SDK, if I make the same kind of modification, in the same editor, I see the following output from dotnet watch:

dotnet watch ⌚ File added: .\wwwroot\pdarvkmr.5io~
dotnet watch ⌚ File deleted: .\wwwroot\index.html
dotnet watch ⌚ File added: .\wwwroot\pdarvkmr.5io~
dotnet watch ⌚ File deleted: .\wwwroot\index.html
dotnet watch 🔥 Hot Reload of static files succeeded.
dotnet watch ⌚ No hot reload changes to apply.

The browser is refreshed, but it's intermittent if the modification is visible without needing a second, manual, browser refresh (i.e. there's a race here, presumably the browser is refreshed too early).

I assume that the intermediate files are part of some kind of "safe save" process which VS uses, and dnw was previously smart enough (or dumb enough!) to ignore these, but is now picking them up and confusing itself.

I know from working on other dev-tool file-watchers that editors will always find ways to confuse them, but I think it's reasonable to expect that "dotnet watch" is not confused by Visual Studio, particularly when it used to work OK. There is only one "breaking change" release note for dnw in 9.0, and it doesn't apply here.

Reproduction

  1. Watch an asp.net project with a static html file
  2. Edit that file in Visual Studio
  3. Observe that dnw in 9.0 is confused by what file modification occurred.

Additional Info

.NET 8.0 --verbose startup output:

  Determining projects to restore...
  All projects are up-to-date for restore.
  EmbeddedWebApp -> [ObfuscatedPath]\EmbeddedWebApp\bin\dnw\Debug\net8.0\EmbeddedWebApp.dll
  Running WebPage.h builder
dotnet watch ⌚ Process id 35476 ran for 937ms
dotnet watch ⌚ Running MSBuild target 'GenerateWatchList' on '[ObfuscatedPath]\EmbeddedWebApp\EmbeddedWebApp.csproj'
dotnet watch 🚀 Started 'C:\Program Files\dotnet\dotnet.exe' with arguments 'msbuild /nologo [ObfuscatedPath]\EmbeddedWebApp\EmbeddedWebApp.csproj "/p:_DotNetWatchListFile=C:\Users\Will Dean\AppData\Local\Temp\tmplkoyyg.tmp" /nologo /v:n /t:GenerateWatchList /p:DotNetWatchBuild=true /p:DesignTimeBuild=true "/p:CustomAfterMicrosoftCommonTargets=C:\Program Files\dotnet\sdk\8.0.404\DotnetTools\dotnet-watch\8.0.404-servicing.24521.39\tools\net8.0\any\DotNetWatch.targets" "/p:CustomAfterMicrosoftCommonCrossTargetingTargets=C:\Program Files\dotnet\sdk\8.0.404\DotnetTools\dotnet-watch\8.0.404-servicing.24521.39\tools\net8.0\any\DotNetWatch.targets" /p:_DotNetWatchTraceOutput=true': process id 38436
dotnet watch ⌚ Process id 38436 ran for 391ms
dotnet watch ⌚ Watching 11 file(s) for changes
dotnet watch ⌚ dotnet-watch is configured to launch a browser on ASP.NET Core application startup.
dotnet watch ⌚ Configuring the app to use browser-refresh middleware.
dotnet watch ⌚ Refresh server running at wss://localhost:56238,ws://localhost:56239.
dotnet watch 🔥 HotReloadProfile: Default.
dotnet watch ⌚ Connecting to the application.
dotnet watch ⌚ Running EmbeddedWebApp with the following arguments: ''
dotnet watch 🚀 Started '[ObfuscatedPath]\EmbeddedWebApp\bin\dnw\Debug\net8.0\EmbeddedWebApp.exe' with arguments '': process id 34612
dotnet watch 🚀 Started
dotnet watch 🔥 Hot reload capabilities: Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType.
[12:20:20 INF] Starting...

.NET 9.0 --verbose startup info

dotnet watch ⌚ Working directory: '[ObfuscatedPath]\EmbeddedWebApp'
dotnet watch ⌚ Watching with Hot Reload.
dotnet watch ⌚ DOTNET_WATCH_RESTART_ON_RUDE_EDIT = 'true'. Will restart without prompt.
dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
  💡 Press "Ctrl + R" to restart.
dotnet watch ⌚ Running MSBuild target 'GenerateWatchList' on '[ObfuscatedPath]\EmbeddedWebApp\EmbeddedWebApp.csproj'
dotnet watch 🚀 Launched 'C:\Program Files\dotnet\dotnet.exe' with arguments 'msbuild /nologo [ObfuscatedPath]\EmbeddedWebApp\EmbeddedWebApp.csproj "/p:_DotNetWatchListFile=C:\Users\Will Dean\AppData\Local\Temp\tmppeffge.tmp" /nologo /v:n /t:GenerateWatchList /p:DotNetWatchBuild=true /p:DesignTimeBuild=true "/p:CustomAfterMicrosoftCommonTargets=C:\Program Files\dotnet\sdk\9.0.100\DotnetTools\dotnet-watch\9.0.100-rtm.24529.9\tools\net9.0\any\DotNetWatch.targets" "/p:CustomAfterMicrosoftCommonCrossTargetingTargets=C:\Program Files\dotnet\sdk\9.0.100\DotnetTools\dotnet-watch\9.0.100-rtm.24529.9\tools\net9.0\any\DotNetWatch.targets" /p:_DotNetWatchTraceOutput=true': process id 476
dotnet watch ⌚ Process id 476 ran for 437ms.
dotnet watch ⌚ Watching 11 file(s) for changes
dotnet watch ⌚ Target process is '[ObfuscatedPath]\EmbeddedWebApp\bin\dnw\Debug\net8.0\EmbeddedWebApp.exe'
dotnet watch ⌚ Configuring the app to use browser-refresh middleware
dotnet watch ⌚ dotnet-watch is configured to launch a browser on ASP.NET Core application startup.
dotnet watch ⌚ Refresh server running at wss://localhost:56426,ws://localhost:56427.
dotnet watch 🔥 HotReloadProfile: Default.
dotnet watch ⌚ [EmbeddedWebApp (net8.0)] Waiting for application to connect to pipe 6d0d30b2-c55e-460d-b45f-8bfd37680577.
dotnet watch 🚀 [EmbeddedWebApp (net8.0)] Launched 'C:\Program Files\dotnet\dotnet.exe' with arguments '[env:DOTNET_MODIFIABLE_ASSEMBLIES=debug] [env:DOTNET_WATCH_HOTRELOAD_NAMEDPIPE_NAME=6d0d30b2-c55e-460d-b45f-8bfd37680577] "[env:DOTNET_STARTUP_HOOKS=C:\Program Files\dotnet\sdk\9.0.100\DotnetTools\dotnet-watch\9.0.100-rtm.24529.9\tools\net9.0\any\hotreload\Microsoft.Extensions.DotNetDeltaApplier.dll;C:\Program Files\dotnet\sdk\9.0.100\DotnetTools\dotnet-watch\9.0.100-rtm.24529.9\tools\net9.0\any\middleware\Microsoft.AspNetCore.Watch.BrowserRefresh.dll]" run': process id 33816
Using launch settings from [ObfuscatedPath]\EmbeddedWebApp\Properties\launchSettings.json...
Building...
dotnet watch 🕵️ [6d0d30b2-c55e-460d-b45f-8bfd37680577] Loaded into process: [ObfuscatedPath]\EmbeddedWebApp\bin\dnw\Debug\net8.0\EmbeddedWebApp.dll
dotnet watch 🕵️ [6d0d30b2-c55e-460d-b45f-8bfd37680577] Connecting to hot-reload server
dotnet watch 🕵️ [6d0d30b2-c55e-460d-b45f-8bfd37680577] Connected.
dotnet watch ⌚ [EmbeddedWebApp (net8.0)] Capabilities: 'Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType'
dotnet watch ⌚ [EmbeddedWebApp (net8.0)] Build completed.
[12:24:42 INF] Starting...
dotnet watch ⌚ Solution:
dotnet watch ⌚   Project: [ObfuscatedPath]\EmbeddedWebApp\EmbeddedWebApp.csproj
dotnet watch ⌚     Document: [ObfuscatedPath]\EmbeddedWebApp\Program.cs [NK6zspago2WOYSP0AkwjGGXpnhjEAy12KwQ+0u78iCs=]
dotnet watch ⌚     Document: [ObfuscatedPath]\EmbeddedWebApp\Startup.cs [vLbZ2LmHj1nwjlIqOCzEx12tRMKwsrP9zz8iZnI0G0g=]
dotnet watch ⌚     Document: [ObfuscatedPath]\EmbeddedWebApp\obj\dnw\Debug\net8.0\.NETCoreApp,Version=v8.0.AssemblyAttributes.cs [96XZeJyGNiXhOf+Z4RE6UDgw9rhaiPYSmRbfg6x2tJ4=]
dotnet watch ⌚     Document: [ObfuscatedPath]\EmbeddedWebApp\obj\dnw\Debug\net8.0\EmbeddedWebApp.AssemblyInfo.cs [M8JjV6F4Cyt9NPvb8IIM2wucrcVZPOP8L8uzCqXg04w=]
dotnet watch ⌚     Config: [ObfuscatedPath]\EmbeddedWebApp\obj\dnw\Debug\net8.0\EmbeddedWebApp.GeneratedMSBuildEditorConfig.editorconfig [V/yBk6IbOX+h0aRS35CBEYoHc3CFvr2jncQc8B+7pqU=]
dotnet watch ⌚     Config: C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\analyzers\build\config\analysislevel_8_default.globalconfig [AqvoHMovS1Aoopie98b3akwNsww5DhMbRVschVTGAv4=]
dotnet watch 🔥 Hot reload session started.
dotnet watch ⌚ Waiting for changes

Further technical details

  • Include the output of dotnet --info
.NET SDK:
 Version:           9.0.100
 Commit:            59db016f11
 Workload version:  9.0.100-manifests.c6f19616
 MSBuild version:   17.12.7+5b8665660

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

.NET workloads installed:
 [android]
   Installation Source: VS 17.12.35506.116, VS 17.12.35323.107
   Manifest Version:    35.0.7/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.7\WorkloadManifest.json
   Install Type:              Msi

 [aspire]
   Installation Source: VS 17.12.35506.116, VS 17.12.35323.107
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

 [maui-windows]
   Installation Source: VS 17.12.35506.116, VS 17.12.35323.107
   Manifest Version:    9.0.0/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.0\WorkloadManifest.json
   Install Type:              Msi

 [maccatalyst]
   Installation Source: VS 17.12.35506.116, VS 17.12.35323.107
   Manifest Version:    18.0.9617/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.0.9617\WorkloadManifest.json
   Install Type:              Msi

 [ios]
   Installation Source: VS 17.12.35506.116, VS 17.12.35323.107
   Manifest Version:    18.0.9617/9.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.0.9617\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

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

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-rc.1.24431.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-rc.2.24474.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
 [ObfuscatedPath]\EmbeddedWebApp\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
  • The IDE VS 17.12.0
@garrettlondon1
Copy link

garrettlondon1 commented Nov 17, 2024

Seeing additional issues with hot reload:

dotnet watch ❌ [UI (net9.0)] Change failed to apply (error code: '00-01-00-00-00'). Further changes won't be applied to this process.

Always on the second change to a CSS file. Works fine in .NET8

@Juulsn
Copy link

Juulsn commented Nov 18, 2024

Not just CSS but every change in .razor files, after the second edit. While the second edit still gets applied, no further changes are applied starting from the third edit due to "Further changes won’t be applied to this process."

This makes dotnet watch (hot-reload) essentially useless in .NET 9 😕

dotnet watch ⌚ Updating diagnostics in the browser.
dotnet watch ⌚ Failed to receive response from a connected browser.
dotnet watch ⌚ Updating diagnostics in the browser.
dotnet watch ⌚ Failed to receive response from a connected browser.
dotnet watch ⌚ Updating diagnostics in the browser.
dotnet watch 🔥 [MigrationService (net9.0)] Previous changes failed to apply. Further changes are not applied to this process.
dotnet watch ❌ [ApiService (net9.0)] Change failed to apply (error code: '00-03-00-00-00'). Further changes won't be applied to this process.
dotnet watch ⌚ [ApiService (net9.0)] Disposing agent communication pipe
dotnet watch 🔥 [ApiService (net9.0)] Updates applied: 1 out of 1.
dotnet watch ❌ [Web (net9.0)] Change failed to apply (error code: '00-03-00-00-00-3E'). Further changes won't be applied to this process.
dotnet watch ⌚ [Web (net9.0)] Disposing agent communication pipe
dotnet watch 🔥 [Web (net9.0)] Updates applied: 1 out of 1.
dotnet watch ❌ [AppHost (net9.0)] Change failed to apply (error code: '00-03-00-00-00-3E-41-70-70-6C-79-69-6E-67-20-64'). Further changes won't be applied to this process.
dotnet watch ⌚ [AppHost (net9.0)] Disposing agent communication pipe
dotnet watch 🔥 [AppHost (net9.0)] Updates applied: 1 out of 1.
dotnet watch ❌ [Web.Portal (net9.0)] Change failed to apply (error code: '00-04-00-00-00-3E-41-70-70-6C-79-69-6E-67-20-64'). Further changes won't be applied to this process.
dotnet watch ⌚ [Web.Portal (net9.0)] Disposing agent communication pipe
dotnet watch 🔥 [Web.Portal (net9.0)] Updates applied: 1 out of 1.
dotnet watch 🔥 Hot reload change handled in 286ms.
dotnet watch ⌚ File change: Update '/Users/me/RiderProjects/Project/Web.Portal/Components/Pages/Home.razor' (written 17:54:27.7986775 after 17:52:19.1168130).
dotnet watch ⌚ Ignoring file change during build: Update '/Users/me/RiderProjects/Project/Web.Portal/Components/Pages/Home.razor~' (created 00:00:00.0000000 and written 00:00:00.0000000 before 17:52:19.1168130).
dotnet watch ⌚ Change ignored: Update '/Users/me/RiderProjects/Project/Web.Portal/Components/Pages/Home.razor~'.
dotnet watch ⌚ Ignoring file change during build: Add '/Users/me/RiderProjects/Project/Web.Portal/Components/Pages/Home.razor~' (created 00:00:00.0000000 and written 00:00:00.0000000 before 17:52:19.1168130).
dotnet watch ⌚ Change ignored: Add '/Users/me/RiderProjects/Project/Web.Portal/Components/Pages/Home.razor~'.
dotnet watch ⌚ File '/Users/me/RiderProjects/Project/Web.Portal/Components/Pages/Home.razor~' deleted after 17:52:19.1168130.
dotnet watch ⌚ Change ignored: Delete '/Users/me/RiderProjects/Project/Web.Portal/Components/Pages/Home.razor~'.
dotnet watch ⌚ File updated: /Users/me/RiderProjects/Project/Web.Portal/Components/Pages/Home.razor
dotnet watch ⌚ Solution: 
dotnet watch ⌚   Project: /Users/me/RiderProjects/Project/AppHost/AppHost.csproj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Watch untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants