C
C#14mo ago
Fypur

❔ Specify working directory when using dotnet watch

When I use dotnet run --project ../../../../Platformer.csproj The project runs just fine. I want to be able to hot reload the project though (and since im using vscode because im on ubuntu it's a pain in the ass). I can't use rider because my pc isn't powerful enough. When I use dotnet watch --project ../../../../Platformer.csproj The project starts up but then has an error because the project directory is set as the project's directlory (not the one I'm inputting the command from but the ../../../../ one). Does anyone know how to fix this? Or maybe just another way to have hot reload in vs code?
8 Replies
ZacharyPatten
ZacharyPatten14mo ago
1. is your code open source? if yes, feel free to link 2. if you are using Visual studio Code, then why not use the launch.json file and launch it from the debugging view in VSC?
Fypur
Fypur14mo ago
it's not about my code, i know the problem has to do with the working directory so no need to link it if I do that I don't get to hot reload my project launch.json uses the dotnet build which doesn't support hot reloading I can't run dotnet watch on my csproj because if i do the working directory is the directory of the csproj and not project/bin/x64/Debug/net6.0/
ZacharyPatten
ZacharyPatten14mo ago
yeah but I'm pretty sure you can get hot reload working while launching from the VSC debug screen too. I haven't actually done it myself, but did a quick google search and found this: https://kontext.tech/article/972/visual-studio-code-debug-aspnet-application-with-hot-reload. I'm a little too busy to try it myself at the moment, but maybe that will help
Fypur
Fypur14mo ago
Thanks to what you sent I made it work. Now though my breakpoints don't work :/
ZacharyPatten
ZacharyPatten14mo ago
Hard to tell what the issue is without seeing what you are seeing, but do you have "debug.allowBreakpointsEverywhere": true? in your settings
ZacharyPatten
ZacharyPatten14mo ago
screenshot from UI if you don't want to edit the JSON directly
Fypur
Fypur14mo ago
Ah nevermind actually it didn't work, it's only because I hard coded the value of the working directory for a bit anyways what you've sent me is actually really janky it starts up the game every 30 secondes or so somehow I gotta kill it with task manager breakpoints work when I don't use dotnet watch using the default vscode launch.json as long as i set "cwd": "${workspacefolder}/bin/Debug/net6.0/
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.