-
Notifications
You must be signed in to change notification settings - Fork 22
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
Will DockerTools ever support ".NET Hot Reload" #322
Comments
@bhalbright, great question! Hot reload is an item on our backlog to investigate. We need to understand the technical challenges/blockers as well as the cost before we can commit to supporting it. Trust me, we would LOVE to, I just cannot commit at this time. |
Thanks for your response @BigMorty. Hopefully this will make it in the tooling in the future! It would create a killer dev experience. |
Would absolutely love this feature - we're starting to migrate more of project to Docker and using the Docker Compose Tooling (great job!) but having .NET Hot Reload support would significantly improve the dev inner loop by reducing the change feedback loop. |
Would also love to see this feature - we're doing a lot of work with .NET 6, Docker and Dapr and this would really boost feedback loops / the dev cycle. |
@JamesRandall Do you have a sample where you are doing |
I think I'm close to getting it working? I've tried the following changes: docker-compose.vs.debug.yml: version: '3.4'
services:
test-service:
labels:
com.microsoft.visualstudio.debuggee.arguments: " watch run --additionalProbingPath c:\\.nuget\\packages --additionalProbingPath c:\\.nuget\\fallbackpackages --project \"C:\\app\\MyProject.csproj\" --urls http://+:80;https://+:443 --verbose"
DOCKERFILE (ending) FROM build AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "watch", "C:\\app"] The end result of this is that dotnet watch starts up in the container and even sees filesystem events: 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 ws://localhost:49160.
dotnet watch 🚀 Started 'C:\Program Files\dotnet\dotnet.exe' '' with process id 412
dotnet watch ⌚ Running dotnet with the following arguments: run --additionalProbingPath c:\.nuget\packages --additionalProbingPath c:\.nuget\fallbackpackages --urls http://+:80;https://+:443
dotnet watch 🚀 Started
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://[::]:443
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:\app\
dotnet watch ⌚ Killing process 412
dotnet watch ⌚ Process id 412 ran for 101011ms
dotnet watch ⌚ Exited
dotnet watch ⌚ File changed: C:\app\Pages\Index.razor However, I hit the following msbuild failure when the watch tries to recompile: C:\Program Files\dotnet\sdk\6.0.401\Microsoft.Common.CurrentVersion.targets(5097,5): error MSB3027: Could not copy "C:\app\obj\Debug\net6.0\apphost.exe" to "bin\Debug\net6.0\MyProject.exe". Exceeded retry count of 10. Failed. [C:\app\MyProject.csproj]
C:\Program Files\dotnet\sdk\6.0.401\Microsoft.Common.CurrentVersion.targets(5097,5): error MSB3021: Unable to copy file "C:\app\obj\Debug\net6.0\apphost.exe" to "bin\Debug\net6.0\MyProject.exe". The process cannot access the file 'C:\app\bin\Debug\net6.0\MyProject.exe' because it is being used by another process. [C:\app\MyProject.csproj] Anyone have any thoughts on how I could work around this? Thanks! |
I've done it using separate build stage FROM mcr.microsoft.com/dotnet/sdk:6.0 AS watch
WORKDIR /src
COPY . /src
ENTRYPOINT ["dotnet", "watch", "run", "--urls", "http://0.0.0.0:5000"] Then using command to build the image: docker build . --target watch -t app And then running the image docker run -p 5000:5000 -v $PWD/:/src -v $PWD/bin -v $PWD/obj app the There are 3 mounted volumes:
|
On a side note to what folks in here suggested and tried (good stuff by the way) - Would it be possible to support a middle ground for the time being? I recently worked with a few other technologies in the Java / Kotlin space, and it seems like most of them don't go the full mile to support hot reload, they simply restart the application once files were changed. Basically dotnet watch. Would it be possible to simply restart the container and reattach the debugger in a non-intrusive way? I think that would already go a long way of adding reload-style support |
Our current fix is to open and run blazor seperatly from the rest of our docker build environment whenever we want to make any changes, I hope there is room in the schedule for this issue sooner than later. |
We haven't forgot about this request and sure hope we can provide something down the road. So far, we spent some time investigating this and realized that it is a fairly large work item that also involves work in .NET and Debugger. Will keep you posted once we can prioritize and have more info to share. |
very necessary for this feature! |
I just came back here and played around with this approach as well. Great idea! I ultimately ran into the same issue as you did, and the debugging experience is definitely not nice, but on paper this is already close to the desired behaviour. Just a quick note I wanted to drop for everyone else who wanted to play around with this approach: You definitely need to use a proper SDK image as "base" in your Dockerfile, since the "dotnet" cli tool does not come with "dotnet watch" outside of sdk images. |
This feature is a must-have |
@giuseppe-terrasi , we are working on Hot Reload support. Current plan if all goes well is to have support for CTRL-F5 in 17.7 and F5 support in the 17.8 release. |
@dbreshears apologies if this is obvious somewhere - I'm on my phone, but is there a roadmap and estimated data for 17.7 and 17.8? |
@dbreshears Just looked at 17.7 release notes, but no mention of changes part of docker tooling here. |
@ggirard07 I've just installed the 17.7 and tested it with a solution containing two Blazor Server side apps dockerized and a docker-compose project. Running the docker-compose project using CTRL+F5 and not only the hot reload button appeared but the app updated instantly after any change! Awesome! |
In my case I was waiting for the F5 experience, potentially for 17.8, as I do most of my work on backend/WebAPI side 😅 |
I just tested out 17.7 and can't get the feature to work via docker-compose. I have just published the sample app we used which caused me to seek out this repo and file the issue in March 2021 https://github.com/endjin/DaprMultiContainer I'd love if the team could use this as a test case for the feature, as this type of solution is the one that could most benefit from hot reload (when you multiply up the number of services) |
@HowardvanRooijen I've cloned your repo, and the hot reload works both on backend and frontend, updating both C# code and HTML code. |
Hot reload is visible for us when we hit Ctrl+F5, and if we make a change to |
@HowardvanRooijen I mean, the changes appears also if I refresh the page |
Any chance you could provide a Visual Studio "copy info"? Mine is:
|
This is mine (it is in Italian but I don't think it matters. But I'm using the Community version):
|
@giuseppe-terrasi after some more experimenting, it appears that Hot Reload is working in general. We were getting confused because we were testing by updating the values in Other changes to code are propagating on save as expected. |
@MikeEvansLarah great! The hot reload requires a rebuild based on what you update and static values are one of these cases ;) |
Thanks for sanity checking @giuseppe-terrasi! Another thing we discovered is that the changelog in this repo is out of date, but the one in the nuget package is up-to-date, and contains some useful info: https://www.nuget.org/packages/Microsoft.VisualStudio.Azure.Containers.Tools.Targets#readme-body-tab |
@giuseppe-terrasi I tried cloning the above repo but I don't seem to be able to run hot reloading either. This is my VS info:
Am I missing having installed something? |
@nicleary Just double checking you're doing Ctrl+F5 to start without debugging? |
@HowardvanRooijen Ah I see, I didn't realize I needed to do that. Thank you! |
Hello! Is the same process valid on .NET 8 & VisualStudio 17.8? I have access to my app with hot reload by launching the container with CTRL + 5, but i don't have the same behavior when I launch it with |
@dgo-gco This is a feature related to Visual Studio so if you run the project using |
In VS 2022 17.7 basic Hot Reload support was added for Ctrl+F5 and now in 17.8 basic Hot Reload support was extended to F5. |
Is this still the case? I'm on VS 17.8.6, and hot reload does not work at all for our Blazor Server projects using docker compose launch profiles (F5 and Ctrl+F5). Hot Reload output says "No changes were found." Edit: I should clarify the projects aren't "Blazor Server", but the .NET 8 Blazor Web App with (global) interactive server render mode. Is this not supported yet? |
@JonHodgins just created a new .NET 8 Blazor Web App with (global) interactive server render mode, Ctrl+F5ed and edited Home.razor. The hot reload did work for me. |
Is there any news on hot reload while debugging? I am trying this feature on VS 17.11.2 and .NET8 application launched using docker compose. If I launch without debugging (CTRL+F5) hot reload works fine but when using debug (F5) it detects changes but it does not update the application. |
Forgive me for using this board just to ask a question, wasn't sure of a better place to ask.
https://devblogs.microsoft.com/dotnet/update-on-net-hot-reload-progress-and-visual-studio-2022-highlights/ states "the basic Hot Reload experience works with most types of .NET apps and framework versions". From the best I can tell, that does not include running .NET apps using the Visual Studio 2022 docker-compose tooling. I tried with VS 2022 Docker tools/.NET 6 and just get an error "Applying source changes while the application is running is not supported by the runtime."
Just curious, is this ever planned to be supported? I know there's some docs about live refreshing razor pages, but I'm not using razor pages.
As an aside, I've also tried playing around with dotnet watch run by manipulating labels in docker-compose.vs.debug.yml (https://docs.microsoft.com/en-us/visualstudio/containers/docker-compose-properties?view=vs-2022#docker-compose-file-labels) with limited success. I can make the app reload but it seems to break the debugging experience, unless I'm not doing it right.
The text was updated successfully, but these errors were encountered: