I need to specify path to dlls referenced by assembly in .config file. Problem is that path can be found in env. variable. Is it possible to use some sort of %DLLPATH% macro in .config file?
For Applications, including Web Applications, On Windows: If you want environmental variables to be expanded your application will need to do that itself. A common way of doing this is to use the cmd syntax %variable% and then using Environment. ExpandEnvironmentVariables to expand them.
Built-In Environments in . When checking the ASP.NET core project template, you should see that the “ASPNETCORE_ENVIRONMENT” variable with the value “Development” is set by default. Those are three values that are used by convention: Development, Staging, and Production.
Yes, that's possible! Suppose you have something like that in your config:
<configuration> <appSettings> <add key="mypath" value="%DLLPATH%\foo\bar"/> </appSettings> </configuration>
Then you can easily get the path with:
var pathFromConfig = ConfigurationManager.AppSettings["mypath"]; var expandedPath = Environment.ExpandEnvironmentVariables(pathFromConfig);
ExpandEnvironmentVariables(string s)
does the magic by replacing all environment variables within a string with their current values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With