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.68k stars 1.06k forks source link

`dotnet watch run` watches the .git folder. #43817

Open StringEpsilon opened 1 week ago

StringEpsilon commented 1 week ago

Describe the bug

The dotnet watch run command watches the .git folder of my project, sometimes even recompiling due to this error:

Unable to apply hot reload, restart is needed to apply the changes.

From a simple git stash / git stash pop:

dotnet watch ⌚ Files added: ./.git/objects/3c/tmp_obj_S92RQS, ./.git/index.lock, ./.git/index, ./.git/objects/3c/82172b9f73e35b3b42e3653c719df4db9726ec dotnet watch ⌚ Files added: ./.git/objects/3c/tmp_obj_S92RQS, ./.git/index.lock, ./.git/index, ./.git/objects/3c/82172b9f73e35b3b42e3653c719df4db9726ec dotnet watch ⌚ No hot reload changes to apply. Files added: ./.git/index.lock, ./.git/index, ./.git/AUTO_MERGE, ./test, ./.git/AUTO_MERGE.lock dotnet watch ⌚ Files added: ./.git/index.lock, ./.git/index, ./.git/AUTO_MERGE, ./test, ./.git/AUTO_MERGE.lock dotnet watch ⌚ No hot reload changes to apply.

To Reproduce

  1. Create a new test application in a new git repository where the .csproj file is located in the git root folder.
  2. touch test
  3. git add test
  4. dotnet watch run
  5. git stash -S

Now observe the dotnet watch console output.

Exceptions (if any)

N/A

Further technical details

MackinnonBuck commented 5 days ago

@tmat, looks like this is a dotnet watch issue.

tmat commented 5 days ago

@StringEpsilon Could you share the full --verbose output for the case when you get Unable to apply hot reload, restart is needed to apply the changes. error?

StringEpsilon commented 5 days ago

@tmat I have only had that happen once so far from changes in the .git directory, which was when I was testing the reproduction steps for this issue.

If I find a way to provoke that reliably, I'll try to get the verbose output for it. But I'll not run --verbose for my everyday work to catch what turned out to be a fluke, hope you'll understand.

The main issue still stands tho.

tmat commented 5 days ago

@StringEpsilon Thanks. We can certainly special-case and exclude the .git directory, but there should be no difference in functionality. Just more console output.