I'm using newest .Net 5 RC2. For some reason when I run debug, working directory is set to project directory, not "bin\Debug\net5.0-windows". That causes some problems because I use some shared files from other projects (they are all copied into one folder on build) so it's important for me to have working dir in $(TargetDir). I tried to achieve it with 2 ways:
Change launchSettings.json like this:
"profiles": {
"WWW": {
"commandName": "Project",
"workingDirectory": "$(TargetDir)",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
Change .csproj like this:
<PropertyGroup>
<RunWorkingDirectory>$(MSBuildProjectDirectory)\bin\$(Configuration)\$(TargetFramework)\</RunWorkingDirectory>
</PropertyGroup>
both of these ways worked however RazorRuntimeCompilation is not working when I change working directory. Any suggestions?
Here is solution I found:
var Dir = Path.GetFullPath(AppContext.BaseDirectory + "../../../");
builder.AddRazorRuntimeCompilation(options => options.FileProviders.Add(new PhysicalFileProvider(Dir))); ;