Open JohanPetersson opened 2 years ago
Transferred to aspnetcore which owns dotnet-watch
.
Any updates on this issue?
Thanks for contacting us.
We're moving this issue to the .NET 7 Planning
milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
I have issues with this as well. When using a development container, I can't use dotnet watch
reliably.
Related: https://github.com/docker/for-win/issues/8749
Same problem here. Intermittently, I get the "An item with the same key has already been added" error. This would not be so bad if only I knew what it requires of me to fix it.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
@tmat could you please look into this? Thanks!
I can't reproduce it but I see a couple potential issues with the current implementation. Fixing in https://github.com/dotnet/sdk/pull/35712
@tmat I have similar issue
Unhandled exception. System.ArgumentException: An item with the same key has already been added. Key: /src/solution/sharedLibrary/obj/rider.project.restore.info
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at Microsoft.DotNet.Watcher.Internal.PollingFileWatcher.<CheckForChangedFiles>b__23_0(FileSystemInfo f)
at Microsoft.DotNet.Watcher.Internal.PollingFileWatcher.ForeachEntityInDirectory(DirectoryInfo dirInfo, Action`1 fileAction)
at Microsoft.DotNet.Watcher.Internal.PollingFileWatcher.ForeachEntityInDirectory(DirectoryInfo dirInfo, Action`1 fileAction)
at Microsoft.DotNet.Watcher.Internal.PollingFileWatcher.CheckForChangedFiles()
at Microsoft.DotNet.Watcher.Internal.PollingFileWatcher.PollingLoop()
I'm using a docker compose where service is defined something like this:
settings-api:
image: mcr.microsoft.com/dotnet/sdk:6.0
working_dir: /src/path/to/project
entrypoint:
- "/bin/sh"
- "-c"
- "dotnet watch run --packages /src/.packages/ --urls http://+:80"
ports:
- "10101:80"
environment: []
volumes:
- ${PWD}:/src
depends_on:
rabbitmq:
condition: service_healthy
Note that I mount my whole repository as a volume and exception seems to be triggered by shared dependency.
I've also tried to change entrypoint script to dotnet build .... && dotnet watch run ...
, thinking to walk around of what @JohanPetersson mentioned about having empty /bin /obj directories. This did not run either.
The only setup that did run was dotnet build && dotnet watch run --no-build --no-restore ...
, but it is obviously pointless, since watch does not rebuild sources on change. But it also probably means that the issue is somehow related to the build phase in dotnet watch command.
@Volkmire I had a similar issue and I found this article https://medium.com/@saadjaved120/hot-reload-dotnet-application-in-docker-using-dotnet-watch-c41662c73104. I hope this can help you and others.
Based on the article, I think you might need to update your volumes and add these (Just replace the ProjectName
with yours):
...
volumes:
- ./:/app
# After adding the below lines the problem went away for me
- /app/obj/ # <- directory won't be mounted
- /app/bin/ # <- directory won't be mounted
- /app/ProjectName.API/obj/ # <- directory won't be mounted
- /app/ProjectName.API/bin/ # <- directory won't be mounted
Describe the Bug
When using
dotnet watch
the file polling throws following exception:Steps to Reproduce
Add Directory.Build.props to move
bin
andobj
. The bug is however reproducible without this.Make sure bin and obj are empty.
(on Windows)
Other Information
This only happens when the project hasn't been built yet. If I start the container with just
dotnet run
once, shut down the container, and then change back todotnet watch run
as entrypoint, it works.This is reproducible with .NET 6 too.
Output of
docker version
20.10.10, build b485636
Output of
docker info