├── .appveyor.yml ├── .gitattributes ├── .gitignore ├── .travis.yml ├── .vsts-pipelines └── builds │ ├── ci-internal.yml │ └── ci-public.yml ├── CONTRIBUTING.md ├── Directory.Build.props ├── Directory.Build.targets ├── LICENSE.txt ├── MetaPackages.sln ├── NuGet.config ├── NuGetPackageVerifier.json ├── README.md ├── build.cmd ├── build.sh ├── build ├── Key.snk ├── dependencies.props ├── repo.props └── sources.props ├── korebuild-lock.txt ├── korebuild.json ├── run.cmd ├── run.ps1 ├── run.sh ├── samples └── SampleApp │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── SampleApp.csproj │ ├── Startup.cs │ ├── appsettings.json │ └── wwwroot │ └── htmlpage.html ├── src ├── Directory.Build.props └── Microsoft.AspNetCore │ ├── GenericHostBuilderExtensions.cs │ ├── HostFilteringStartupFilter.cs │ ├── Microsoft.AspNetCore.csproj │ ├── WebHost.cs │ └── baseline.netcore.json ├── test ├── Directory.Build.props ├── Microsoft.AspNetCore.FunctionalTests │ ├── Microsoft.AspNetCore.FunctionalTests.csproj │ ├── WebHostFunctionalTests.cs │ └── testCert.pfx ├── Microsoft.AspNetCore.Tests │ ├── Microsoft.AspNetCore.Tests.csproj │ └── WebHostTests.cs └── TestSites │ ├── CreateDefaultBuilderApp │ ├── CreateDefaultBuilderApp.csproj │ ├── Program.cs │ ├── appsettings.Development.json │ └── appsettings.json │ ├── CreateDefaultBuilderOfTApp │ ├── CreateDefaultBuilderOfTApp.csproj │ ├── Program.cs │ ├── appsettings.Development.json │ └── appsettings.json │ ├── DependencyInjectionApp │ ├── DependencyInjectionApp.csproj │ └── Program.cs │ ├── StartRequestDelegateUrlApp │ ├── Program.cs │ └── StartRequestDelegateUrlApp.csproj │ ├── StartRouteBuilderUrlApp │ ├── Program.cs │ └── StartRouteBuilderUrlApp.csproj │ └── StartWithIApplicationBuilderUrlApp │ ├── Program.cs │ └── StartWithIApplicationBuilderUrlApp.csproj └── version.props /.appveyor.yml: -------------------------------------------------------------------------------- 1 | init: 2 | - git config --global core.autocrlf true 3 | branches: 4 | only: 5 | - master 6 | - /^release\/.*$/ 7 | - /^(.*\/)?ci-.*$/ 8 | build_script: 9 | - ps: .\run.ps1 default-build 10 | clone_depth: 1 11 | environment: 12 | global: 13 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 14 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 15 | test: 'off' 16 | deploy: 'off' 17 | os: Visual Studio 2017 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.doc diff=astextplain 2 | *.DOC diff=astextplain 3 | *.docx diff=astextplain 4 | *.DOCX diff=astextplain 5 | *.dot diff=astextplain 6 | *.DOT diff=astextplain 7 | *.pdf diff=astextplain 8 | *.PDF diff=astextplain 9 | *.rtf diff=astextplain 10 | *.RTF diff=astextplain 11 | 12 | *.jpg binary 13 | *.png binary 14 | *.gif binary 15 | 16 | *.cs text=auto diff=csharp 17 | *.vb text=auto 18 | *.resx text=auto 19 | *.c text=auto 20 | *.cpp text=auto 21 | *.cxx text=auto 22 | *.h text=auto 23 | *.hxx text=auto 24 | *.py text=auto 25 | *.rb text=auto 26 | *.java text=auto 27 | *.html text=auto 28 | *.htm text=auto 29 | *.css text=auto 30 | *.scss text=auto 31 | *.sass text=auto 32 | *.less text=auto 33 | *.js text=auto 34 | *.lisp text=auto 35 | *.clj text=auto 36 | *.sql text=auto 37 | *.php text=auto 38 | *.lua text=auto 39 | *.m text=auto 40 | *.asm text=auto 41 | *.erl text=auto 42 | *.fs text=auto 43 | *.fsx text=auto 44 | *.hs text=auto 45 | 46 | *.csproj text=auto 47 | *.vbproj text=auto 48 | *.fsproj text=auto 49 | *.dbproj text=auto 50 | *.sln text=auto eol=crlf 51 | 52 | *.sh eol=lf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Oo]bj/ 2 | [Bb]in/ 3 | TestResults/ 4 | .nuget/ 5 | _ReSharper.*/ 6 | packages/ 7 | artifacts/ 8 | PublishProfiles/ 9 | *.user 10 | *.suo 11 | *.cache 12 | *.docstates 13 | _ReSharper.* 14 | nuget.exe 15 | *net45.csproj 16 | *net451.csproj 17 | *k10.csproj 18 | *.psess 19 | *.vsp 20 | *.pidb 21 | *.userprefs 22 | *DS_Store 23 | *.ncrunchsolution 24 | *.*sdf 25 | *.ipch 26 | *.sln.ide 27 | project.lock.json 28 | .vs 29 | .vscode/ 30 | .build/ 31 | .testPublish/ 32 | global.json 33 | 34 | # Dependencies from pre-requisite builds 35 | .deps/ 36 | .rw/ 37 | .ro/ 38 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | sudo: false 3 | dist: trusty 4 | env: 5 | global: 6 | - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 7 | - DOTNET_CLI_TELEMETRY_OPTOUT: 1 8 | mono: none 9 | os: 10 | - linux 11 | - osx 12 | osx_image: xcode8.2 13 | addons: 14 | apt: 15 | packages: 16 | - libunwind8 17 | branches: 18 | only: 19 | - master 20 | - /^release\/.*$/ 21 | - /^(.*\/)?ci-.*$/ 22 | before_install: 23 | - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s 24 | /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib 25 | /usr/local/lib/; fi 26 | script: 27 | - ./build.sh 28 | -------------------------------------------------------------------------------- /.vsts-pipelines/builds/ci-internal.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - master 3 | - release/* 4 | 5 | resources: 6 | repositories: 7 | - repository: buildtools 8 | type: git 9 | name: aspnet-BuildTools 10 | ref: refs/heads/master 11 | 12 | phases: 13 | - template: .vsts-pipelines/templates/project-ci.yml@buildtools 14 | -------------------------------------------------------------------------------- /.vsts-pipelines/builds/ci-public.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - master 3 | - release/* 4 | 5 | # See https://github.com/aspnet/BuildTools 6 | resources: 7 | repositories: 8 | - repository: buildtools 9 | type: github 10 | endpoint: DotNet-Bot GitHub Connection 11 | name: aspnet/BuildTools 12 | ref: refs/heads/master 13 | 14 | phases: 15 | - template: .vsts-pipelines/templates/project-ci.yml@buildtools 16 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ====== 3 | 4 | Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo. 5 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Microsoft ASP.NET Core 12 | https://github.com/aspnet/MetaPackages 13 | git 14 | $(MSBuildThisFileDirectory) 15 | false 16 | $(MSBuildThisFileDirectory)build\Key.snk 17 | true 18 | true 19 | 20 | 21 | -------------------------------------------------------------------------------- /Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(MicrosoftNETCoreAppPackageVersion) 4 | $(NETStandardLibrary20PackageVersion) 5 | 6 | 7 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright (c) .NET Foundation and Contributors 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MetaPackages.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 15 3 | VisualStudioVersion = 15.0.27005.2 4 | MinimumVisualStudioVersion = 15.0.26730.03 5 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" 6 | ProjectSection(SolutionItems) = preProject 7 | src\Directory.Build.props = src\Directory.Build.props 8 | EndProjectSection 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97D53BEB-A511-4FBE-B784-AB407D9A219F}" 13 | ProjectSection(SolutionItems) = preProject 14 | Directory.Build.props = Directory.Build.props 15 | Directory.Build.targets = Directory.Build.targets 16 | NuGet.config = NuGet.config 17 | version.xml = version.xml 18 | EndProjectSection 19 | EndProject 20 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1-C38E-408C-A7EC-A5C040D041E1}" 21 | ProjectSection(SolutionItems) = preProject 22 | build\dependencies.props = build\dependencies.props 23 | build\repo.targets = build\repo.targets 24 | EndProjectSection 25 | EndProject 26 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F583C-C4CA-43E5-B31C-D21B7806E274}" 27 | EndProject 28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" 29 | EndProject 30 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}" 31 | EndProject 32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.FunctionalTests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}" 33 | EndProject 34 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestSites", "TestSites", "{EC22261D-0DE1-47DE-8F7C-072675D6F5B4}" 35 | EndProject 36 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRouteBuilderUrlApp", "test\TestSites\StartRouteBuilderUrlApp\StartRouteBuilderUrlApp.csproj", "{AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}" 37 | EndProject 38 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartWithIApplicationBuilderUrlApp", "test\TestSites\StartWithIApplicationBuilderUrlApp\StartWithIApplicationBuilderUrlApp.csproj", "{3A85FA52-F601-422E-A42E-9F187DB28492}" 39 | EndProject 40 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRequestDelegateUrlApp", "test\TestSites\StartRequestDelegateUrlApp\StartRequestDelegateUrlApp.csproj", "{401C741B-6C7C-4E08-9F09-C3D43D22C0DE}" 41 | EndProject 42 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateDefaultBuilderApp", "test\TestSites\CreateDefaultBuilderApp\CreateDefaultBuilderApp.csproj", "{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}" 43 | EndProject 44 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" 45 | EndProject 46 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateDefaultBuilderOfTApp", "test\TestSites\CreateDefaultBuilderOfTApp\CreateDefaultBuilderOfTApp.csproj", "{A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}" 47 | EndProject 48 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Tests", "test\Microsoft.AspNetCore.Tests\Microsoft.AspNetCore.Tests.csproj", "{BD08F027-3BB9-427B-9367-19534B7376B3}" 49 | EndProject 50 | Global 51 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 52 | Debug|Any CPU = Debug|Any CPU 53 | Release|Any CPU = Release|Any CPU 54 | EndGlobalSection 55 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 56 | {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 57 | {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Debug|Any CPU.Build.0 = Debug|Any CPU 58 | {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 61 | {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU 62 | {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU 63 | {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU 64 | {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Release|Any CPU.ActiveCfg = Release|Any CPU 67 | {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Release|Any CPU.Build.0 = Release|Any CPU 68 | {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 69 | {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Debug|Any CPU.Build.0 = Debug|Any CPU 70 | {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Release|Any CPU.ActiveCfg = Release|Any CPU 71 | {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Release|Any CPU.Build.0 = Release|Any CPU 72 | {3A85FA52-F601-422E-A42E-9F187DB28492}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 73 | {3A85FA52-F601-422E-A42E-9F187DB28492}.Debug|Any CPU.Build.0 = Debug|Any CPU 74 | {3A85FA52-F601-422E-A42E-9F187DB28492}.Release|Any CPU.ActiveCfg = Release|Any CPU 75 | {3A85FA52-F601-422E-A42E-9F187DB28492}.Release|Any CPU.Build.0 = Release|Any CPU 76 | {401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 77 | {401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Debug|Any CPU.Build.0 = Debug|Any CPU 78 | {401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Release|Any CPU.ActiveCfg = Release|Any CPU 79 | {401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Release|Any CPU.Build.0 = Release|Any CPU 80 | {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 81 | {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.Build.0 = Debug|Any CPU 82 | {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.ActiveCfg = Release|Any CPU 83 | {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.Build.0 = Release|Any CPU 84 | {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 85 | {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU 86 | {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU 87 | {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.Build.0 = Release|Any CPU 88 | {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 89 | {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU 90 | {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU 91 | {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Release|Any CPU.Build.0 = Release|Any CPU 92 | {BD08F027-3BB9-427B-9367-19534B7376B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 93 | {BD08F027-3BB9-427B-9367-19534B7376B3}.Debug|Any CPU.Build.0 = Debug|Any CPU 94 | {BD08F027-3BB9-427B-9367-19534B7376B3}.Release|Any CPU.ActiveCfg = Release|Any CPU 95 | {BD08F027-3BB9-427B-9367-19534B7376B3}.Release|Any CPU.Build.0 = Release|Any CPU 96 | EndGlobalSection 97 | GlobalSection(SolutionProperties) = preSolution 98 | HideSolutionNode = FALSE 99 | EndGlobalSection 100 | GlobalSection(NestedProjects) = preSolution 101 | {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} 102 | {AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274} 103 | {C72A756A-D29D-44C7-83D4-821DBE82DBCA} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} 104 | {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} 105 | {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} 106 | {3A85FA52-F601-422E-A42E-9F187DB28492} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} 107 | {401C741B-6C7C-4E08-9F09-C3D43D22C0DE} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} 108 | {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} 109 | {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} 110 | {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} 111 | {BD08F027-3BB9-427B-9367-19534B7376B3} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} 112 | EndGlobalSection 113 | GlobalSection(ExtensibilityGlobals) = postSolution 114 | SolutionGuid = {A666E9B0-125B-4975-B35B-09A6D68A5047} 115 | EndGlobalSection 116 | EndGlobal 117 | -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NuGetPackageVerifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "Default": { 3 | "rules": [ 4 | "DefaultCompositeRule" 5 | ] 6 | } 7 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Meta Packages [Archived] 2 | ======================== 3 | 4 | **This GitHub project has been archived.** Ongoing development on this project can be found in https://github.com/aspnet/AspNetCore. 5 | 6 | This repo contains NuGet meta packages that help quickly reference sets of common packages. 7 | 8 | This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [AspNetCore](https://github.com/aspnet/AspNetCore) repo. 9 | 10 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" 3 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | # Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) 7 | chmod +x "$DIR/run.sh"; sync 8 | "$DIR/run.sh" default-build "$@" 9 | -------------------------------------------------------------------------------- /build/Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet/MetaPackages/d417aacd7c0eff202f7860fe1e686aa5beeedad7/build/Key.snk -------------------------------------------------------------------------------- /build/dependencies.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 4 | 5 | 6 | 3.0.0-alpha1-20181004.7 7 | 3.0.0-alpha1-10733 8 | 3.0.0-alpha1-10733 9 | 3.0.0-alpha1-10733 10 | 3.0.0-alpha1-10733 11 | 3.0.0-alpha1-10733 12 | 3.0.0-alpha1-10733 13 | 3.0.0-alpha1-10733 14 | 3.0.0-alpha1-10733 15 | 3.0.0-alpha1-10733 16 | 0.7.0-alpha1-10733 17 | 3.0.0-alpha1-10733 18 | 3.0.0-alpha1-10733 19 | 3.0.0-alpha1-10733 20 | 3.0.0-preview-181108-06 21 | 3.0.0-preview-181108-06 22 | 3.0.0-preview-181108-06 23 | 3.0.0-preview-181108-06 24 | 3.0.0-preview-181108-06 25 | 3.0.0-preview-181108-06 26 | 3.0.0-preview-181108-06 27 | 3.0.0-preview-181108-06 28 | 3.0.0-preview-181108-06 29 | 3.0.0-preview-181108-06 30 | 3.0.0-alpha1-10733 31 | 2.0.9 32 | 2.1.3 33 | 2.2.0-rtm-27105-02 34 | 15.6.1 35 | 4.10.0 36 | 2.0.3 37 | 2.3.1 38 | 2.4.0 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /build/repo.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Internal.AspNetCore.Universe.Lineup 7 | https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /build/sources.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $(DotNetRestoreSources) 6 | 7 | $(RestoreSources); 8 | https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; 9 | https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; 10 | https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; 11 | 12 | 13 | $(RestoreSources); 14 | https://api.nuget.org/v3/index.json; 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /korebuild-lock.txt: -------------------------------------------------------------------------------- 1 | version:3.0.0-build-20181114.5 2 | commithash:880e9a204d4ee4a18dfd83c9fb05a192a28bca60 3 | -------------------------------------------------------------------------------- /korebuild.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", 3 | "channel": "master" 4 | } 5 | -------------------------------------------------------------------------------- /run.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" 3 | -------------------------------------------------------------------------------- /run.ps1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env powershell 2 | #requires -version 4 3 | 4 | <# 5 | .SYNOPSIS 6 | Executes KoreBuild commands. 7 | 8 | .DESCRIPTION 9 | Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. 10 | 11 | .PARAMETER Command 12 | The KoreBuild command to run. 13 | 14 | .PARAMETER Path 15 | The folder to build. Defaults to the folder containing this script. 16 | 17 | .PARAMETER Channel 18 | The channel of KoreBuild to download. Overrides the value from the config file. 19 | 20 | .PARAMETER DotNetHome 21 | The directory where .NET Core tools will be stored. 22 | 23 | .PARAMETER ToolsSource 24 | The base url where build tools can be downloaded. Overrides the value from the config file. 25 | 26 | .PARAMETER Update 27 | Updates KoreBuild to the latest version even if a lock file is present. 28 | 29 | .PARAMETER Reinstall 30 | Re-installs KoreBuild 31 | 32 | .PARAMETER ConfigFile 33 | The path to the configuration file that stores values. Defaults to korebuild.json. 34 | 35 | .PARAMETER ToolsSourceSuffix 36 | The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. 37 | 38 | .PARAMETER CI 39 | Sets up CI specific settings and variables. 40 | 41 | .PARAMETER Arguments 42 | Arguments to be passed to the command 43 | 44 | .NOTES 45 | This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. 46 | When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. 47 | 48 | The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set 49 | in the file are overridden by command line parameters. 50 | 51 | .EXAMPLE 52 | Example config file: 53 | ```json 54 | { 55 | "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", 56 | "channel": "master", 57 | "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" 58 | } 59 | ``` 60 | #> 61 | [CmdletBinding(PositionalBinding = $false)] 62 | param( 63 | [Parameter(Mandatory = $true, Position = 0)] 64 | [string]$Command, 65 | [string]$Path = $PSScriptRoot, 66 | [Alias('c')] 67 | [string]$Channel, 68 | [Alias('d')] 69 | [string]$DotNetHome, 70 | [Alias('s')] 71 | [string]$ToolsSource, 72 | [Alias('u')] 73 | [switch]$Update, 74 | [switch]$Reinstall, 75 | [string]$ToolsSourceSuffix, 76 | [string]$ConfigFile = $null, 77 | [switch]$CI, 78 | [Parameter(ValueFromRemainingArguments = $true)] 79 | [string[]]$Arguments 80 | ) 81 | 82 | Set-StrictMode -Version 2 83 | $ErrorActionPreference = 'Stop' 84 | 85 | # 86 | # Functions 87 | # 88 | 89 | function Get-KoreBuild { 90 | 91 | $lockFile = Join-Path $Path 'korebuild-lock.txt' 92 | 93 | if (!(Test-Path $lockFile) -or $Update) { 94 | Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix 95 | } 96 | 97 | $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 98 | if (!$version) { 99 | Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" 100 | } 101 | $version = $version.TrimStart('version:').Trim() 102 | $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) 103 | 104 | if ($Reinstall -and (Test-Path $korebuildPath)) { 105 | Remove-Item -Force -Recurse $korebuildPath 106 | } 107 | 108 | if (!(Test-Path $korebuildPath)) { 109 | Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" 110 | New-Item -ItemType Directory -Path $korebuildPath | Out-Null 111 | $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" 112 | 113 | try { 114 | $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" 115 | Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix 116 | if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) { 117 | # Use built-in commands where possible as they are cross-plat compatible 118 | Microsoft.PowerShell.Archive\Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath 119 | } 120 | else { 121 | # Fallback to old approach for old installations of PowerShell 122 | Add-Type -AssemblyName System.IO.Compression.FileSystem 123 | [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) 124 | } 125 | } 126 | catch { 127 | Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore 128 | throw 129 | } 130 | finally { 131 | Remove-Item $tmpfile -ErrorAction Ignore 132 | } 133 | } 134 | 135 | return $korebuildPath 136 | } 137 | 138 | function Join-Paths([string]$path, [string[]]$childPaths) { 139 | $childPaths | ForEach-Object { $path = Join-Path $path $_ } 140 | return $path 141 | } 142 | 143 | function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { 144 | if ($RemotePath -notlike 'http*') { 145 | Copy-Item $RemotePath $LocalPath 146 | return 147 | } 148 | 149 | $retries = 10 150 | while ($retries -gt 0) { 151 | $retries -= 1 152 | try { 153 | Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath 154 | return 155 | } 156 | catch { 157 | Write-Verbose "Request failed. $retries retries remaining" 158 | } 159 | } 160 | 161 | Write-Error "Download failed: '$RemotePath'." 162 | } 163 | 164 | # 165 | # Main 166 | # 167 | 168 | # Load configuration or set defaults 169 | 170 | $Path = Resolve-Path $Path 171 | if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } 172 | 173 | if (Test-Path $ConfigFile) { 174 | try { 175 | $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json 176 | if ($config) { 177 | if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } 178 | if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} 179 | } 180 | } 181 | catch { 182 | Write-Host -ForegroundColor Red $Error[0] 183 | Write-Error "$ConfigFile contains invalid JSON." 184 | exit 1 185 | } 186 | } 187 | 188 | if (!$DotNetHome) { 189 | $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` 190 | elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` 191 | elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` 192 | else { Join-Path $PSScriptRoot '.dotnet'} 193 | } 194 | 195 | if (!$Channel) { $Channel = 'master' } 196 | if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } 197 | 198 | # Execute 199 | 200 | $korebuildPath = Get-KoreBuild 201 | Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') 202 | 203 | try { 204 | Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI 205 | Invoke-KoreBuildCommand $Command @Arguments 206 | } 207 | finally { 208 | Remove-Module 'KoreBuild' -ErrorAction Ignore 209 | } 210 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # 6 | # variables 7 | # 8 | 9 | RESET="\033[0m" 10 | RED="\033[0;31m" 11 | YELLOW="\033[0;33m" 12 | MAGENTA="\033[0;95m" 13 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 14 | [ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" 15 | verbose=false 16 | update=false 17 | reinstall=false 18 | repo_path="$DIR" 19 | channel='' 20 | tools_source='' 21 | tools_source_suffix='' 22 | ci=false 23 | 24 | # 25 | # Functions 26 | # 27 | __usage() { 28 | echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" 29 | echo "" 30 | echo "Arguments:" 31 | echo " command The command to be run." 32 | echo " ... Arguments passed to the command. Variable number of arguments allowed." 33 | echo "" 34 | echo "Options:" 35 | echo " --verbose Show verbose output." 36 | echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." 37 | echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." 38 | echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." 39 | echo " --path The directory to build. Defaults to the directory containing the script." 40 | echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." 41 | echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." 42 | echo " -u|--update Update to the latest KoreBuild even if the lock file is present." 43 | echo " --reinstall Reinstall KoreBuild." 44 | echo " --ci Apply CI specific settings and environment variables." 45 | echo "" 46 | echo "Description:" 47 | echo " This function will create a file \$DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be." 48 | echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." 49 | 50 | if [[ "${1:-}" != '--no-exit' ]]; then 51 | exit 2 52 | fi 53 | } 54 | 55 | get_korebuild() { 56 | local version 57 | local lock_file="$repo_path/korebuild-lock.txt" 58 | if [ ! -f "$lock_file" ] || [ "$update" = true ]; then 59 | __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" 60 | fi 61 | version="$(grep 'version:*' -m 1 "$lock_file")" 62 | if [[ "$version" == '' ]]; then 63 | __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" 64 | return 1 65 | fi 66 | version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" 67 | local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" 68 | 69 | if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then 70 | rm -rf "$korebuild_path" 71 | fi 72 | 73 | { 74 | if [ ! -d "$korebuild_path" ]; then 75 | mkdir -p "$korebuild_path" 76 | local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" 77 | tmpfile="$(mktemp)" 78 | echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" 79 | if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then 80 | unzip -q -d "$korebuild_path" "$tmpfile" 81 | fi 82 | rm "$tmpfile" || true 83 | fi 84 | 85 | source "$korebuild_path/KoreBuild.sh" 86 | } || { 87 | if [ -d "$korebuild_path" ]; then 88 | echo "Cleaning up after failed installation" 89 | rm -rf "$korebuild_path" || true 90 | fi 91 | return 1 92 | } 93 | } 94 | 95 | __error() { 96 | echo -e "${RED}error: $*${RESET}" 1>&2 97 | } 98 | 99 | __warn() { 100 | echo -e "${YELLOW}warning: $*${RESET}" 101 | } 102 | 103 | __machine_has() { 104 | hash "$1" > /dev/null 2>&1 105 | return $? 106 | } 107 | 108 | __get_remote_file() { 109 | local remote_path=$1 110 | local local_path=$2 111 | local remote_path_suffix=$3 112 | 113 | if [[ "$remote_path" != 'http'* ]]; then 114 | cp "$remote_path" "$local_path" 115 | return 0 116 | fi 117 | 118 | local failed=false 119 | if __machine_has wget; then 120 | wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true 121 | else 122 | failed=true 123 | fi 124 | 125 | if [ "$failed" = true ] && __machine_has curl; then 126 | failed=false 127 | curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true 128 | fi 129 | 130 | if [ "$failed" = true ]; then 131 | __error "Download failed: $remote_path" 1>&2 132 | return 1 133 | fi 134 | } 135 | 136 | # 137 | # main 138 | # 139 | 140 | command="${1:-}" 141 | shift 142 | 143 | while [[ $# -gt 0 ]]; do 144 | case $1 in 145 | -\?|-h|--help) 146 | __usage --no-exit 147 | exit 0 148 | ;; 149 | -c|--channel|-Channel) 150 | shift 151 | channel="${1:-}" 152 | [ -z "$channel" ] && __usage 153 | ;; 154 | --config-file|-ConfigFile) 155 | shift 156 | config_file="${1:-}" 157 | [ -z "$config_file" ] && __usage 158 | if [ ! -f "$config_file" ]; then 159 | __error "Invalid value for --config-file. $config_file does not exist." 160 | exit 1 161 | fi 162 | ;; 163 | -d|--dotnet-home|-DotNetHome) 164 | shift 165 | DOTNET_HOME="${1:-}" 166 | [ -z "$DOTNET_HOME" ] && __usage 167 | ;; 168 | --path|-Path) 169 | shift 170 | repo_path="${1:-}" 171 | [ -z "$repo_path" ] && __usage 172 | ;; 173 | -s|--tools-source|-ToolsSource) 174 | shift 175 | tools_source="${1:-}" 176 | [ -z "$tools_source" ] && __usage 177 | ;; 178 | --tools-source-suffix|-ToolsSourceSuffix) 179 | shift 180 | tools_source_suffix="${1:-}" 181 | [ -z "$tools_source_suffix" ] && __usage 182 | ;; 183 | -u|--update|-Update) 184 | update=true 185 | ;; 186 | --reinstall|-[Rr]einstall) 187 | reinstall=true 188 | ;; 189 | --ci|-[Cc][Ii]) 190 | ci=true 191 | ;; 192 | --verbose|-Verbose) 193 | verbose=true 194 | ;; 195 | --) 196 | shift 197 | break 198 | ;; 199 | *) 200 | break 201 | ;; 202 | esac 203 | shift 204 | done 205 | 206 | if ! __machine_has unzip; then 207 | __error 'Missing required command: unzip' 208 | exit 1 209 | fi 210 | 211 | if ! __machine_has curl && ! __machine_has wget; then 212 | __error 'Missing required command. Either wget or curl is required.' 213 | exit 1 214 | fi 215 | 216 | [ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" 217 | if [ -f "$config_file" ]; then 218 | if __machine_has jq ; then 219 | if jq '.' "$config_file" >/dev/null ; then 220 | config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" 221 | config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" 222 | else 223 | __error "$config_file contains invalid JSON." 224 | exit 1 225 | fi 226 | elif __machine_has python ; then 227 | if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then 228 | config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" 229 | config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" 230 | else 231 | __error "$config_file contains invalid JSON." 232 | exit 1 233 | fi 234 | elif __machine_has python3 ; then 235 | if python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then 236 | config_channel="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")" 237 | config_tools_source="$(python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")" 238 | else 239 | __error "$config_file contains invalid JSON." 240 | exit 1 241 | fi 242 | else 243 | __error 'Missing required command: jq or python. Could not parse the JSON file.' 244 | exit 1 245 | fi 246 | 247 | [ ! -z "${config_channel:-}" ] && channel="$config_channel" 248 | [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" 249 | fi 250 | 251 | [ -z "$channel" ] && channel='master' 252 | [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' 253 | 254 | get_korebuild 255 | set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" 256 | invoke_korebuild_command "$command" "$@" 257 | -------------------------------------------------------------------------------- /samples/SampleApp/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.AspNetCore; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.AspNetCore.Routing; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.Hosting; 12 | 13 | namespace SampleApp 14 | { 15 | public class Program 16 | { 17 | public static void Main(string[] args) 18 | { 19 | HelloWorld(); 20 | 21 | CustomUrl(); 22 | 23 | CustomRouter(); 24 | 25 | CustomApplicationBuilder(); 26 | 27 | StartupClass(args); 28 | 29 | HostBuilderWithWebHost(args); 30 | } 31 | 32 | private static void HelloWorld() 33 | { 34 | using (WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) 35 | { 36 | //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 37 | Console.WriteLine("Running HelloWorld: Press any key to shutdown and start the next sample..."); 38 | Console.ReadKey(); 39 | } 40 | } 41 | 42 | private static void CustomUrl() 43 | { 44 | // Changing the listening URL 45 | using (WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!"))) 46 | { 47 | //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 48 | Console.WriteLine("Running CustomUrl: Press any key to shutdown and start the next sample..."); 49 | Console.ReadKey(); 50 | } 51 | } 52 | 53 | private static void CustomRouter() 54 | { 55 | // Using a router 56 | using (WebHost.Start(router => router 57 | .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}")) 58 | .MapGet("goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}")) 59 | .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) 60 | .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}")) 61 | .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")))) 62 | { 63 | //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 64 | Console.WriteLine("Running CustomRouter: Press any key to shutdown and start the next sample..."); 65 | Console.ReadKey(); 66 | } 67 | } 68 | 69 | private static void CustomApplicationBuilder() 70 | { 71 | // Using a application builder 72 | using (WebHost.StartWith(app => 73 | { 74 | app.UseStaticFiles(); 75 | app.Run(async context => 76 | { 77 | await context.Response.WriteAsync("Hello, World!"); 78 | }); 79 | })) 80 | { 81 | //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 82 | Console.WriteLine("Running CustomApplicationBuilder: Press any key to shutdown and start the next sample..."); 83 | Console.ReadKey(); 84 | } 85 | } 86 | 87 | private static void StartupClass(string[] args) 88 | { 89 | // Using defaults with a Startup class 90 | using (var host = WebHost.CreateDefaultBuilder(args) 91 | .UseStartup() 92 | .Build()) 93 | { 94 | host.Run(); 95 | } 96 | } 97 | 98 | private static void HostBuilderWithWebHost(string[] args) 99 | { 100 | var host = new HostBuilder() 101 | .ConfigureAppConfiguration(config => 102 | { 103 | config.AddCommandLine(args); 104 | }) 105 | .ConfigureWebHostDefaults(builder => 106 | { 107 | builder.UseStartup(); 108 | }) 109 | .Build(); 110 | 111 | host.Run(); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /samples/SampleApp/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:53432/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "SampleApp": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:53433" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/SampleApp/SampleApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0 5 | aspnetcore-MetaPackagesSampleApp-20170406180413 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /samples/SampleApp/Startup.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Builder; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.Extensions.DependencyInjection; 8 | 9 | namespace SampleApp 10 | { 11 | public class Startup 12 | { 13 | public void ConfigureServices(IServiceCollection services) 14 | { 15 | 16 | } 17 | 18 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 19 | { 20 | app.Run(async (context) => 21 | { 22 | await context.Response.WriteAsync($"Hello from {nameof(Startup)}!"); 23 | }); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /samples/SampleApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "AllowedHosts": "example.com;localhost", 3 | "Kestrel": { 4 | "EndPoints": { 5 | "Http": { 6 | "Url": "http://localhost:5005" 7 | } 8 | 9 | // To enable HTTPS using a certificate file, set the path to a .pfx file in 10 | // the "Path" property below and configure the password in user secrets. 11 | // The "Password" property should be set in user secrets. 12 | //"HttpsInlineCertFile": { 13 | // "Url": "http://localhost:5005" 14 | // "Certificate": { 15 | // "Path": "", 16 | // "Password: "" 17 | // } 18 | //}, 19 | 20 | //"HttpsInlineCertStore": { 21 | // "Url": "http://localhost:5005" 22 | // "Certificate": { 23 | // "Subject": "", 24 | // "Store": "", 25 | // "Location": "", 26 | // "AllowInvalid": "" // Set to "true" to allow invalid certificates (e.g. expired) 27 | // } 28 | //}, 29 | 30 | // This uses the cert defined under Certificates/Default or the development cert. 31 | //"HttpsDefaultCert": { 32 | // "Url": "http://localhost:5005" 33 | //} 34 | } 35 | }, 36 | "Certificates": { 37 | //"Default": { 38 | // "Path": "", 39 | // "Password": "" 40 | //}, 41 | 42 | // From cert store: 43 | //"Default": { 44 | // "Subject": "", 45 | // "Store": "", 46 | // "Location": "", 47 | // "AllowInvalid": "" // Set to "true" to allow invalid certificates (e.g. expired certificates) 48 | //} 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /samples/SampleApp/wwwroot/htmlpage.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | A static HTML file. 11 | 12 | -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore/GenericHostBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore; 4 | 5 | namespace Microsoft.Extensions.Hosting 6 | { 7 | /// 8 | /// Extension methods for configuring the IWebHostBuilder. 9 | /// 10 | public static class GenericHostBuilderExtensions 11 | { 12 | /// 13 | /// Initializes a new instance of the class with pre-configured defaults. 14 | /// 15 | /// 16 | /// The following defaults are applied to the : 17 | /// use Kestrel as the web server and configure it using the application's configuration providers, 18 | /// and enable IIS integration. 19 | /// 20 | /// The instance to configure 21 | /// The configure callback 22 | /// 23 | public static IHostBuilder ConfigureWebHostDefaults(this IHostBuilder builder, Action configure) 24 | { 25 | return builder.ConfigureWebHost(webHostBuilder => 26 | { 27 | WebHost.ConfigureWebDefaults(webHostBuilder); 28 | 29 | configure(webHostBuilder); 30 | }); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | 8 | namespace Microsoft.AspNetCore 9 | { 10 | internal class HostFilteringStartupFilter : IStartupFilter 11 | { 12 | public Action Configure(Action next) 13 | { 14 | return app => 15 | { 16 | app.UseHostFiltering(); 17 | next(app); 18 | }; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netcoreapp3.0 5 | aspnetcore 6 | Microsoft.AspNetCore 7 | true 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore/WebHost.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.IO; 6 | using System.Reflection; 7 | using Microsoft.AspNetCore.Builder; 8 | using Microsoft.AspNetCore.HostFiltering; 9 | using Microsoft.AspNetCore.Hosting; 10 | using Microsoft.AspNetCore.Http; 11 | using Microsoft.AspNetCore.Routing; 12 | using Microsoft.Extensions.Configuration; 13 | using Microsoft.Extensions.DependencyInjection; 14 | using Microsoft.Extensions.Logging; 15 | using Microsoft.Extensions.Options; 16 | 17 | namespace Microsoft.AspNetCore 18 | { 19 | /// 20 | /// Provides convenience methods for creating instances of and with pre-configured defaults. 21 | /// 22 | public static class WebHost 23 | { 24 | /// 25 | /// Initializes and starts a new with pre-configured defaults. 26 | /// See for details. 27 | /// 28 | /// A delegate that handles requests to the application. 29 | /// A started that hosts the application. 30 | public static IWebHost Start(RequestDelegate app) => 31 | Start(url: null, app: app); 32 | 33 | /// 34 | /// Initializes and starts a new with pre-configured defaults. 35 | /// See for details. 36 | /// 37 | /// The URL the hosted application will listen on. 38 | /// A delegate that handles requests to the application. 39 | /// A started that hosts the application. 40 | public static IWebHost Start(string url, RequestDelegate app) 41 | { 42 | var startupAssemblyName = app.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name; 43 | return StartWith(url: url, configureServices: null, app: appBuilder => appBuilder.Run(app), applicationName: startupAssemblyName); 44 | } 45 | 46 | /// 47 | /// Initializes and starts a new with pre-configured defaults. 48 | /// See for details. 49 | /// 50 | /// A delegate that configures the router for handling requests to the application. 51 | /// A started that hosts the application. 52 | public static IWebHost Start(Action routeBuilder) => 53 | Start(url: null, routeBuilder: routeBuilder); 54 | 55 | /// 56 | /// Initializes and starts a new with pre-configured defaults. 57 | /// See for details. 58 | /// 59 | /// The URL the hosted application will listen on. 60 | /// A delegate that configures the router for handling requests to the application. 61 | /// A started that hosts the application. 62 | public static IWebHost Start(string url, Action routeBuilder) 63 | { 64 | var startupAssemblyName = routeBuilder.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name; 65 | return StartWith(url, services => services.AddRouting(), appBuilder => appBuilder.UseRouter(routeBuilder), applicationName: startupAssemblyName); 66 | } 67 | 68 | /// 69 | /// Initializes and starts a new with pre-configured defaults. 70 | /// See for details. 71 | /// 72 | /// The delegate that configures the . 73 | /// A started that hosts the application. 74 | public static IWebHost StartWith(Action app) => 75 | StartWith(url: null, app: app); 76 | 77 | /// 78 | /// Initializes and starts a new with pre-configured defaults. 79 | /// See for details. 80 | /// 81 | /// The URL the hosted application will listen on. 82 | /// The delegate that configures the . 83 | /// A started that hosts the application. 84 | public static IWebHost StartWith(string url, Action app) => 85 | StartWith(url: url, configureServices: null, app: app, applicationName: null); 86 | 87 | private static IWebHost StartWith(string url, Action configureServices, Action app, string applicationName) 88 | { 89 | var builder = CreateDefaultBuilder(); 90 | 91 | if (!string.IsNullOrEmpty(url)) 92 | { 93 | builder.UseUrls(url); 94 | } 95 | 96 | if (configureServices != null) 97 | { 98 | builder.ConfigureServices(configureServices); 99 | } 100 | 101 | builder.Configure(app); 102 | 103 | if (!string.IsNullOrEmpty(applicationName)) 104 | { 105 | builder.UseSetting(WebHostDefaults.ApplicationKey, applicationName); 106 | } 107 | 108 | var host = builder.Build(); 109 | 110 | host.Start(); 111 | 112 | return host; 113 | } 114 | 115 | /// 116 | /// Initializes a new instance of the class with pre-configured defaults. 117 | /// 118 | /// 119 | /// The following defaults are applied to the returned : 120 | /// use Kestrel as the web server and configure it using the application's configuration providers, 121 | /// set the to the result of , 122 | /// load from 'appsettings.json' and 'appsettings.[].json', 123 | /// load from User Secrets when is 'Development' using the entry assembly, 124 | /// load from environment variables, 125 | /// configure the to log to the console and debug output, 126 | /// and enable IIS integration. 127 | /// 128 | /// The initialized . 129 | public static IWebHostBuilder CreateDefaultBuilder() => 130 | CreateDefaultBuilder(args: null); 131 | 132 | /// 133 | /// Initializes a new instance of the class with pre-configured defaults. 134 | /// 135 | /// 136 | /// The following defaults are applied to the returned : 137 | /// use Kestrel as the web server and configure it using the application's configuration providers, 138 | /// set the to the result of , 139 | /// load from 'appsettings.json' and 'appsettings.[].json', 140 | /// load from User Secrets when is 'Development' using the entry assembly, 141 | /// load from environment variables, 142 | /// load from supplied command line args, 143 | /// configure the to log to the console and debug output, 144 | /// and enable IIS integration. 145 | /// 146 | /// The command line args. 147 | /// The initialized . 148 | public static IWebHostBuilder CreateDefaultBuilder(string[] args) 149 | { 150 | var builder = new WebHostBuilder(); 151 | 152 | if (string.IsNullOrEmpty(builder.GetSetting(WebHostDefaults.ContentRootKey))) 153 | { 154 | builder.UseContentRoot(Directory.GetCurrentDirectory()); 155 | } 156 | if (args != null) 157 | { 158 | builder.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build()); 159 | } 160 | 161 | builder.ConfigureAppConfiguration((hostingContext, config) => 162 | { 163 | var env = hostingContext.HostingEnvironment; 164 | 165 | config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) 166 | .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); 167 | 168 | if (env.IsDevelopment()) 169 | { 170 | var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName)); 171 | if (appAssembly != null) 172 | { 173 | config.AddUserSecrets(appAssembly, optional: true); 174 | } 175 | } 176 | 177 | config.AddEnvironmentVariables(); 178 | 179 | if (args != null) 180 | { 181 | config.AddCommandLine(args); 182 | } 183 | }) 184 | .ConfigureLogging((hostingContext, logging) => 185 | { 186 | logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); 187 | logging.AddConsole(); 188 | logging.AddDebug(); 189 | logging.AddEventSourceLogger(); 190 | }). 191 | UseDefaultServiceProvider((context, options) => 192 | { 193 | options.ValidateScopes = context.HostingEnvironment.IsDevelopment(); 194 | }); 195 | 196 | ConfigureWebDefaults(builder); 197 | 198 | return builder; 199 | } 200 | 201 | internal static void ConfigureWebDefaults(IWebHostBuilder builder) 202 | { 203 | builder.UseKestrel((builderContext, options) => 204 | { 205 | options.Configure(builderContext.Configuration.GetSection("Kestrel")); 206 | }) 207 | .ConfigureServices((hostingContext, services) => 208 | { 209 | // Fallback 210 | services.PostConfigure(options => 211 | { 212 | if (options.AllowedHosts == null || options.AllowedHosts.Count == 0) 213 | { 214 | // "AllowedHosts": "localhost;127.0.0.1;[::1]" 215 | var hosts = hostingContext.Configuration["AllowedHosts"]?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); 216 | // Fall back to "*" to disable. 217 | options.AllowedHosts = (hosts?.Length > 0 ? hosts : new[] { "*" }); 218 | } 219 | }); 220 | // Change notification 221 | services.AddSingleton>( 222 | new ConfigurationChangeTokenSource(hostingContext.Configuration)); 223 | 224 | services.AddTransient(); 225 | }) 226 | .UseIIS() 227 | .UseIISIntegration(); 228 | } 229 | 230 | /// 231 | /// Initializes a new instance of the class with pre-configured defaults using typed Startup. 232 | /// 233 | /// 234 | /// The following defaults are applied to the returned : 235 | /// use Kestrel as the web server and configure it using the application's configuration providers, 236 | /// set the to the result of , 237 | /// load from 'appsettings.json' and 'appsettings.[].json', 238 | /// load from User Secrets when is 'Development' using the entry assembly, 239 | /// load from environment variables, 240 | /// load from supplied command line args, 241 | /// configure the to log to the console and debug output, 242 | /// enable IIS integration. 243 | /// 244 | /// The type containing the startup methods for the application. 245 | /// The command line args. 246 | /// The initialized . 247 | public static IWebHostBuilder CreateDefaultBuilder(string[] args) where TStartup : class => 248 | CreateDefaultBuilder(args).UseStartup(); 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /src/Microsoft.AspNetCore/baseline.netcore.json: -------------------------------------------------------------------------------- 1 | { 2 | "AssemblyIdentity": "Microsoft.AspNetCore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", 3 | "Types": [ 4 | { 5 | "Name": "Microsoft.AspNetCore.WebHost", 6 | "Visibility": "Public", 7 | "Kind": "Class", 8 | "Abstract": true, 9 | "Static": true, 10 | "Sealed": true, 11 | "ImplementedInterfaces": [], 12 | "Members": [ 13 | { 14 | "Kind": "Method", 15 | "Name": "Start", 16 | "Parameters": [ 17 | { 18 | "Name": "app", 19 | "Type": "Microsoft.AspNetCore.Http.RequestDelegate" 20 | } 21 | ], 22 | "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", 23 | "Static": true, 24 | "Visibility": "Public", 25 | "GenericParameter": [] 26 | }, 27 | { 28 | "Kind": "Method", 29 | "Name": "Start", 30 | "Parameters": [ 31 | { 32 | "Name": "url", 33 | "Type": "System.String" 34 | }, 35 | { 36 | "Name": "app", 37 | "Type": "Microsoft.AspNetCore.Http.RequestDelegate" 38 | } 39 | ], 40 | "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", 41 | "Static": true, 42 | "Visibility": "Public", 43 | "GenericParameter": [] 44 | }, 45 | { 46 | "Kind": "Method", 47 | "Name": "Start", 48 | "Parameters": [ 49 | { 50 | "Name": "routeBuilder", 51 | "Type": "System.Action" 52 | } 53 | ], 54 | "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", 55 | "Static": true, 56 | "Visibility": "Public", 57 | "GenericParameter": [] 58 | }, 59 | { 60 | "Kind": "Method", 61 | "Name": "Start", 62 | "Parameters": [ 63 | { 64 | "Name": "url", 65 | "Type": "System.String" 66 | }, 67 | { 68 | "Name": "routeBuilder", 69 | "Type": "System.Action" 70 | } 71 | ], 72 | "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", 73 | "Static": true, 74 | "Visibility": "Public", 75 | "GenericParameter": [] 76 | }, 77 | { 78 | "Kind": "Method", 79 | "Name": "StartWith", 80 | "Parameters": [ 81 | { 82 | "Name": "app", 83 | "Type": "System.Action" 84 | } 85 | ], 86 | "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", 87 | "Static": true, 88 | "Visibility": "Public", 89 | "GenericParameter": [] 90 | }, 91 | { 92 | "Kind": "Method", 93 | "Name": "StartWith", 94 | "Parameters": [ 95 | { 96 | "Name": "url", 97 | "Type": "System.String" 98 | }, 99 | { 100 | "Name": "app", 101 | "Type": "System.Action" 102 | } 103 | ], 104 | "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", 105 | "Static": true, 106 | "Visibility": "Public", 107 | "GenericParameter": [] 108 | }, 109 | { 110 | "Kind": "Method", 111 | "Name": "CreateDefaultBuilder", 112 | "Parameters": [], 113 | "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHostBuilder", 114 | "Static": true, 115 | "Visibility": "Public", 116 | "GenericParameter": [] 117 | }, 118 | { 119 | "Kind": "Method", 120 | "Name": "CreateDefaultBuilder", 121 | "Parameters": [ 122 | { 123 | "Name": "args", 124 | "Type": "System.String[]" 125 | } 126 | ], 127 | "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHostBuilder", 128 | "Static": true, 129 | "Visibility": "Public", 130 | "GenericParameter": [] 131 | } 132 | ], 133 | "GenericParameters": [] 134 | } 135 | ] 136 | } -------------------------------------------------------------------------------- /test/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Net.Http; 8 | using System.Threading.Tasks; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.AspNetCore.Server.IntegrationTesting; 11 | using Microsoft.AspNetCore.Testing.xunit; 12 | using Microsoft.Extensions.Logging; 13 | using Microsoft.Extensions.Logging.Testing; 14 | using Xunit; 15 | using Xunit.Sdk; 16 | 17 | namespace Microsoft.AspNetCore.Tests 18 | { 19 | public class WebHostFunctionalTests : LoggedTest 20 | { 21 | [Fact] 22 | public async Task Start_RequestDelegate_Url() 23 | { 24 | await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync(string.Empty), "StartRequestDelegateUrlApp"); 25 | } 26 | 27 | [Fact] 28 | public async Task Start_RouteBuilder_Url() 29 | { 30 | await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync("/route"), "StartRouteBuilderUrlApp"); 31 | } 32 | 33 | [Fact] 34 | public async Task StartWith_IApplicationBuilder_Url() 35 | { 36 | await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync(string.Empty), "StartWithIApplicationBuilderUrlApp"); 37 | } 38 | 39 | [Fact] 40 | public async Task CreateDefaultBuilder_InitializeWithDefaults() 41 | { 42 | var applicationName = "CreateDefaultBuilderApp"; 43 | await ExecuteTestApp(applicationName, async (deploymentResult, logger) => 44 | { 45 | var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken, retryCount: 5); 46 | 47 | var responseText = await response.Content.ReadAsStringAsync(); 48 | try 49 | { 50 | // Assert server is Kestrel 51 | Assert.Equal("Kestrel", response.Headers.Server.ToString()); 52 | // The application name will be sent in response when all asserts succeed in the test app. 53 | Assert.Equal(applicationName, responseText); 54 | } 55 | catch (XunitException) 56 | { 57 | logger.LogWarning(response.ToString()); 58 | logger.LogWarning(responseText); 59 | throw; 60 | } 61 | }, setTestEnvVars: true); 62 | } 63 | 64 | [Fact] 65 | public async Task CreateDefaultBuilderOfT_InitializeWithDefaults() 66 | { 67 | var applicationName = "CreateDefaultBuilderOfTApp"; 68 | await ExecuteTestApp(applicationName, async (deploymentResult, logger) => 69 | { 70 | var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken, retryCount: 5); 71 | 72 | var responseText = await response.Content.ReadAsStringAsync(); 73 | try 74 | { 75 | // Assert server is Kestrel 76 | Assert.Equal("Kestrel", response.Headers.Server.ToString()); 77 | // The application name will be sent in response when all asserts succeed in the test app. 78 | Assert.Equal(applicationName, responseText); 79 | } 80 | catch (XunitException) 81 | { 82 | logger.LogWarning(response.ToString()); 83 | logger.LogWarning(responseText); 84 | throw; 85 | } 86 | }, setTestEnvVars: true); 87 | } 88 | 89 | [Theory] 90 | [InlineData("Development", "InvalidOperationException: Cannot consume scoped service")] 91 | [InlineData("Production", "Success")] 92 | public async Task CreateDefaultBuilder_InitializesDependencyInjectionSettingsBasedOnEnv(string environment, string expected) 93 | { 94 | var applicationName = "DependencyInjectionApp"; 95 | await ExecuteTestApp(applicationName, async (deploymentResult, logger) => 96 | { 97 | var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); 98 | var responseText = await response.Content.ReadAsStringAsync(); 99 | try 100 | { 101 | // Assert UseDeveloperExceptionPage is called in WebHostStartupFilter. 102 | Assert.Contains(expected, responseText); 103 | } 104 | catch (XunitException) 105 | { 106 | logger.LogWarning(response.ToString()); 107 | logger.LogWarning(responseText); 108 | throw; 109 | } 110 | }, setTestEnvVars: true, environment: environment); 111 | } 112 | 113 | [Fact] 114 | public void LoggingConfigurationSectionPassedToLoggerByDefault() 115 | { 116 | try 117 | { 118 | File.WriteAllText("appsettings.json", @" 119 | { 120 | ""Logging"": { 121 | ""LogLevel"": { 122 | ""Default"": ""Warning"" 123 | } 124 | } 125 | } 126 | "); 127 | using (var webHost = WebHost.Start("http://127.0.0.1:0", context => context.Response.WriteAsync("Hello, World!"))) 128 | { 129 | var factory = (ILoggerFactory)webHost.Services.GetService(typeof(ILoggerFactory)); 130 | var logger = factory.CreateLogger("Test"); 131 | 132 | logger.Log(LogLevel.Information, 0, "Message", null, (s, e) => 133 | { 134 | Assert.True(false); 135 | return string.Empty; 136 | }); 137 | 138 | var logWritten = false; 139 | logger.Log(LogLevel.Warning, 0, "Message", null, (s, e) => 140 | { 141 | logWritten = true; 142 | return string.Empty; 143 | }); 144 | 145 | Assert.True(logWritten); 146 | } 147 | } 148 | finally 149 | { 150 | File.Delete("appsettings.json"); 151 | } 152 | } 153 | 154 | [ConditionalFact] 155 | [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] 156 | public async Task RunsInIISExpressInProcess() 157 | { 158 | var applicationName = "CreateDefaultBuilderApp"; 159 | var deploymentParameters = new DeploymentParameters(Path.Combine(GetTestSitesPath(), applicationName), ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) 160 | { 161 | TargetFramework = "netcoreapp3.0", 162 | HostingModel = HostingModel.InProcess, 163 | AncmVersion = AncmVersion.AspNetCoreModuleV2 164 | }; 165 | 166 | SetEnvironmentVariables(deploymentParameters, "Development"); 167 | 168 | using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory)) 169 | { 170 | var deploymentResult = await deployer.DeployAsync(); 171 | var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), Logger, deploymentResult.HostShutdownToken, retryCount: 5); 172 | 173 | var responseText = await response.Content.ReadAsStringAsync(); 174 | try 175 | { 176 | // Assert server is IISExpress 177 | Assert.Equal("Microsoft-IIS/10.0", response.Headers.Server.ToString()); 178 | // The application name will be sent in response when all asserts succeed in the test app. 179 | Assert.Equal(applicationName, responseText); 180 | } 181 | catch (XunitException) 182 | { 183 | Logger.LogWarning(response.ToString()); 184 | Logger.LogWarning(responseText); 185 | throw; 186 | } 187 | } 188 | } 189 | 190 | private async Task ExecuteStartOrStartWithTest(Func> getResponse, string applicationName) 191 | { 192 | await ExecuteTestApp(applicationName, async (deploymentResult, logger) => 193 | { 194 | var response = await RetryHelper.RetryRequest(() => getResponse(deploymentResult), logger, deploymentResult.HostShutdownToken); 195 | 196 | var responseText = await response.Content.ReadAsStringAsync(); 197 | try 198 | { 199 | Assert.Equal(applicationName, responseText); 200 | } 201 | catch (XunitException) 202 | { 203 | logger.LogWarning(response.ToString()); 204 | logger.LogWarning(responseText); 205 | throw; 206 | } 207 | }); 208 | } 209 | 210 | private async Task ExecuteTestApp(string applicationName, 211 | Func assertAction, 212 | bool setTestEnvVars = false, 213 | string environment = "Development") 214 | { 215 | var deploymentParameters = new DeploymentParameters(Path.Combine(GetTestSitesPath(), applicationName), ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) 216 | { 217 | TargetFramework = "netcoreapp3.0", 218 | }; 219 | 220 | if (setTestEnvVars) 221 | { 222 | SetEnvironmentVariables(deploymentParameters, environment); 223 | } 224 | 225 | using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory)) 226 | { 227 | var deploymentResult = await deployer.DeployAsync(); 228 | 229 | await assertAction(deploymentResult, Logger); 230 | } 231 | } 232 | 233 | private static void SetEnvironmentVariables(DeploymentParameters deploymentParameters, string environment) 234 | { 235 | deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("aspnetcore_environment", environment)); 236 | deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("envKey", "envValue")); 237 | } 238 | 239 | private static string GetTestSitesPath() 240 | { 241 | var applicationBasePath = AppContext.BaseDirectory; 242 | 243 | var directoryInfo = new DirectoryInfo(applicationBasePath); 244 | do 245 | { 246 | var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "MetaPackages.sln")); 247 | if (solutionFileInfo.Exists) 248 | { 249 | return Path.GetFullPath(Path.Combine(directoryInfo.FullName, "test", "TestSites")); 250 | } 251 | 252 | directoryInfo = directoryInfo.Parent; 253 | } 254 | while (directoryInfo.Parent != null); 255 | 256 | throw new Exception($"Solution root could not be found using {applicationBasePath}"); 257 | } 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aspnet/MetaPackages/d417aacd7c0eff202f7860fe1e686aa5beeedad7/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx -------------------------------------------------------------------------------- /test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/Microsoft.AspNetCore.Tests/WebHostTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Concurrent; 6 | using System.Collections.Generic; 7 | using System.Diagnostics.Tracing; 8 | using System.Linq; 9 | using System.Threading; 10 | using Microsoft.AspNetCore.HostFiltering; 11 | using Microsoft.AspNetCore.Hosting; 12 | using Microsoft.Extensions.Configuration; 13 | using Microsoft.Extensions.DependencyInjection; 14 | using Microsoft.Extensions.Logging; 15 | using Microsoft.Extensions.Options; 16 | using Xunit; 17 | 18 | namespace Microsoft.AspNetCore.Tests 19 | { 20 | public class WebHostTests 21 | { 22 | [Fact] 23 | public void WebHostConfiguration_IncludesCommandLineArguments() 24 | { 25 | var builder = WebHost.CreateDefaultBuilder(new string[] { "--urls", "http://localhost:5001" }); 26 | Assert.Equal("http://localhost:5001", builder.GetSetting(WebHostDefaults.ServerUrlsKey)); 27 | } 28 | 29 | [Fact] 30 | public void WebHostConfiguration_HostFilterOptionsAreReloadable() 31 | { 32 | var host = WebHost.CreateDefaultBuilder() 33 | .Configure(app => { }) 34 | .ConfigureAppConfiguration(configBuilder => 35 | { 36 | configBuilder.Add(new ReloadableMemorySource()); 37 | }).Build(); 38 | var config = host.Services.GetRequiredService(); 39 | var monitor = host.Services.GetRequiredService>(); 40 | var options = monitor.CurrentValue; 41 | 42 | Assert.Contains("*", options.AllowedHosts); 43 | 44 | var changed = new ManualResetEvent(false); 45 | monitor.OnChange(newOptions => 46 | { 47 | changed.Set(); 48 | }); 49 | 50 | config["AllowedHosts"] = "NewHost"; 51 | 52 | Assert.True(changed.WaitOne(TimeSpan.FromSeconds(10))); 53 | options = monitor.CurrentValue; 54 | Assert.Contains("NewHost", options.AllowedHosts); 55 | } 56 | 57 | [Fact] 58 | public void CreateDefaultBuilder_RegistersEventSourceLogger() 59 | { 60 | var listener = new TestEventListener(); 61 | var host = WebHost.CreateDefaultBuilder() 62 | .Configure(_ => { }) 63 | .Build(); 64 | 65 | var logger = host.Services.GetRequiredService>(); 66 | logger.LogInformation("Request starting"); 67 | 68 | var events = listener.EventData.ToArray(); 69 | Assert.Contains(events, args => 70 | args.EventSource.Name == "Microsoft-Extensions-Logging" && 71 | args.Payload.OfType().Any(p => p.Contains("Request starting"))); 72 | } 73 | 74 | private class TestEventListener : EventListener 75 | { 76 | private volatile bool _disposed; 77 | 78 | private ConcurrentQueue _events = new ConcurrentQueue(); 79 | 80 | public IEnumerable EventData => _events; 81 | 82 | protected override void OnEventSourceCreated(EventSource eventSource) 83 | { 84 | if (eventSource.Name == "Microsoft-Extensions-Logging") 85 | { 86 | EnableEvents(eventSource, EventLevel.Informational); 87 | } 88 | } 89 | 90 | protected override void OnEventWritten(EventWrittenEventArgs eventData) 91 | { 92 | if (!_disposed) 93 | { 94 | _events.Enqueue(eventData); 95 | } 96 | } 97 | 98 | public override void Dispose() 99 | { 100 | _disposed = true; 101 | base.Dispose(); 102 | } 103 | } 104 | 105 | private class ReloadableMemorySource : IConfigurationSource 106 | { 107 | public IConfigurationProvider Build(IConfigurationBuilder builder) 108 | { 109 | return new ReloadableMemoryProvider(); 110 | } 111 | } 112 | 113 | private class ReloadableMemoryProvider : ConfigurationProvider 114 | { 115 | public override void Set(string key, string value) 116 | { 117 | base.Set(key, value); 118 | OnReload(); 119 | } 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | aspnetcore-CreateDefaultBuilder-20170424224131 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/TestSites/CreateDefaultBuilderApp/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.AspNetCore; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.DependencyInjection; 10 | 11 | namespace CreateDefaultBuilderApp 12 | { 13 | public class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | string responseMessage = null; 18 | 19 | WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) 20 | .ConfigureServices((context, services) => responseMessage = responseMessage ?? GetResponseMessage(context)) 21 | .ConfigureKestrel(options => options 22 | .Configure(options.ConfigurationLoader.Configuration) 23 | .Endpoint("HTTP", endpointOptions => 24 | { 25 | if (responseMessage == null 26 | && !string.Equals("KestrelEndPointSettingValue", endpointOptions.ConfigSection["KestrelEndPointSettingName"])) 27 | { 28 | responseMessage = "Default Kestrel configuration not read."; 29 | } 30 | })) 31 | .Configure(app => app.Run(context => 32 | { 33 | var hostingEnvironment = app.ApplicationServices.GetRequiredService(); 34 | return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName); 35 | })) 36 | .Build().Run(); 37 | } 38 | 39 | private static string GetResponseMessage(WebHostBuilderContext context) 40 | { 41 | // Verify ContentRootPath set 42 | var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT"); 43 | if (!string.Equals(contentRoot, context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) 44 | { 45 | return $"ContentRootPath incorrect. Expected: {contentRoot} Actual: {context.HostingEnvironment.ContentRootPath}"; 46 | } 47 | 48 | // Verify appsettings.json loaded 49 | if (!string.Equals("settingsValue", context.Configuration["settingsKey"], StringComparison.Ordinal)) 50 | { 51 | return $"appsettings.json not loaded into Configuration."; 52 | } 53 | 54 | // Verify appsettings.environment.json loaded 55 | if (!string.Equals("devSettingsValue", context.Configuration["devSettingsKey"], StringComparison.Ordinal)) 56 | { 57 | return $"appsettings.{context.HostingEnvironment.EnvironmentName}.json not loaded into Configuration."; 58 | } 59 | 60 | // TODO: Verify UserSecrets loaded 61 | 62 | // Verify environment variables loaded 63 | if (!string.Equals("envValue", context.Configuration["envKey"], StringComparison.Ordinal)) 64 | { 65 | return $"Environment variables not loaded into Configuration."; 66 | } 67 | 68 | // Verify command line arguments loaded 69 | if (!string.Equals("cliValue", context.Configuration["cliKey"], StringComparison.Ordinal)) 70 | { 71 | return $"Command line arguments not loaded into Configuration."; 72 | } 73 | 74 | // TODO: Verify AddConsole called 75 | // TODO: Verify AddDebug called 76 | // TODO: Verify UseIISIntegration called 77 | 78 | return null; 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "devSettingsKey": "devSettingsValue" 3 | } 4 | -------------------------------------------------------------------------------- /test/TestSites/CreateDefaultBuilderApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "settingsKey": "settingsValue", 3 | "Kestrel": { 4 | "Endpoints": { 5 | "HTTP": { 6 | "Url": "http://127.0.0.1:0", 7 | "KestrelEndPointSettingName": "KestrelEndPointSettingValue" 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | aspnetcore-CreateDefaultBuilderOfT-20170424224131 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/TestSites/CreateDefaultBuilderOfTApp/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.AspNetCore; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.HostFiltering; 8 | using Microsoft.AspNetCore.Hosting; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Options; 12 | 13 | namespace CreateDefaultBuilderOfTApp 14 | { 15 | public class Program 16 | { 17 | static void Main(string[] args) 18 | { 19 | string responseMessage = null; 20 | 21 | WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) 22 | .ConfigureServices((context, service) => responseMessage = responseMessage ?? GetResponseMessage(context)) 23 | .ConfigureKestrel(options => options 24 | .Configure(options.ConfigurationLoader.Configuration) 25 | .Endpoint("HTTP", endpointOptions => 26 | { 27 | if (responseMessage == null 28 | && !string.Equals("KestrelEndPointSettingValue", endpointOptions.ConfigSection["KestrelEndPointSettingName"])) 29 | { 30 | responseMessage = "Default Kestrel configuration not read."; 31 | } 32 | })) 33 | .Configure(app => app.Run(context => 34 | { 35 | // Verify allowed hosts were loaded 36 | var hostFilteringOptions = app.ApplicationServices.GetRequiredService>(); 37 | var hosts = string.Join(',', hostFilteringOptions.Value.AllowedHosts); 38 | if (responseMessage == null && !string.Equals("example.com,127.0.0.1", hosts, StringComparison.Ordinal)) 39 | { 40 | responseMessage = "AllowedHosts not loaded into Options."; 41 | } 42 | 43 | var hostingEnvironment = app.ApplicationServices.GetRequiredService(); 44 | return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName); 45 | })) 46 | .Build() 47 | .Run(); 48 | } 49 | 50 | private static string GetResponseMessage(WebHostBuilderContext context) 51 | { 52 | // Verify ContentRootPath set 53 | var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT"); 54 | if (!string.Equals(contentRoot, context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) 55 | { 56 | return $"ContentRootPath incorrect. Expected: {contentRoot} Actual: {context.HostingEnvironment.ContentRootPath}"; 57 | } 58 | 59 | // Verify appsettings.json loaded 60 | if (!string.Equals("settingsValue", context.Configuration["settingsKey"], StringComparison.Ordinal)) 61 | { 62 | return $"appsettings.json not loaded into Configuration."; 63 | } 64 | 65 | // Verify appsettings.environment.json loaded 66 | if (!string.Equals("devSettingsValue", context.Configuration["devSettingsKey"], StringComparison.Ordinal)) 67 | { 68 | return $"appsettings.{context.HostingEnvironment.EnvironmentName}.json not loaded into Configuration."; 69 | } 70 | 71 | // TODO: Verify UserSecrets loaded 72 | 73 | // Verify environment variables loaded 74 | if (!string.Equals("envValue", context.Configuration["envKey"], StringComparison.Ordinal)) 75 | { 76 | return $"Environment variables not loaded into Configuration."; 77 | } 78 | 79 | // Verify command line arguments loaded 80 | if (!string.Equals("cliValue", context.Configuration["cliKey"], StringComparison.Ordinal)) 81 | { 82 | return $"Command line arguments not loaded into Configuration."; 83 | } 84 | 85 | // TODO: Verify AddConsole called 86 | // TODO: Verify AddDebug called 87 | // TODO: Verify UseIISIntegration called 88 | 89 | return null; 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "devSettingsKey": "devSettingsValue" 3 | } 4 | -------------------------------------------------------------------------------- /test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "settingsKey": "settingsValue", 3 | "AllowedHosts": "example.com;127.0.0.1", 4 | "Kestrel": { 5 | "Endpoints": { 6 | "HTTP": { 7 | "Url": "http://127.0.0.1:0", 8 | "KestrelEndPointSettingName": "KestrelEndPointSettingValue" 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/TestSites/DependencyInjectionApp/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.AspNetCore; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.DependencyInjection; 10 | 11 | namespace CreateDefaultBuilderApp 12 | { 13 | public class Program 14 | { 15 | static void Main(string[] args) 16 | { 17 | WebHost.CreateDefaultBuilder() 18 | .UseUrls("http://127.0.0.1:0") 19 | .ConfigureServices((context, services) => 20 | { 21 | services.AddSingleton(typeof(IService<>), typeof(Service<>)); 22 | services.AddScoped(); 23 | }) 24 | .Configure(app => 25 | { 26 | app.Run(context => 27 | { 28 | try 29 | { 30 | context.RequestServices.GetService>(); 31 | return context.Response.WriteAsync("Success"); 32 | } 33 | catch (Exception ex) 34 | { 35 | return context.Response.WriteAsync(ex.ToString()); 36 | } 37 | }); 38 | }) 39 | .Build().Run(); 40 | } 41 | 42 | interface IService 43 | { 44 | } 45 | 46 | interface IAnotherService 47 | { 48 | } 49 | 50 | class Service: IService 51 | { 52 | public Service(T t) 53 | { 54 | } 55 | } 56 | 57 | class AnotherService: IAnotherService 58 | { 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /test/TestSites/StartRequestDelegateUrlApp/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Threading; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Hosting.Server.Features; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.Extensions.DependencyInjection; 11 | 12 | namespace StartRequestDelegateUrlApp 13 | { 14 | public class Program 15 | { 16 | static void Main(string[] args) 17 | { 18 | var messageSent = new ManualResetEventSlim(false); 19 | 20 | using (var host = WebHost.Start("http://127.0.0.1:0", async context => 21 | { 22 | // Respond with the ApplicationName. 23 | var env = context.RequestServices.GetRequiredService(); 24 | await context.Response.WriteAsync(env.ApplicationName); 25 | messageSent.Set(); 26 | })) 27 | { 28 | // Need these for test deployer to consider host deployment successful 29 | // The address written here is used by the client to send requests 30 | var addresses = host.ServerFeatures.Get().Addresses; 31 | foreach (var address in addresses) 32 | { 33 | Console.WriteLine($"Now listening on: {address}"); 34 | } 35 | Console.WriteLine("Application started. Press Ctrl+C to shut down."); 36 | 37 | // Shut down after message sent or timeout 38 | messageSent.Wait(TimeSpan.FromSeconds(30)); 39 | 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/TestSites/StartRouteBuilderUrlApp/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Threading; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Hosting.Server.Features; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.AspNetCore.Routing; 11 | using Microsoft.Extensions.DependencyInjection; 12 | 13 | namespace StartRequestDelegateUrlApp 14 | { 15 | public class Program 16 | { 17 | static void Main(string[] args) 18 | { 19 | var messageSent = new ManualResetEventSlim(false); 20 | 21 | using (var host = WebHost.Start("http://127.0.0.1:0", router => 22 | router.MapGet("route", async (req, res, data) => 23 | { 24 | var env = req.HttpContext.RequestServices.GetRequiredService(); 25 | await res.WriteAsync(env.ApplicationName); 26 | messageSent.Set(); 27 | }))) 28 | { 29 | // Need these for test deployer to consider host deployment successful 30 | // The address written here is used by the client to send requests 31 | var addresses = host.ServerFeatures.Get().Addresses; 32 | foreach (var address in addresses) 33 | { 34 | Console.WriteLine($"Now listening on: {address}"); 35 | } 36 | Console.WriteLine("Application started. Press Ctrl+C to shut down."); 37 | 38 | // Shut down after message sent or timeout 39 | messageSent.Wait(TimeSpan.FromSeconds(30)); 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Threading; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Builder; 8 | using Microsoft.AspNetCore.Hosting; 9 | using Microsoft.AspNetCore.Hosting.Server.Features; 10 | using Microsoft.AspNetCore.Http; 11 | using Microsoft.Extensions.DependencyInjection; 12 | 13 | namespace StartWithIApplicationBuilderUrlApp 14 | { 15 | public class Program 16 | { 17 | static void Main(string[] args) 18 | { 19 | var messageSent = new ManualResetEventSlim(false); 20 | 21 | using (var host = WebHost.StartWith("http://127.0.0.1:0", app => 22 | { 23 | app.Run(async context => 24 | { 25 | var env = context.RequestServices.GetRequiredService(); 26 | await context.Response.WriteAsync(env.ApplicationName); 27 | messageSent.Set(); 28 | }); 29 | })) 30 | { 31 | // Need these for test deployer to consider host deployment successful 32 | // The address written here is used by the client to send requests 33 | var addresses = host.ServerFeatures.Get().Addresses; 34 | foreach (var address in addresses) 35 | { 36 | Console.WriteLine($"Now listening on: {address}"); 37 | } 38 | Console.WriteLine("Application started. Press Ctrl+C to shut down."); 39 | 40 | // Shut down after message sent or timeout 41 | messageSent.Wait(TimeSpan.FromSeconds(30)); 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /version.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 3.0.0 4 | alpha1 5 | $(VersionPrefix) 6 | $(VersionPrefix)-$(VersionSuffix)-final 7 | t000 8 | a- 9 | $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) 10 | $(VersionSuffix)-$(BuildNumber) 11 | 12 | 13 | --------------------------------------------------------------------------------