I ran into the same problem, but with a unique script in this post, so I will add it.
I have a solution with several nested projects. It looks like this:
> Solution > MvcProject > wwwroot >
When I started my MvcProject in IHostingEnvironment for ContentRootPath , the Solution folder was set, and WebRootPath was null.
According to other people's answers, adding the wwwroot folder to the Solution folder made the value WebRootPath , but that was the path to the Solution folder. I had to change the current working directory of my startup task ( cwd ) in VS Code. By default it is "cwd": "${workspaceFolder}" , and I had to change it to "cwd": "${workspaceFolder}/MvcProject"
Refresh
I again had the same problem on another machine, and I was glad I commented on this. This time, the problem was that we did not have files in one of our wwwroot folders, and empty folders did not wwwroot up in the git repositories. Add the file to your folder if you need it!
(This was done in order to be consistent with setting static file processing. In the end, we will have something there before the project starts!)
source share