-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Provide a way to override the global configuration file path #931
Comments
Note that I don't expect this to "fix" |
Came up with another major would-be porter. |
@JeremyKuhne any new info on this one ? Wondering whether we must have it for 3.0. |
Must? I don't think so, but this is painful for porting when using System.Configuration. One fundamental problem is that we don't expose While we don't have multiple public static partial class AppContext
{
// Populated with "APP_CONTEXT_CONFIGURATION_FILE" much like "APP_CONTEXT_BASE_DIRECTORY"
public static ConfigurationFile { get; }
}
public static partial class AppDomainSetup
{
// This API exists on NetFX
public static ConfigurationFile => AppContext.ConfigurationFile;
} If this was set before Putting the hooks in our side would be relatively easy as you could follow the pattern used by |
I'm not sure what is the trigger to CoreCLR's native host can already do this - in fact it will already work today via |
It is just the static constructor. As we don't use it directly, user code should be able to hit it.
What is the syntax for that? |
In the app's {
"runtimeOptions": {
"tfm": "netcoreapp3.0",
"configProperties": {
"APP_CONTEXT_CONFIGURATION_FILE": "myfile.config"
},
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.0.0"
}
}
} And then from managed code |
Do we have a customer report about what people end up doing to make this work today? It would be useful to validate that this proposal will make it significantly better. We do not have end-to-end support for the XML config files in the .NET Core tooling. Unless we fix that, the XML config file experience on .NET Core is always going somewhat worse compared to .NET Framework. This is very similar to https://github.com/dotnet/corefx/issues/36433. Both are about components that just need piece of data, and this piece of data happened to live with AppDomainSetup in .NET Framework. |
They are having to rewrite their code or copy over the shared test app.config on the box.
Yeah, I don't really expect to make this painless, there just isn't a way to do this now. Idea is MSTest can just push the I don't imagine there is a lot of code out there that needs to read the config path out of AppDomainSetup, but it wouldn't hurt to have it for any other cases that do. |
The planned workaround here is to read from `AppDomain.CurrentDomain.GetData("APP_CONTEXT_CONFIGURATION_FILE") and use that if it exists. Here is where the change needs to be made: Overiding can be done via https://github.com/dotnet/corefx/issues/32095#issuecomment-483425717 or making sure you get in and set the value on AppDomain before ConfigurationManager is first used. dotnet/corefx#36897 tracks creating an API to move this logic up to |
cc @divega This hook would help the EF6 tests. For now, we work around it with a bit of MSBuild magic: <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<None Update="App.config">
<Link>xunit.console.dll.config</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> Note, |
Moving to Future as this is not required to ship 3.0. |
We are done with porting APIs from .NET Framework. |
@jkotas Is this fixed? This issue grew into something larger than the title suggests. To me, this issue is about providing a hook (e.g. |
Ok, I have updated the title to match. |
Is there any interest in addressing this? We keep hitting it when porting from Framework, and it's kinda annoying. |
@ericsampson We have an API which is already approved here #29271 and it is up-for-grabs. When adding the implementation for it, we only need to make sure it is based on an AppContext switch as proposed in that issue so that it can be used to override the global configuration file. After that is done, we just need to update System.Configuration so that it uses this AppContext value as @JeremyKuhne mentioned here #931 (comment) Would you be interested in contributing the fix and API for this? |
.NET Framework actually used |
Will this indeed fix dotnet/project-system#7448 as well? It's not clear to me. |
No, I don't believe this will fix dotnet/project-system#7448. This issue is about allowing an app to specify a custom file location for their config file. dotnet/project-system#7448 is about the config system failing to initialize when a |
Yes, the original issue is not related, but the issue mentioned in the comment is related to this and which made me think this can fix dotnet/project-system#7448. Now i think dotnet/project-system#7448 is either non-runtime issue or might be related to #32307 |
Need to follow through how the default value gets set on .NET Framework and see if we can match. Notably, if there is a way to configure this via environment variables we should also allow doing this and update System.Configuration to pull from AppDomainSetup.ConfigurationFile.
At worst we should move the logic down from System.Configuration for generating this name.
Note that this value is settable. I believe that there is no way to get System.Configuration to reset after it does it's first load on the .NET Framework, but that should also be investigated.
The text was updated successfully, but these errors were encountered: