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

How to docker-compose using "dotnet watch run" in container #217

Closed
roussakov opened this issue Nov 3, 2019 · 6 comments
Closed

How to docker-compose using "dotnet watch run" in container #217

roussakov opened this issue Nov 3, 2019 · 6 comments

Comments

@roussakov
Copy link

roussakov commented Nov 3, 2019

Hi guys,
I'm trying to set up a docker-compose stack using visual studio 2017 docker tooling.
And unable to find the way how to run the app inside a container using dotnet watch run
any suggestions?

Thanks!

@bwateratmsft
Copy link
Contributor

@roussakov Unfortunately this isn't possible with the tooling. We use a lot of optimizations in debug mode that are incompatible with dotnet watch.

@amarant
Copy link

amarant commented Nov 3, 2019

@bwateratmsft So does it means that it is impossible to edit a cshtml page and having that change reflected on a refresh with docker-compose ?

@bwateratmsft
Copy link
Contributor

@amarant Not necessarily; the edit-refresh scenario is kind of scattered depending on .NET Core version and container OS. @pratiksanglikar can probably list which ones work.

In debug mode, we map in the source and binaries built on the host. In release mode, source is copied in, and built in the SDK container. So, it would never work in release mode, but can in debug.

@roussakov
Copy link
Author

@bwateratmsft Thanks a lot for your answer.

@pratiksanglikar
Copy link
Contributor

pratiksanglikar commented Nov 4, 2019

Hi @roussakov , @amarant
Adding to @bwateratmsft , Edit and Refresh works depending on what version of .NET Core you are on.

  • .NET Core 2.1 -> Works on both Linux and Windows containers.

  • .NET Core 2.2 -> Runtime compilation APIs are obsoleted, it works, but may take multiple refreshes to actually see the changes on both Linux and Windows containers.

  • .NET Core 3.0 -> Runtime compilation support is disabled in default templates. To enable it,
    • Add Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation nuget package.
    • In the Startup.cs, add services.AddRazorPages().AddRazorRuntimeCompilation();

After making the above-mentioned changes, Edit and refresh works for both Linux and Windows containers.

Also, this would work when editing *.cshtml files but not while editing *.cs files.

@elietebchrani
Copy link

This solution is working locally, but when publishing to Azure it's not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants