Skip to content

Commit c6d719a

Browse files
authored
Merge pull request #2 from aspnet/1.0-preview2
1.0 preview2
2 parents 83bba83 + fc57780 commit c6d719a

178 files changed

Lines changed: 596 additions & 28089 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Bb]in/
2+
[Oo]bj/
3+
src/**/[Bb]in/
4+
src/**/[Oo]bj/
5+
test/**/[Bb]in/
6+
test/**/[Oo]bj/
7+
.vs/
8+
msbuild.*
9+
/packages/
10+
samples/SampleWebApp/bin/
11+
samples/SampleWebApp/obj/

CONTRIBUTING.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# How to contribute
2+
3+
One of the easiest ways to contribute is to participate in discussions and discuss issues. You can also contribute by submitting pull requests with code changes.
4+
5+
## General feedback and discussions?
6+
Please start a discussion on the [Home repo issue tracker](https://github.com/aspnet/MicrosoftConfigurationBuilders/issues).
7+
8+
## Bugs and feature requests?
9+
For non-security related bugs please log a new issue on the [Home repo issue tracker](https://github.com/aspnet/MicrosoftConfigurationBuilders/issues).
10+
11+
## Reporting security issues and bugs
12+
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/ff852094.aspx).
13+
14+
## Filing issues
15+
When filing issues, please use our [bug filing templates](https://github.com/aspnet/MicrosoftConfigurationBuilders/wiki/Functional-bug-template).
16+
The best way to get your bug fixed is to be as detailed as you can be about the problem.
17+
Providing a minimal project with steps to reproduce the problem is ideal.
18+
Here are questions you can answer before you file a bug to make sure you're not missing any important information.
19+
20+
1. Did you read the [documentation](https://github.com/aspnet/MicrosoftConfigurationBuilders/wiki)?
21+
2. Did you include the snippet of broken code in the issue?
22+
3. What are the *EXACT* steps to reproduce this problem?
23+
4. What version Powershell are you using?
24+
5. What version of VS (including update version) are you using?
25+
26+
GitHub supports [markdown](https://help.github.com/articles/github-flavored-markdown/), so when filing bugs make sure you check the formatting before clicking submit.

LICENSE.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ASP.NET Configuration Builders
2+
3+
Copyright (c) Microsoft Corporation
4+
All rights reserved.
5+
6+
MIT License
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MicrosoftConfigurationBuilders.msbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
<ItemGroup Condition="'$(BuildCoreOnly)' != 'true'">
1313
<AssemblyProject Include="test\Microsoft.Configuration.ConfigurationBuilders.Test\Test\Test.csproj" />
14+
<AssemblyProject Include="samples\SampleWebApp\SampleWebApp.csproj" />
1415
</ItemGroup>
1516

1617
<ItemGroup>

MicrosoftConfigurationBuilders.sln

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27018.1
4+
VisualStudioVersion = 15.0.27130.2036
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure", "src\Azure\Azure.csproj", "{345C5437-4990-45DC-BE34-6E37AA05D8D2}"
77
ProjectSection(ProjectDependencies) = postProject
@@ -38,33 +38,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
3838
EndProject
3939
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{2F759F48-7F89-4811-8F94-380BCCC83C69}"
4040
EndProject
41-
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "ConfigBuildersSample", "samples\ConfigBuildersSample\ConfigBuildersSample\", "{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}"
42-
ProjectSection(WebsiteProperties) = preProject
43-
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.7.1"
44-
ProjectReferences = "{f382fbf8-146d-4968-a199-90d37f9ef9a7}|Microsoft.Configuration.ConfigurationBuilders.Base.dll;{84e0ce5d-4af2-414f-a940-22b3f93fc727}|Microsoft.Configuration.ConfigurationBuilders.Json.dll;{c60d6cbb-d513-4692-81a6-0be5d45e4702}|Microsoft.Configuration.ConfigurationBuilders.UserSecrets.dll;{c6530e81-d8d8-47a8-912e-d2939f801835}|Microsoft.Configuration.ConfigurationBuilders.Environment.dll;"
45-
Debug.AspNetCompiler.VirtualPath = "/localhost_57833"
46-
Debug.AspNetCompiler.PhysicalPath = "samples\ConfigBuildersSample\ConfigBuildersSample\"
47-
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_57833\"
48-
Debug.AspNetCompiler.Updateable = "true"
49-
Debug.AspNetCompiler.ForceOverwrite = "true"
50-
Debug.AspNetCompiler.FixedNames = "false"
51-
Debug.AspNetCompiler.Debug = "True"
52-
Release.AspNetCompiler.VirtualPath = "/localhost_57833"
53-
Release.AspNetCompiler.PhysicalPath = "samples\ConfigBuildersSample\ConfigBuildersSample\"
54-
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_57833\"
55-
Release.AspNetCompiler.Updateable = "true"
56-
Release.AspNetCompiler.ForceOverwrite = "true"
57-
Release.AspNetCompiler.FixedNames = "false"
58-
Release.AspNetCompiler.Debug = "False"
59-
VWDPort = "57833"
60-
SlnRelativePath = "samples\ConfigBuildersSample\ConfigBuildersSample\"
61-
DefaultWebSiteLanguage = "Visual C#"
62-
EndProjectSection
63-
ProjectSection(ProjectDependencies) = postProject
64-
{C6530E81-D8D8-47A8-912E-D2939F801835} = {C6530E81-D8D8-47A8-912E-D2939F801835}
65-
{C60D6CBB-D513-4692-81A6-0BE5D45E4702} = {C60D6CBB-D513-4692-81A6-0BE5D45E4702}
66-
EndProjectSection
67-
EndProject
6841
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Base", "src\Base\Base.csproj", "{F382FBF8-146D-4968-A199-90D37F9EF9A7}"
6942
EndProject
7043
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserSecrets", "src\UserSecrets\UserSecrets.csproj", "{C60D6CBB-D513-4692-81A6-0BE5D45E4702}"
@@ -77,6 +50,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Environment", "src\Environm
7750
{F382FBF8-146D-4968-A199-90D37F9EF9A7} = {F382FBF8-146D-4968-A199-90D37F9EF9A7}
7851
EndProjectSection
7952
EndProject
53+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApp", "samples\SampleWebApp\SampleWebApp.csproj", "{590892DD-F842-4E7C-9400-4C6451C16B1A}"
54+
EndProject
8055
Global
8156
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8257
Debug|Any CPU = Debug|Any CPU
@@ -99,10 +74,6 @@ Global
9974
{9371A23F-BCB8-4429-8652-0A12D43F14F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
10075
{9371A23F-BCB8-4429-8652-0A12D43F14F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
10176
{9371A23F-BCB8-4429-8652-0A12D43F14F3}.Release|Any CPU.Build.0 = Release|Any CPU
102-
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
103-
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
104-
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}.Release|Any CPU.ActiveCfg = Debug|Any CPU
105-
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE}.Release|Any CPU.Build.0 = Debug|Any CPU
10677
{F382FBF8-146D-4968-A199-90D37F9EF9A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10778
{F382FBF8-146D-4968-A199-90D37F9EF9A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
10879
{F382FBF8-146D-4968-A199-90D37F9EF9A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -115,12 +86,16 @@ Global
11586
{C6530E81-D8D8-47A8-912E-D2939F801835}.Debug|Any CPU.Build.0 = Debug|Any CPU
11687
{C6530E81-D8D8-47A8-912E-D2939F801835}.Release|Any CPU.ActiveCfg = Release|Any CPU
11788
{C6530E81-D8D8-47A8-912E-D2939F801835}.Release|Any CPU.Build.0 = Release|Any CPU
89+
{590892DD-F842-4E7C-9400-4C6451C16B1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
90+
{590892DD-F842-4E7C-9400-4C6451C16B1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
91+
{590892DD-F842-4E7C-9400-4C6451C16B1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
92+
{590892DD-F842-4E7C-9400-4C6451C16B1A}.Release|Any CPU.Build.0 = Release|Any CPU
11893
EndGlobalSection
11994
GlobalSection(SolutionProperties) = preSolution
12095
HideSolutionNode = FALSE
12196
EndGlobalSection
12297
GlobalSection(NestedProjects) = preSolution
123-
{B6D1F37C-41CD-4809-A7F0-AD10EBFDC6CE} = {2F759F48-7F89-4811-8F94-380BCCC83C69}
98+
{590892DD-F842-4E7C-9400-4C6451C16B1A} = {2F759F48-7F89-4811-8F94-380BCCC83C69}
12499
EndGlobalSection
125100
GlobalSection(ExtensibilityGlobals) = postSolution
126101
SolutionGuid = {6380A53F-A088-4D0B-B415-C8D16222F022}

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuration Builders
22

3-
Configuration Builders are a new feature of the full .Net Framework, introduced in .Net 4.7.1. You can read about the concept in [this blog post](http://www.msdn.com).
3+
Configuration Builders are a new feature of the full .Net Framework, introduced in .Net 4.7.1. You can read about the concept in [this blog post](http://jeffreyfritz.com/2017/11/modern-configuration-for-asp-net-4-7-1-with-configurationbuilders/).
44
With this project, Microsoft is providing a basic set of Configuration Builders that should make it easy for developers to get started with the new feature. They
55
are also intended to address some of the basic needs of applications as they move into a container and cloud focused environment.
66

@@ -59,48 +59,51 @@ This is the simplest of the config builders. It draws its values from Environmen
5959
```xml
6060
<add name="UserSecrets"
6161
[mode|prefix|stripPrefix]
62-
(userSecretId="12345678-90AB-CDEF-1234-567890" | userSecretFile="~\secrets.file")
63-
[ignoreMissingFile="true"]
62+
(userSecretsId="12345678-90AB-CDEF-1234-567890" | userSecretsFile="~\secrets.file")
63+
[optional="true"]
6464
type="Microsoft.Configuration.ConfigurationBuilders.UserSecretsConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.UserSecrets" />
6565
```
66-
To enable a feature similar to .Net Core's user secrets you can use this config builder. Microsoft is considering future plans to better integrate secret management
67-
into Visual Studio, and full-framework projects would use this config builder. In order to keep external dependencies out of the picture, the actual secret file will
68-
be xml formatted. (If you need to share a secrets.json file with Core projects, you could consider using the `SimpleJsonConfigBuilder` below.)
66+
To enable a feature similar to .Net Core's user secrets you can use this config builder. Microsoft is adding better secrets management in future releases
67+
of Visual Studio, and this config builder will be a part of that plan. Web Applications are the initial target for this work in Visual Studio, but this
68+
configuration builder can be used in any full-framework project if you specify your own secrets file. (Or define the 'UserSecretsId' property in your
69+
project file and create the raw secrets file in the correct location for reading.) In order to keep external dependencies out of the picture, the
70+
actual secret file will be xml formatted - though this should be considered an implementation detail, and the format should not be relied upon.
71+
(If you need to share a secrets.json file with Core projects, you could consider using the `SimpleJsonConfigBuilder` below... but as with this
72+
builder, the json format for Core secrets is technically an implementation detail subject to change as well.)
6973

7074
There are three additional configuration attributes for this config builder:
7175
* `userSecretsId` - This is the preferred method for identifying an xml secrets file. It works similar to .Net Core, which uses a 'UserSecretsId' project
7276
property to store this identifier. (The string does not have to be a Guid. Just unique. The VS "Manage User Secrets" experience produces a Guid.) With this
73-
attribute, the `UserSecretsConfigBuilder` will look in a well-known local location for a secrets file belonging to this identifier. One of this attribute or
74-
the 'userSecretsFile' attribute is required.
77+
attribute, the `UserSecretsConfigBuilder` will look in a well-known local location for a secrets file belonging to this identifier. In MSBuild environments,
78+
the value of this attribute will be replaced with the project property $(UserSecretsId) in the output directory iff the initial value is '${UserSecretsId}'.
79+
One of this attribute or the 'userSecretsFile' attribute is required.
7580
* `userSecretsFile` - An optional attribute specifying the file containing the secrets. The '~' character can be used at the start to reference the app root.
7681
One of this attribute or the 'userSecretsId' attribute is required. If both are specified, 'userSecretsFile' takes precedence.
77-
* `ignoreMissingFile` - A simple boolean to avoid throwing exceptions if the secrets file cannot be found. The default is `true`.
82+
* `optional` - A simple boolean to avoid throwing exceptions if the secrets file cannot be found. The default is `true`.
7883

7984
### AzureKeyVaultConfigBuilder
8085
```xml
8186
<add name="AzureKeyVault"
8287
[mode|prefix|stripPrefix]
8388
(vaultName="MyVaultName" |
8489
uri="https://MyVaultName.vault.azure.net")
85-
[clientId="12345678-9012-3456-7890-123456789012"
86-
clientSecret="8eNKl240FSfhgY909unhg23DKNj3b2cOO8bVvd+wdCc="]
90+
[connectionString="connection string"]
8791
type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure" />
8892
```
89-
If your secrets are kept in Azure Key Vault, then this config builder is for you. There are four additional attributes for this config builder. The `vaultName` is
93+
If your secrets are kept in Azure Key Vault, then this config builder is for you. There are three additional attributes for this config builder. The `vaultName` is
9094
required. The other attributes allow you some manual control about which vault to connect to, but are only necessary if the application is not running in an
91-
environment that works well with `Microsoft.Azure.Services.AppAuthentication`. Otherwise, the Azure Services Authentication library is used to automatically pick
92-
up connection information from the execution environment.
95+
environment that works magically with `Microsoft.Azure.Services.AppAuthentication`. The Azure Services Authentication library is used to automatically pick
96+
up connection information from the execution environment if possible, but you can override that feature by providing a connection string instead.
9397
* `vaultName` - This is a required attribute. It specifies the name of the vault in your Azure subscription from which to read key/value pairs.
94-
* `clientId` - This is the Azure Active Directory App Id. A string representation of a GUID.
95-
* `clientSecret` - This is the Azure Active Directory App Key. A string.
98+
* `connectionString` - A connection string usable by [AzureServiceTokenProvider](https://docs.microsoft.com/en-us/azure/key-vault/service-to-service-authentication#connection-string-support)
9699
* `uri` - Connect to other Key Vault providers with this attribute. If not specified, Azure is the assumed Vault provider. If the uri _is_specified, then `vaultName` is no longer a required parameter.
97100

98101
### SimpleJsonConfigBuilder
99102
```xml
100103
<add name="SimpleJson"
101104
[mode|prefix|stripPrefix]
102105
jsonFile="~\config.json"
103-
[ignoreMissingFile="true"]
106+
[optional="true"]
104107
[jsonMode="(Flat|Sectional)"]
105108
type="Microsoft.Configuration.ConfigurationBuilders.SimpleJsonConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Json" />
106109
```
@@ -113,7 +116,7 @@ begins with 'Simple.' Think of the backing json file as a simple dictionary, rat
113116

114117
There are three additional attributes that can be used to configure this builder:
115118
* `jsonFile` - A required attribute specifying the json file to draw from. The '~' character can be used at the start to reference the app root.
116-
* `ignoreMissingFile` - A simple boolean to avoid throwing exceptions if the secrets file cannot be found. The default is `true`.
119+
* `optional` - A simple boolean to avoid throwing exceptions if the json file cannot be found. The default is `true`.
117120
* `jsonMode` - `[Flat|Sectional]`. 'Flat' is the default.
118121
- This attribute requires a little more explanation. It says above to think of the json file as a single flat key/value source. This is the usual that applies to other key/value config builders like `EnvironmentConfigBuilder` and `AzureKeyVaultConfigBuilder` because those sources provide no other option. If the `SimpleJsonConfigBuilder` is configured in 'Sectional' mode, then the json file is conceptually divided just at the top level into multiple simple dictionaries. Each one of those dictionaries will only be applied to the config section that matches the top-level property name attached to them. For example:
119122
```json
@@ -158,7 +161,6 @@ public class CustomConfigBuilder : KeyValueConfigBuilder
158161
```
159162

160163
## Blog Posts
161-
[Insert](sldfj)
162-
[Blog Posts](sldkfjs)
163-
[And References](sldkfj)
164-
[Here](lskdjf)
164+
[.Net Framework 4.7.1 ASP.NET and Configuration features](https://blogs.msdn.microsoft.com/dotnet/2017/09/13/net-framework-4-7-1-asp-net-and-configuration-features/)
165+
[Modern Configuration for ASP.NET 4.7.1 with ConfigurationBuilders](http://jeffreyfritz.com/2017/11/modern-configuration-for-asp-net-4-7-1-with-configurationbuilders/)
166+
[Service-to-service authentication to Azure Key Vault using .NET](https://docs.microsoft.com/en-us/azure/key-vault/service-to-service-authentication#connection-string-support)

build.cmd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
@ECHO OFF
22

33
setlocal
4+
set EnableNuGetPackageRestore=true
45

56
REM msbuild will compile in Debug mode by default. The nuget packages project is Release by default.
67
REM Long story short... be explicit. Don't use defaults.
7-
REM set cfgOption=/p:Configuration=Release
8-
set cfgOption=/p:Configuration=Debug
8+
set cfgOption=/p:Configuration=Release
9+
REM set cfgOption=/p:Configuration=Debug
910
REM set cfgOption=/p:Configuration=Debug;Release
1011

1112
set logOptions=/flp:Summary;Verbosity=diag;LogFile=msbuild.log /flp1:warningsonly;logfile=msbuild.wrn /flp2:errorsonly;logfile=msbuild.err

0 commit comments

Comments
 (0)