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 prints No hot reload changes to apply when <AdditionalFiles> is used in .csproj #45656

Open
AlphaBs opened this issue Dec 30, 2024 · 0 comments
Labels
Area-Watch untriaged Request triage from a team member

Comments

@AlphaBs
Copy link

AlphaBs commented Dec 30, 2024

Describe the bug

When <AdditionalFiles Include="any-razor-page.cshtml"/> is added to the .csproj file, dotnet watch stops working for all files in the project and consistently outputs No hot reload changes to apply, despite changes being made to the files.
However, the changes can be applied manually by pressing Ctrl+R or restarting dotnet watch.

dotnet watch --verbose
PS C:\p\programming\git\HotReloadDemo> dotnet watch --verbose
dotnet watch ⌚ Watching with Hot Reload.
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 🔧 Building...
dotnet watch 🚀 Started 'C:\Program Files\dotnet\dotnet.exe' with arguments 'msbuild /nologo /t:Build /restore': process id 21300
  Determining projects to restore...
  All projects are up-to-date for restore.
  HotReloadDemo -> C:\p\programming\git\HotReloadDemo\bin\Debug\net8.0\HotReloadDemo.dll
dotnet watch ⌚ Process id 21300 ran for 1281ms
dotnet watch ⌚ Running MSBuild target 'GenerateWatchList' on 'C:\p\programming\git\HotReloadDemo\HotReloadDemo.csproj'
dotnet watch 🚀 Started 'C:\Program Files\dotnet\dotnet.exe' with arguments 'msbuild /nologo C:\p\programming\git\HotReloadDemo\HotReloadDemo.csproj /p:_DotNetWatchListFile=C:\Users\ksi12\AppData\Local\Temp\tmpkfzfcq.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 23164
dotnet watch ⌚ Process id 23164 ran for 518ms
dotnet watch ⌚ Watching 76 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:13207,ws://localhost:13208.
dotnet watch 🔥 HotReloadProfile: Default.
dotnet watch ⌚ Connecting to the application.
dotnet watch ⌚ MSBuildWorkspace warning: [Warning] Duplicate source file 'C:\p\programming\git\HotReloadDemo\Pages\Privacy.cshtml' in project 'C:\p\programming\git\HotReloadDemo\HotReloadDemo.csproj'
dotnet watch ⌚ Running HotReloadDemo with the following arguments: ''
dotnet watch 🚀 Started 'C:\p\programming\git\HotReloadDemo\bin\Debug\net8.0\HotReloadDemo.exe' with arguments '': process id 24172
dotnet watch 🚀 Started
dotnet watch 🔥 Hot reload capabilities: Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType.
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5041
dotnet watch ⌚ Launching browser.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\p\programming\git\HotReloadDemo
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
      Failed to determine the https port for redirect.
dotnet watch ⌚ File changed: .\Pages\Index.cshtml.
dotnet watch ⌚ No hot reload changes to apply.
dotnet watch ⌚ Updating diagnostics in the browser.
dotnet watch 🔥 Hot reload change handled in 164.3551ms.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new Razor project: dotnet new razor
  2. Modify the .csproj file (you can include any razor page, not just Privacy.cshtml):
  <ItemGroup>
    <AdditionalFiles Include="Pages\Privacy.cshtml" />
  </ItemGroup>
  1. Run dotnet watch
  2. Try editing any other razor page (e.g., Index.cshtml) and observe that changes are not applied.

Alternatively, you can clone my repository to see the issue in action: hot-reload-bug-demo-2

Exceptions (if any)

dotnet watch should detect changes made to any Razor pages and apply hot reload appropriately.

Further technical details

dotnet --info
PS C:\p\programming\git\HotReloadDemo> dotnet --info
.NET SDK:
 Version:           8.0.404
 Commit:            7b190310f2
 Workload version:  8.0.400-manifests.77ae465e
 MSBuild version:   17.11.9+a69bbaaf5

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

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
 [aspire]
   Installation Source: VS 17.10.35004.147
   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:        FileBased


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

.NET SDKs installed:
  8.0.300 [C:\Program Files\dotnet\sdk]
  8.0.404 [C:\Program Files\dotnet\sdk]
  9.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.5 [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 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.5 [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 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.5 [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 [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:
  C:\p\programming\git\HotReloadDemo\global.json

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

Download .NET:
  https://aka.ms/dotnet/download
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Watch untriaged Request triage from a team member labels Dec 30, 2024
@AlphaBs AlphaBs changed the title dotnet watch fails to apply hot reload changes when <AdditionalFiles> is used in .csproj dotnet watch prints No hot reload changes to apply when <AdditionalFiles> is used in .csproj Dec 30, 2024
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

1 participant