From 798df3acbb5202b84f811cbe6a79a3cc6f3e3714 Mon Sep 17 00:00:00 2001 From: Steve Molloy Date: Mon, 2 Jul 2018 16:57:07 -0700 Subject: [PATCH 1/4] Oops. I missed a few steps when fleshing out a non-greedy KeyPerFile.GetValue(). --- samples/SampleWebApp/Web.config | 6 +++++- src/KeyPerFile/KeyPerFileConfigBuilder.cs | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/samples/SampleWebApp/Web.config b/samples/SampleWebApp/Web.config index 9ee9f48..d58e445 100644 --- a/samples/SampleWebApp/Web.config +++ b/samples/SampleWebApp/Web.config @@ -14,7 +14,7 @@ - + @@ -32,6 +32,10 @@ + + + + diff --git a/src/KeyPerFile/KeyPerFileConfigBuilder.cs b/src/KeyPerFile/KeyPerFileConfigBuilder.cs index 68a75b1..ac3d77d 100644 --- a/src/KeyPerFile/KeyPerFileConfigBuilder.cs +++ b/src/KeyPerFile/KeyPerFileConfigBuilder.cs @@ -88,10 +88,19 @@ public override ICollection> GetAllValues(string pr /// The value corresponding to the given 'key' or null if no value is found. public override string GetValue(string key) { - if (_allValues != null && _allValues.TryGetValue(key, out string val)) - return val; + string filename = key; + if (!String.IsNullOrEmpty(KeyDelimiter)) + filename = filename.Replace(KeyDelimiter, Path.DirectorySeparatorChar.ToString()); - return null; + if (!String.IsNullOrWhiteSpace(IgnorePrefix)) + { + foreach (var pathPart in filename.Split(new char[] { Path.DirectorySeparatorChar })) { + if (pathPart.StartsWith(IgnorePrefix, StringComparison.OrdinalIgnoreCase)) + return null; + } + } + + return ReadValueFromFile(Path.Combine(DirectoryPath, filename)); } private IDictionary ReadAllValues(string root, string prefix, IDictionary values) @@ -107,7 +116,7 @@ private IDictionary ReadAllValues(string root, string prefix, ID { foreach (var sub in di.EnumerateDirectories()) { - if (!String.IsNullOrWhiteSpace(IgnorePrefix) && sub.Name.StartsWith(IgnorePrefix)) + if (!String.IsNullOrWhiteSpace(IgnorePrefix) && sub.Name.StartsWith(IgnorePrefix, StringComparison.OrdinalIgnoreCase)) continue; ReadAllValues(sub.FullName, sub.Name + KeyDelimiter, values); @@ -116,7 +125,7 @@ private IDictionary ReadAllValues(string root, string prefix, ID foreach (var file in di.EnumerateFiles()) { - if (!String.IsNullOrWhiteSpace(IgnorePrefix) && file.Name.StartsWith(IgnorePrefix)) + if (!String.IsNullOrWhiteSpace(IgnorePrefix) && file.Name.StartsWith(IgnorePrefix, StringComparison.OrdinalIgnoreCase)) continue; string key = prefix + file.Name; From fb285304787b136828e96f5d3339a73d73a25047 Mon Sep 17 00:00:00 2001 From: Steve Molloy Date: Thu, 5 Jul 2018 10:10:18 -0700 Subject: [PATCH 2/4] Adding README messages to pre-existing builders to warn about possible loss of config options. --- ...uration.ConfigurationBuilders.Azure.nuproj | 3 ++ .../README.txt | 20 ++++++++++ ...n.ConfigurationBuilders.Environment.nuproj | 3 ++ .../README.txt | 20 ++++++++++ ...guration.ConfigurationBuilders.Json.nuproj | 3 ++ .../README.txt | 20 ++++++++++ ...n.ConfigurationBuilders.UserSecrets.nuproj | 3 ++ .../README.txt | 40 +++++++++++++++++++ src/packages/packages.csproj | 3 ++ 9 files changed, 115 insertions(+) create mode 100644 src/packages/ConfigurationBuilders.Azure.nupkg/README.txt create mode 100644 src/packages/ConfigurationBuilders.Environment.nupkg/README.txt create mode 100644 src/packages/ConfigurationBuilders.Json.nupkg/README.txt create mode 100644 src/packages/ConfigurationBuilders.UserSecrets.nupkg/README.txt diff --git a/src/packages/ConfigurationBuilders.Azure.nupkg/Microsoft.Configuration.ConfigurationBuilders.Azure.nuproj b/src/packages/ConfigurationBuilders.Azure.nupkg/Microsoft.Configuration.ConfigurationBuilders.Azure.nuproj index c270c05..a47d673 100644 --- a/src/packages/ConfigurationBuilders.Azure.nupkg/Microsoft.Configuration.ConfigurationBuilders.Azure.nuproj +++ b/src/packages/ConfigurationBuilders.Azure.nupkg/Microsoft.Configuration.ConfigurationBuilders.Azure.nuproj @@ -40,6 +40,9 @@ tools\Net471\ + + README.txt + \ No newline at end of file diff --git a/src/packages/ConfigurationBuilders.Azure.nupkg/README.txt b/src/packages/ConfigurationBuilders.Azure.nupkg/README.txt new file mode 100644 index 0000000..a7afe5e --- /dev/null +++ b/src/packages/ConfigurationBuilders.Azure.nupkg/README.txt @@ -0,0 +1,20 @@ +######################################################################################################################## +## ## +## Microsoft.Configuration.ConfigurationBuilders ## +## ## +######################################################################################################################## + +Hello there. Sorry to bother you. If this is the first time you are installing this configuration builder into your +project, then click the 'X' on the tab to close and continue on. + +However, if you are updating this package from a version earlier than 1.0.2... you may want to double check the +declarations for your config builders, because we might have lost any changes you made to the default declarations +that were created during the original install. + +The upgrade mechanism for nuget is actually just Uninstall/Install, and prior to 1.0.2, this package would delete +the config builder declaration that it created upon install. Makes sense. But if you made any changes to that +declaration without changing the name of it, we didn't bother to make note of that. So the 'install' phase of +updating will declare the default config builder with the default parameters again. + +Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. So you should +not be inconvenienced like this in the future. Sorry for the trouble. diff --git a/src/packages/ConfigurationBuilders.Environment.nupkg/Microsoft.Configuration.ConfigurationBuilders.Environment.nuproj b/src/packages/ConfigurationBuilders.Environment.nupkg/Microsoft.Configuration.ConfigurationBuilders.Environment.nuproj index b7449bc..2f63d4a 100644 --- a/src/packages/ConfigurationBuilders.Environment.nupkg/Microsoft.Configuration.ConfigurationBuilders.Environment.nuproj +++ b/src/packages/ConfigurationBuilders.Environment.nupkg/Microsoft.Configuration.ConfigurationBuilders.Environment.nuproj @@ -40,6 +40,9 @@ tools\Net471\ + + README.txt + \ No newline at end of file diff --git a/src/packages/ConfigurationBuilders.Environment.nupkg/README.txt b/src/packages/ConfigurationBuilders.Environment.nupkg/README.txt new file mode 100644 index 0000000..a7afe5e --- /dev/null +++ b/src/packages/ConfigurationBuilders.Environment.nupkg/README.txt @@ -0,0 +1,20 @@ +######################################################################################################################## +## ## +## Microsoft.Configuration.ConfigurationBuilders ## +## ## +######################################################################################################################## + +Hello there. Sorry to bother you. If this is the first time you are installing this configuration builder into your +project, then click the 'X' on the tab to close and continue on. + +However, if you are updating this package from a version earlier than 1.0.2... you may want to double check the +declarations for your config builders, because we might have lost any changes you made to the default declarations +that were created during the original install. + +The upgrade mechanism for nuget is actually just Uninstall/Install, and prior to 1.0.2, this package would delete +the config builder declaration that it created upon install. Makes sense. But if you made any changes to that +declaration without changing the name of it, we didn't bother to make note of that. So the 'install' phase of +updating will declare the default config builder with the default parameters again. + +Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. So you should +not be inconvenienced like this in the future. Sorry for the trouble. diff --git a/src/packages/ConfigurationBuilders.Json.nupkg/Microsoft.Configuration.ConfigurationBuilders.Json.nuproj b/src/packages/ConfigurationBuilders.Json.nupkg/Microsoft.Configuration.ConfigurationBuilders.Json.nuproj index 80a0ec0..00be497 100644 --- a/src/packages/ConfigurationBuilders.Json.nupkg/Microsoft.Configuration.ConfigurationBuilders.Json.nuproj +++ b/src/packages/ConfigurationBuilders.Json.nupkg/Microsoft.Configuration.ConfigurationBuilders.Json.nuproj @@ -40,6 +40,9 @@ tools\Net471\ + + README.txt + \ No newline at end of file diff --git a/src/packages/ConfigurationBuilders.Json.nupkg/README.txt b/src/packages/ConfigurationBuilders.Json.nupkg/README.txt new file mode 100644 index 0000000..a7afe5e --- /dev/null +++ b/src/packages/ConfigurationBuilders.Json.nupkg/README.txt @@ -0,0 +1,20 @@ +######################################################################################################################## +## ## +## Microsoft.Configuration.ConfigurationBuilders ## +## ## +######################################################################################################################## + +Hello there. Sorry to bother you. If this is the first time you are installing this configuration builder into your +project, then click the 'X' on the tab to close and continue on. + +However, if you are updating this package from a version earlier than 1.0.2... you may want to double check the +declarations for your config builders, because we might have lost any changes you made to the default declarations +that were created during the original install. + +The upgrade mechanism for nuget is actually just Uninstall/Install, and prior to 1.0.2, this package would delete +the config builder declaration that it created upon install. Makes sense. But if you made any changes to that +declaration without changing the name of it, we didn't bother to make note of that. So the 'install' phase of +updating will declare the default config builder with the default parameters again. + +Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. So you should +not be inconvenienced like this in the future. Sorry for the trouble. diff --git a/src/packages/ConfigurationBuilders.UserSecrets.nupkg/Microsoft.Configuration.ConfigurationBuilders.UserSecrets.nuproj b/src/packages/ConfigurationBuilders.UserSecrets.nupkg/Microsoft.Configuration.ConfigurationBuilders.UserSecrets.nuproj index 9442d48..61bde06 100644 --- a/src/packages/ConfigurationBuilders.UserSecrets.nupkg/Microsoft.Configuration.ConfigurationBuilders.UserSecrets.nuproj +++ b/src/packages/ConfigurationBuilders.UserSecrets.nupkg/Microsoft.Configuration.ConfigurationBuilders.UserSecrets.nuproj @@ -40,6 +40,9 @@ tools\Net471\ + + README.txt + \ No newline at end of file diff --git a/src/packages/ConfigurationBuilders.UserSecrets.nupkg/README.txt b/src/packages/ConfigurationBuilders.UserSecrets.nupkg/README.txt new file mode 100644 index 0000000..584454f --- /dev/null +++ b/src/packages/ConfigurationBuilders.UserSecrets.nupkg/README.txt @@ -0,0 +1,40 @@ +######################################################################################################################## +## ## +## Microsoft.Configuration.ConfigurationBuilders ## +## ## +######################################################################################################################## + +Hello there. Sorry to bother you. If this is the first time you are installing this configuration builder into your +project, then click the 'X' on the tab to close and continue on. + +However, if you are updating this package from a version earlier than 1.0.2... you may want to double check the +declarations for your config builders, because we might have lost any changes you made to the default declarations +that were created during the original install. + +The upgrade mechanism for nuget is actually just Uninstall/Install, and prior to 1.0.2, this package would delete +the config builder declaration that it created upon install. Makes sense. But if you made any changes to that +declaration without changing the name of it, we didn't bother to make note of that. So the 'install' phase of +updating will declare the default config builder with the default parameters again. + +Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. So you should +not be inconvenienced like this in the future. Sorry for the trouble. + + +######################################################################################################################## +## ## +## Microsoft.Configuration.ConfigurationBuilders.UserSecrets ## +## ## +######################################################################################################################## + +In addition to the upgrade trouble mentioned above, we have also made changes to the UserSecrets package specifically. +We no longer create an empty secrets file, nor do we add a link under 'Properties' to the empty secrets file that we +no longer create. And we do not install any .targets/.props files to magically read $(UserSecretsId) from project +settings at compile-time. + +Why? Because Visual Studio will handle these things for you. Similar to the ASP.Net Core User Secrets experience, VS +will have a contextual "Manage User Secrets..." option for your Web Forms projects. Using that will install this +package, create the empty secrets file, and open it for editing. So you will use that menu item instead of seeing +a project item for secrets. + +Also, the first and final word on UserSecretsId is what is set in the builder declaration. No more cumbersome +attempts at using project properties in configuration at runtime. Now, what you see (in *.config) is what you get. :) diff --git a/src/packages/packages.csproj b/src/packages/packages.csproj index e53da29..69fdd5c 100644 --- a/src/packages/packages.csproj +++ b/src/packages/packages.csproj @@ -63,6 +63,9 @@ + + + From 3f53f9f0f6973dece77fb6b512e6c923cbfe6503 Mon Sep 17 00:00:00 2001 From: Steve Molloy Date: Thu, 5 Jul 2018 10:28:54 -0700 Subject: [PATCH 3/4] Project file got missed in last commit somehow. --- src/packages/packages.csproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/packages/packages.csproj b/src/packages/packages.csproj index 69fdd5c..974f29c 100644 --- a/src/packages/packages.csproj +++ b/src/packages/packages.csproj @@ -64,7 +64,10 @@ - + + + + From d65bfb878ab3bbd3bf38ea3567fa8a9bb60796c3 Mon Sep 17 00:00:00 2001 From: Steve Molloy Date: Thu, 5 Jul 2018 17:13:47 -0700 Subject: [PATCH 4/4] Rewording readmes. --- .../README.txt | 18 +++++++++------ .../README.txt | 18 +++++++++------ .../README.txt | 18 +++++++++------ .../README.txt | 23 ++++++++++--------- 4 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/packages/ConfigurationBuilders.Azure.nupkg/README.txt b/src/packages/ConfigurationBuilders.Azure.nupkg/README.txt index a7afe5e..ee71d33 100644 --- a/src/packages/ConfigurationBuilders.Azure.nupkg/README.txt +++ b/src/packages/ConfigurationBuilders.Azure.nupkg/README.txt @@ -1,20 +1,24 @@ ######################################################################################################################## ## ## -## Microsoft.Configuration.ConfigurationBuilders ## +## Microsoft.Configuration.ConfigurationBuilders.Azure ## ## ## ######################################################################################################################## -Hello there. Sorry to bother you. If this is the first time you are installing this configuration builder into your -project, then click the 'X' on the tab to close and continue on. +WARNING: Double check config builder attributes in your configuraiton files. Some attributes may have been changed + when upgrading this package. + +If this is the first time you are installing this configuration builder into your +project, feel free to click the 'X' on this tab to close and continue on. However, if you are updating this package from a version earlier than 1.0.2... you may want to double check the -declarations for your config builders, because we might have lost any changes you made to the default declarations +declarations for your config builders, because we might have lost changes you made to the default declarations that were created during the original install. The upgrade mechanism for nuget is actually just Uninstall/Install, and prior to 1.0.2, this package would delete the config builder declaration that it created upon install. Makes sense. But if you made any changes to that declaration without changing the name of it, we didn't bother to make note of that. So the 'install' phase of -updating will declare the default config builder with the default parameters again. +updating will declare the default config builder with the default parameters again. (If you did change the name +to something other than the default - AzureKeyVault - then we did not delete your declaration when uninstalling.) -Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. So you should -not be inconvenienced like this in the future. Sorry for the trouble. +Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. Sorry for the +inconvenience. There should be no such troubles with future upgrades. diff --git a/src/packages/ConfigurationBuilders.Environment.nupkg/README.txt b/src/packages/ConfigurationBuilders.Environment.nupkg/README.txt index a7afe5e..a569858 100644 --- a/src/packages/ConfigurationBuilders.Environment.nupkg/README.txt +++ b/src/packages/ConfigurationBuilders.Environment.nupkg/README.txt @@ -1,20 +1,24 @@ ######################################################################################################################## ## ## -## Microsoft.Configuration.ConfigurationBuilders ## +## Microsoft.Configuration.ConfigurationBuilders.Environment ## ## ## ######################################################################################################################## -Hello there. Sorry to bother you. If this is the first time you are installing this configuration builder into your -project, then click the 'X' on the tab to close and continue on. +WARNING: Double check config builder attributes in your configuraiton files. Some attributes may have been changed + when upgrading this package. + +If this is the first time you are installing this configuration builder into your +project, feel free to click the 'X' on this tab to close and continue on. However, if you are updating this package from a version earlier than 1.0.2... you may want to double check the -declarations for your config builders, because we might have lost any changes you made to the default declarations +declarations for your config builders, because we might have lost changes you made to the default declarations that were created during the original install. The upgrade mechanism for nuget is actually just Uninstall/Install, and prior to 1.0.2, this package would delete the config builder declaration that it created upon install. Makes sense. But if you made any changes to that declaration without changing the name of it, we didn't bother to make note of that. So the 'install' phase of -updating will declare the default config builder with the default parameters again. +updating will declare the default config builder with the default parameters again. (If you did change the name +to something other than the default - Environment - then we did not delete your declaration when uninstalling.) -Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. So you should -not be inconvenienced like this in the future. Sorry for the trouble. +Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. Sorry for the +inconvenience. There should be no such troubles with future upgrades. diff --git a/src/packages/ConfigurationBuilders.Json.nupkg/README.txt b/src/packages/ConfigurationBuilders.Json.nupkg/README.txt index a7afe5e..5e064bc 100644 --- a/src/packages/ConfigurationBuilders.Json.nupkg/README.txt +++ b/src/packages/ConfigurationBuilders.Json.nupkg/README.txt @@ -1,20 +1,24 @@ ######################################################################################################################## ## ## -## Microsoft.Configuration.ConfigurationBuilders ## +## Microsoft.Configuration.ConfigurationBuilders.Json ## ## ## ######################################################################################################################## -Hello there. Sorry to bother you. If this is the first time you are installing this configuration builder into your -project, then click the 'X' on the tab to close and continue on. +WARNING: Double check config builder attributes in your configuraiton files. Some attributes may have been changed + when upgrading this package. + +If this is the first time you are installing this configuration builder into your +project, feel free to click the 'X' on this tab to close and continue on. However, if you are updating this package from a version earlier than 1.0.2... you may want to double check the -declarations for your config builders, because we might have lost any changes you made to the default declarations +declarations for your config builders, because we might have lost changes you made to the default declarations that were created during the original install. The upgrade mechanism for nuget is actually just Uninstall/Install, and prior to 1.0.2, this package would delete the config builder declaration that it created upon install. Makes sense. But if you made any changes to that declaration without changing the name of it, we didn't bother to make note of that. So the 'install' phase of -updating will declare the default config builder with the default parameters again. +updating will declare the default config builder with the default parameters again. (If you did change the name +to something other than the default - SimpleJson - then we did not delete your declaration when uninstalling.) -Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. So you should -not be inconvenienced like this in the future. Sorry for the trouble. +Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. Sorry for the +inconvenience. There should be no such troubles with future upgrades. diff --git a/src/packages/ConfigurationBuilders.UserSecrets.nupkg/README.txt b/src/packages/ConfigurationBuilders.UserSecrets.nupkg/README.txt index 584454f..be8572d 100644 --- a/src/packages/ConfigurationBuilders.UserSecrets.nupkg/README.txt +++ b/src/packages/ConfigurationBuilders.UserSecrets.nupkg/README.txt @@ -1,30 +1,31 @@ ######################################################################################################################## ## ## -## Microsoft.Configuration.ConfigurationBuilders ## +## Microsoft.Configuration.ConfigurationBuilders.UserSecrets ## ## ## ######################################################################################################################## -Hello there. Sorry to bother you. If this is the first time you are installing this configuration builder into your -project, then click the 'X' on the tab to close and continue on. +WARNING: Double check config builder attributes in your configuraiton files. Some attributes may have been changed + when upgrading this package. + +If this is the first time you are installing this configuration builder into your +project, feel free to click the 'X' on this tab to close and continue on. However, if you are updating this package from a version earlier than 1.0.2... you may want to double check the -declarations for your config builders, because we might have lost any changes you made to the default declarations +declarations for your config builders, because we might have lost changes you made to the default declarations that were created during the original install. The upgrade mechanism for nuget is actually just Uninstall/Install, and prior to 1.0.2, this package would delete the config builder declaration that it created upon install. Makes sense. But if you made any changes to that declaration without changing the name of it, we didn't bother to make note of that. So the 'install' phase of -updating will declare the default config builder with the default parameters again. +updating will declare the default config builder with the default parameters again. (If you did change the name +to something other than the default - Secrets - then we did not delete your declaration when uninstalling.) -Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. So you should -not be inconvenienced like this in the future. Sorry for the trouble. +Starting in version 1.0.2, we have a way to stash old declarations aside and restore them upon install. Sorry for the +inconvenience. There should be no such troubles with future upgrades. ######################################################################################################################## -## ## -## Microsoft.Configuration.ConfigurationBuilders.UserSecrets ## -## ## -######################################################################################################################## + In addition to the upgrade trouble mentioned above, we have also made changes to the UserSecrets package specifically. We no longer create an empty secrets file, nor do we add a link under 'Properties' to the empty secrets file that we