Skip to content

Comments

Fix SingleFile regression in client configuration#42176

Merged
safern merged 3 commits intodotnet:masterfrom
am11:feature/singlefile/configurationmanager
Sep 24, 2020
Merged

Fix SingleFile regression in client configuration#42176
safern merged 3 commits intodotnet:masterfrom
am11:feature/singlefile/configurationmanager

Conversation

@am11
Copy link
Member

@am11 am11 commented Sep 13, 2020

This PR attempts to fix a 3.1 to 5.0 observable regression in ConfigurationManager APIs.

Starting with 5.0System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name in app published with PublishSingleFile=True returns <Unknown> string.
With 3.1 it returns a pseudoname: MyApp.dll with the singlefile executable with name MyApp (without .dll).

This change adjusts ClientConfigPaths implementation such that it stays compatible with 3.1 behavior.

Fixes #42161

cc @vitek-karas, @jkotas, I tested locally that it fixes the reported 3.1 -> 5.0 regression in #42161; but I am not sure if there is enough infra to exercise SingleFile publish integration test.

@am11 am11 marked this pull request as ready for review September 13, 2020 11:09
@ghost
Copy link

ghost commented Sep 13, 2020

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@ghost
Copy link

ghost commented Sep 13, 2020

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

@ghost
Copy link

ghost commented Sep 13, 2020

Tagging subscribers to this area: @safern
See info in area-owners.md if you want to be subscribed.

@am11
Copy link
Member Author

am11 commented Sep 24, 2020

ping - if there are no other comments, can this be merged?

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@safern safern merged commit efb3c91 into dotnet:master Sep 24, 2020
@safern
Copy link
Member

safern commented Sep 24, 2020

I think it might be to late to get it backported to 5.0.0 but I'll ask @ericstj and @danmosemsft

@danmoseley
Copy link
Member

We are close to "would we service for this" bar now. @ericstj ?

@ericstj
Copy link
Member

ericstj commented Sep 25, 2020

I don’t have a good read on bar for single file scenario. This change is not without risk. @agocke @jeffschwMSFT do you support this?

@agocke
Copy link
Member

agocke commented Sep 25, 2020

My initial feeling is we should not risk destablizing non-single-file scenario for the single-file scenario unless this is really critical.

So here's my question: this change was really made to support ConfigurationManager. How prevalent is that? Is this going to hit a large portion of apps within 5 minutes? Is there any workaround?

@am11 am11 deleted the feature/singlefile/configurationmanager branch September 25, 2020 07:07
@am11
Copy link
Member Author

am11 commented Sep 25, 2020

This change is not without risk.

Yes, although risk is not high. We have a good test coverage of client configuration. We just don't have tests for signlefile form factor, it was not the intentional breakage.

ConfigurationManager. How prevalent is that?

I think fair to say; not any less prevalent than [m]any other fixes being backported to 5.0.

it seems these single file regressions were not intended by this change: #40974. It happened due to lack of single file test infra and made known when the user reported in #42161.

@ericstj
Copy link
Member

ericstj commented Sep 25, 2020

I think fair to say; not any less prevalent than [m]any other fixes being backported to 5.0.

Not so. ConfigurationManager is just a .NETFramework compat assembly. We don’t reccomend it’s use for new code. It is not part of the shared framework. Question for anyone consuming this: do you actually have an end to end that works well in single file? @mshobohm can you let us know?

@ericstj
Copy link
Member

ericstj commented Sep 25, 2020

@JeremyKuhne @merriemcgaw do you think this would be important for Windows Forms apps using Single File? I know WinForms has some Settings integration that other components do not.

@mshobohm
Copy link

mshobohm commented Sep 25, 2020

For me the bug fix in 6.0 was to late, I went life with 5.0 rc1,publishsinglefile and a simple workaround:

Convert App.config to myAppname.Settings.json

using System.Text.json;
public static class xxx ...
static Dictionary<String, String> settings=null;      
        // centralized access to ConfigurationManager
        public static String AppSetting(String setting)
        {
           if (settings ==null)
            {
                var jsontext = File.ReadAllText("<myAppname>Settings.json");
                settings = JsonSerializer.Deserialize<Dictionary<String, String>>(jsontext);               
            }
            if (settings.ContainsKey(setting))
            return settings[setting];
            else
                return setting;
            //return ConfigurationManager.AppSettings[setting];
        }

ConfigurationManager (in my opinion) has 2 disadvantages:

  1. The rename step of App.config with assembyname.dll.config (lack of transparency)
  2. The rename step of ConfigurationManager.OpenExeConfiguration didn't help me with this issue.

Keep it simple keep it stupid (KISS) would be to give the (relative or Full) Path of the config file not the path of the exe-file
The main reason for the usage of PublishSingleFile was the saving of filespace.
I wonder why you cant fix it with 5.0.1 or 5.0.2 while 6.0 will arrive in November 2021 ?

@ericstj
Copy link
Member

ericstj commented Sep 25, 2020

In terms of simplicity I think your workaround approach is better for simple immutable application configuration. Another option might be Microsoft.Extensions.Configuration.

System.Configuration is a legacy API that carries the overhead of the desktop scenarios that are no longer interesting or fully supported, eg: strongly-typed configuration classes, layered machine/user/app config, XML, etc.

why you cant fix it with 5.0.1 or 5.0.2

We have a high-bar for the product right now as we approach GA, and an even higher bar in servicing. We need to justify the importance of fixes because we have to weigh the benefit of the fix over the risk of breaking other customers. It's especially important when we look at a fix in a legacy component like this, where a lot of people are using specifically because they don't/can't touch the old code that is using it. Taking it in 6.0 gives us a longer bake time to discover potential issues with the fix before it released.

@JeremyKuhne
Copy link
Member

do you think this would be important for Windows Forms apps using Single File? I know WinForms has some Settings integration that other components do not.

Yes, but I'm not clear on exactly how important. Users are definitely still using AppSettings for their ported (or hopefully soon-to-be-ported) apps and Design relies on IPersistComponentSettings. The change looks like fairly low risk to the non-single file scenario, fwiw.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Configuration.ConfigurationManager cannot read AppSettings when published with publishSingleFile=true

9 participants