How does ASPNET Core resolves the configuration pathHow to import a module given the full path?Publish not getting connection string from appsettings.production.jsonHow to store AWS credentials for dotnet core app hosted on Ubuntu 16.04?Dotnet isn't aware of environment specific appsettings fileWhat is the equivalent of Web.config transform in ASP.NET Core?Cannot find module 'aspnet-webpack' when using 'dotnet publish' in .Net Core 2.0 & AngularC# project configuration and environment variableDetailed application logs from aspnet core app to cloudwatchHow to have a config file for local development and one for the development server in AspNet Core without breaking the IsDevelopment function logicConfigure Asp.Net core web api Development environment during debugging with iis express
What does this Swiss black on yellow rectangular traffic sign with a symbol looking like a dart mean?
Why does std::string_view create a dangling view in a ternary expression?
Warnings using NDSolve on wave PDE. "Using maximum number of grid points" , "Warning: scaled local spatial error estimate"
Too early in the morning to have SODA?
Why does Linux list NVMe drives as /dev/nvme0 instead of /dev/sda?
How could empty set be unique if it could be vacuously false
Umlaut character order when sorting
How can I prevent a user from copying files on another hard drive?
King or Queen-Which piece is which?
Encounter design and XP thresholds
How much steel armor can you wear and still be able to swim?
Is there a name for the trope when there is a moments dialogue when someone pauses just before they leave the room?
What are the current battlegrounds for people’s “rights” in the UK?
Are there any individual aliens that have gained superpowers in the Marvel universe?
Why is it easier to balance a non-moving bike standing up than sitting down?
Explicit song lyrics checker
What does it cost to buy a tavern?
Should I include an appendix for inessential, yet related worldbuilding to my story?
Very tricky nonogram - where to go next?
Is the continuity test limit resistance of a multimeter standard?
Prisoner on alien planet escapes by making up a story about ghost companions and wins the war
Justifying Affordable Bespoke Spaceships
What was the first third-party commercial application for MS-DOS?
How hard is it to distinguish if I am given remote access to a virtual machine vs a piece of hardware?
How does ASPNET Core resolves the configuration path
How to import a module given the full path?Publish not getting connection string from appsettings.production.jsonHow to store AWS credentials for dotnet core app hosted on Ubuntu 16.04?Dotnet isn't aware of environment specific appsettings fileWhat is the equivalent of Web.config transform in ASP.NET Core?Cannot find module 'aspnet-webpack' when using 'dotnet publish' in .Net Core 2.0 & AngularC# project configuration and environment variableDetailed application logs from aspnet core app to cloudwatchHow to have a config file for local development and one for the development server in AspNet Core without breaking the IsDevelopment function logicConfigure Asp.Net core web api Development environment during debugging with iis express
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have the following code:
var config = new ConfigurationBuilder();
config
.SetBasePath(Directory.GetCurrentDirectory())
.AddEnvironmentVariables()
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.environment.json", true);
Which works fine in development environment and production too. However if I place this:
Raise<FileNotFoundException>.If(File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json")),
$"Could not find the settings file");
It raises exception during debug sessions and release sessions (basically when the app is not published and executed from Visual Studio) that file could not be found which is kind of correct because VS2017 does not copy settings file to the debug folder and instead keep them in the source folder. So my question is,
how does the dotnet core resolves the configuration path for aspnet core?
asp.net-core configuration
add a comment |
I have the following code:
var config = new ConfigurationBuilder();
config
.SetBasePath(Directory.GetCurrentDirectory())
.AddEnvironmentVariables()
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.environment.json", true);
Which works fine in development environment and production too. However if I place this:
Raise<FileNotFoundException>.If(File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json")),
$"Could not find the settings file");
It raises exception during debug sessions and release sessions (basically when the app is not published and executed from Visual Studio) that file could not be found which is kind of correct because VS2017 does not copy settings file to the debug folder and instead keep them in the source folder. So my question is,
how does the dotnet core resolves the configuration path for aspnet core?
asp.net-core configuration
Not 100% sure but probably using theIHostingEnvironment Interface
theContentRootPath
property
– Anton Toshik
Mar 25 at 8:07
add a comment |
I have the following code:
var config = new ConfigurationBuilder();
config
.SetBasePath(Directory.GetCurrentDirectory())
.AddEnvironmentVariables()
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.environment.json", true);
Which works fine in development environment and production too. However if I place this:
Raise<FileNotFoundException>.If(File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json")),
$"Could not find the settings file");
It raises exception during debug sessions and release sessions (basically when the app is not published and executed from Visual Studio) that file could not be found which is kind of correct because VS2017 does not copy settings file to the debug folder and instead keep them in the source folder. So my question is,
how does the dotnet core resolves the configuration path for aspnet core?
asp.net-core configuration
I have the following code:
var config = new ConfigurationBuilder();
config
.SetBasePath(Directory.GetCurrentDirectory())
.AddEnvironmentVariables()
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.environment.json", true);
Which works fine in development environment and production too. However if I place this:
Raise<FileNotFoundException>.If(File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json")),
$"Could not find the settings file");
It raises exception during debug sessions and release sessions (basically when the app is not published and executed from Visual Studio) that file could not be found which is kind of correct because VS2017 does not copy settings file to the debug folder and instead keep them in the source folder. So my question is,
how does the dotnet core resolves the configuration path for aspnet core?
asp.net-core configuration
asp.net-core configuration
asked Mar 25 at 6:56
Simple FellowSimple Fellow
2,69911725
2,69911725
Not 100% sure but probably using theIHostingEnvironment Interface
theContentRootPath
property
– Anton Toshik
Mar 25 at 8:07
add a comment |
Not 100% sure but probably using theIHostingEnvironment Interface
theContentRootPath
property
– Anton Toshik
Mar 25 at 8:07
Not 100% sure but probably using the
IHostingEnvironment Interface
the ContentRootPath
property– Anton Toshik
Mar 25 at 8:07
Not 100% sure but probably using the
IHostingEnvironment Interface
the ContentRootPath
property– Anton Toshik
Mar 25 at 8:07
add a comment |
1 Answer
1
active
oldest
votes
I think you're getting confused on things here. The configuration is pulled by default from the entry point directory. Inside Visual Studio or when running dotnet run
from the command-line within your project root, everything works fine. Also, when you publish, the published directory will contain the configuration files alongside the entrypoint DLL, so this will work fine as well.
What you seem to be talking about is running from the bin
directory, which is not a supported thing. The bin directory is effectively a cache. It's not a published version of your application, and thus cannot be run as if it is.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332597%2fhow-does-aspnet-core-resolves-the-configuration-path%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you're getting confused on things here. The configuration is pulled by default from the entry point directory. Inside Visual Studio or when running dotnet run
from the command-line within your project root, everything works fine. Also, when you publish, the published directory will contain the configuration files alongside the entrypoint DLL, so this will work fine as well.
What you seem to be talking about is running from the bin
directory, which is not a supported thing. The bin directory is effectively a cache. It's not a published version of your application, and thus cannot be run as if it is.
add a comment |
I think you're getting confused on things here. The configuration is pulled by default from the entry point directory. Inside Visual Studio or when running dotnet run
from the command-line within your project root, everything works fine. Also, when you publish, the published directory will contain the configuration files alongside the entrypoint DLL, so this will work fine as well.
What you seem to be talking about is running from the bin
directory, which is not a supported thing. The bin directory is effectively a cache. It's not a published version of your application, and thus cannot be run as if it is.
add a comment |
I think you're getting confused on things here. The configuration is pulled by default from the entry point directory. Inside Visual Studio or when running dotnet run
from the command-line within your project root, everything works fine. Also, when you publish, the published directory will contain the configuration files alongside the entrypoint DLL, so this will work fine as well.
What you seem to be talking about is running from the bin
directory, which is not a supported thing. The bin directory is effectively a cache. It's not a published version of your application, and thus cannot be run as if it is.
I think you're getting confused on things here. The configuration is pulled by default from the entry point directory. Inside Visual Studio or when running dotnet run
from the command-line within your project root, everything works fine. Also, when you publish, the published directory will contain the configuration files alongside the entrypoint DLL, so this will work fine as well.
What you seem to be talking about is running from the bin
directory, which is not a supported thing. The bin directory is effectively a cache. It's not a published version of your application, and thus cannot be run as if it is.
answered Mar 25 at 16:33
Chris PrattChris Pratt
165k22254320
165k22254320
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332597%2fhow-does-aspnet-core-resolves-the-configuration-path%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Not 100% sure but probably using the
IHostingEnvironment Interface
theContentRootPath
property– Anton Toshik
Mar 25 at 8:07