-
Notifications
You must be signed in to change notification settings - Fork 386
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
.NET Core console app default working directory is the source directory, not the bin directory #589
Comments
Wasn't this needed for ASP.NET as they run from source? |
I see. Tagging @BillHiebert to confirm. |
What? Regardless of what ASP.NET needs, this is a bug for Console apps |
@pi3k14 If this is returning the project folder for you (I can't test right now), can you open another bug? |
@davkean, will do |
@pi3k14 if ist a bug, a better way today to get real directory is by |
@alexsandro-xpt yes, as documented in issue #2239 |
This is still an issue. The same code does two different things if you |
@BillHiebert - can you take a look? |
Based on a conversation I had with @eerhardt, this was done for consistency. Here's an excerpt from that thread: |
@Pilchie @BillHiebert It's an open bug, reported in #2239 |
@BillHiebert agreed, but tracked in #2239, right? |
@Pilchie - yes |
this is still a problem in the context that @nathanchere mentioned |
@srivatsn Are you test it if have same behavior in WebApp? I'm ask it because I test it with var builder = new HostBuilder()
// .UseContentRoot(Directory.GetCurrentDirectory())
// .UseEnvironment(EnvironmentName.Development)
.ConfigureHostConfiguration(configHost =>
{
configHost.AddEnvironmentVariables(prefix: "ASPNETCORE_");
configHost.AddCommandLine(args);
})
.ConfigureAppConfiguration((context, config) =>
{
config.SetBasePath(Directory.GetCurrentDirectory()); // <-----------------------------------------
// config.SetBasePath(AppContext.BaseDirectory);
config.AddEnvironmentVariables(prefix: "ASPNETCORE_");
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
config.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true);
config.AddCommandLine(args);
if (context.HostingEnvironment.IsProduction())
{
var configFile = "configuration/NotifyServices-App";
config.AddJsonFile(configFile, optional: true);
var configPath = Path.Combine(context.HostingEnvironment.ContentRootPath, configFile);
if (!File.Exists(configPath))
{
System.Console.WriteLine($"O arquivo ${configPath} não foi encontrado, ele é importante mas não necessário no ambiente {context.HostingEnvironment.EnvironmentName}.");
}
}
}).... |
.net core bug dotnet/project-system#589
Expected something like this:
C:\ConsoleApplication1\ConsoleApplication1\bin\Debug
Got this:
C:\ConsoleApplication1\ConsoleApplication1
The text was updated successfully, but these errors were encountered: