Consider adding setting a 'project directory' environment variable in dotnet-run
See original GitHub issueIt looks like some of the ASP.NET-specific stuff used to support an ASPNET_APPLICATIONBASE
environment variable in order to allow a web application to automatically determine its ‘base path’ correctly whether it was running from the context of a project with dotnet-run
(variable set) or from the context of a set of published outputs (no variable set.) It seems that the Visual Studio tooling sets this variable since some point in the past, at least to support RC1 projects.
I don’t know whether this kind of situation will really apply to anything other than ASP.NET web applications, at least in the overwhelming majority of cases, but I feel like dotnet-run
should be responsible for setting one or more environment variables like DOTNET_PROJECTDIRECTORY
that running applications could use to be context-aware.
Related:
https://github.com/dotnet/cli/pull/1382 https://github.com/aspnet/Hosting/issues/651
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top GitHub Comments
Note that you can add this to your csproj file inside a
<PropertyGroup>
to forcedotnet run
to use the project’s directory:Setting
RunWorkingDirectory
as environment variable will also make MSBuild pick it up.I have the same problem. I am trying to
dotnet run -p ./path/to/my/project
In
main
, I haveand then in
Startup
I haveThis results in:
Since
dotnet run -p
doesn’t change the current working directory, the base path point to current and not to./path/to/my/project
. AndAddUserSecrets
is expecting to find aproject.json
at the basepath and failing to do so.