dotnet / dotnet/aspnetcore

dotnet watch sometimes broken when ItemGroup was added

Open
#58,603 0 comments 0 reactions 0 assignees View on GitHub
area-commandlinetools
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

In our .net 8 project we are using `dotnet watch` to make use of live updates for UI changes in our MVC application. This process works well except sometimes when hot reloading is not working anymore. When this occurs changing some text in a `cshtml` file does not trigger an reload of the web browser. The output of `dotnet watch` for any file within the project is something like this:

```
File changed: ./Views/x/y.cshtml.
No hot reload changes to apply.
```

It is also worth mentioning that this detection is quite slow (seconds) compared to the usual detection within milliseconds.

Now we have already found a a quick fix that might lead to the cause. At least "Rider" (Maybe also other IDEs) sometimes add new/changed files to the `csproj` file as an `ItemGroup` like so:

```



```

When something like that happens hot reloading does not work anymore (like written above) until this line is removed.

### Expected Behavior

Expected behavior is, that `dotnet watch` always works and is not easily broken by such changes or that some more logs are written to help to solve the issue.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

8.0.401

### Anything else?

.NET SDK:
Version: 8.0.401
Commit: 811edcc344
Workload version: 8.0.400-manifests.57f7c351
MSBuild version: 17.11.4+37eb419ad

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.0
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.401/

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
[aspire]
Installation Source: SDK 8.0.400
Manifest Version: 8.2.0/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.2.0/WorkloadManifest.json
Install Type: FileBased

Host:
Version: 9.0.0-rc.2.24473.5
Architecture: arm64
Commit: 990ebf52fc

.NET SDKs installed:
8.0.401 [/usr/local/share/dotnet/sdk]
9.0.100-rc.2.24474.11 [/usr/local/share/dotnet/sdk]. <--- It is not related to that, I had this before installing 9

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0-rc.2.24473.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
/Users/xx/Developer/xx/global.json

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

Download .NET:
https://aka.ms/dotnet/download

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.