From d3a7d7f5dac71843ab6773e1cd82039f2a78c853 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Mon, 10 Oct 2016 13:43:46 -0700 Subject: [PATCH 001/361] Create README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..d35e5f0866 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +Meta packages +======== + +This repo contains NuGet meta packages that help quickly reference sets of common packages. + +This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo. + From 95620d6cd5b0fda14d4931c02d626e8f6f5898b5 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Mon, 10 Oct 2016 13:44:14 -0700 Subject: [PATCH 002/361] Create LICENSE.txt --- LICENSE.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000..0bdc1962b6 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,12 @@ +Copyright (c) .NET Foundation. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +these files except in compliance with the License. You may obtain a copy of the +License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. From 34e0b3ae35d55801893b795271dcddd47527d240 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Mon, 10 Oct 2016 13:44:30 -0700 Subject: [PATCH 003/361] Create CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..64ff041d5c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +Contributing +====== + +Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. From d5b0126f618826d9227654ce6fdd0dd255a723ea Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 10 Oct 2016 14:18:36 -0700 Subject: [PATCH 004/361] Add AspNetCore meta package --- .gitattributes | 52 ++++++++++++++ .gitignore | 30 +++++++++ MetaPackages.sln | 32 +++++++++ NuGet.config | 8 +++ NuGetPackageVerifier.json | 7 ++ build.cmd | 2 + build.ps1 | 67 +++++++++++++++++++ build.sh | 46 +++++++++++++ global.json | 3 + .../Microsoft.AspNetCore.xproj | 20 ++++++ src/Microsoft.AspNetCore/project.json | 23 +++++++ 11 files changed, 290 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 MetaPackages.sln create mode 100644 NuGet.config create mode 100644 NuGetPackageVerifier.json create mode 100644 build.cmd create mode 100644 build.ps1 create mode 100644 build.sh create mode 100644 global.json create mode 100644 src/Microsoft.AspNetCore/Microsoft.AspNetCore.xproj create mode 100644 src/Microsoft.AspNetCore/project.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..c2f0f84273 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,52 @@ +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +*.jpg binary +*.png binary +*.gif binary + +*.cs text=auto diff=csharp +*.vb text=auto +*.resx text=auto +*.c text=auto +*.cpp text=auto +*.cxx text=auto +*.h text=auto +*.hxx text=auto +*.py text=auto +*.rb text=auto +*.java text=auto +*.html text=auto +*.htm text=auto +*.css text=auto +*.scss text=auto +*.sass text=auto +*.less text=auto +*.js text=auto +*.lisp text=auto +*.clj text=auto +*.sql text=auto +*.php text=auto +*.lua text=auto +*.m text=auto +*.asm text=auto +*.erl text=auto +*.fs text=auto +*.fsx text=auto +*.hs text=auto + +*.csproj text=auto +*.vbproj text=auto +*.fsproj text=auto +*.dbproj text=auto +*.sln text=auto eol=crlf + +*.sh eol=lf \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..0fb89cd896 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +[Oo]bj/ +[Bb]in/ +TestResults/ +.nuget/ +_ReSharper.*/ +packages/ +artifacts/ +PublishProfiles/ +*.user +*.suo +*.cache +*.docstates +_ReSharper.* +nuget.exe +*net45.csproj +*net451.csproj +*k10.csproj +*.psess +*.vsp +*.pidb +*.userprefs +*DS_Store +*.ncrunchsolution +*.*sdf +*.ipch +*.sln.ide +project.lock.json +.vs +.build/ +.testPublish/ \ No newline at end of file diff --git a/MetaPackages.sln b/MetaPackages.sln new file mode 100644 index 0000000000..320802fac1 --- /dev/null +++ b/MetaPackages.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8DFE5055-E413-45B8-B584-3FDC84B2D5F2}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + EndProjectSection +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.xproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + EndGlobalSection +EndGlobal diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000000..9f4165645a --- /dev/null +++ b/NuGet.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json new file mode 100644 index 0000000000..45b04454bf --- /dev/null +++ b/NuGetPackageVerifier.json @@ -0,0 +1,7 @@ +{ + "Default": { // Rules to run for packages not listed in any other set. + "rules": [ + "DefaultCompositeRule" + ] + } +} \ No newline at end of file diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000000..7d4894cb4a --- /dev/null +++ b/build.cmd @@ -0,0 +1,2 @@ +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000000..6d49c4dccd --- /dev/null +++ b/build.ps1 @@ -0,0 +1,67 @@ +$ErrorActionPreference = "Stop" + +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +{ + while($true) + { + try + { + Invoke-WebRequest $url -OutFile $downloadLocation + break + } + catch + { + $exceptionMessage = $_.Exception.Message + Write-Host "Failed to download '$url': $exceptionMessage" + if ($retries -gt 0) { + $retries-- + Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" + Start-Sleep -Seconds 10 + + } + else + { + $exception = $_.Exception + throw $exception + } + } + } +} + +cd $PSScriptRoot + +$repoFolder = $PSScriptRoot +$env:REPO_FOLDER = $repoFolder + +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/1.0.0.zip" +if ($env:KOREBUILD_ZIP) +{ + $koreBuildZip=$env:KOREBUILD_ZIP +} + +$buildFolder = ".build" +$buildFile="$buildFolder\KoreBuild.ps1" + +if (!(Test-Path $buildFolder)) { + Write-Host "Downloading KoreBuild from $koreBuildZip" + + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() + New-Item -Path "$tempFolder" -Type directory | Out-Null + + $localZipFile="$tempFolder\korebuild.zip" + + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 + + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) + + New-Item -Path "$buildFolder" -Type directory | Out-Null + copy-item "$tempFolder\**\build\*" $buildFolder -Recurse + + # Cleanup + if (Test-Path $tempFolder) { + Remove-Item -Recurse -Force $tempFolder + } +} + +&"$buildFile" $args \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000000..a55d3ebc12 --- /dev/null +++ b/build.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $repoFolder + +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/1.0.0.zip" +if [ ! -z $KOREBUILD_ZIP ]; then + koreBuildZip=$KOREBUILD_ZIP +fi + +buildFolder=".build" +buildFile="$buildFolder/KoreBuild.sh" + +if test ! -d $buildFolder; then + echo "Downloading KoreBuild from $koreBuildZip" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" + mkdir $tempFolder + + localZipFile="$tempFolder/korebuild.zip" + + retries=6 + until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) + do + echo "Failed to download '$koreBuildZip'" + if [ "$retries" -le 0 ]; then + exit 1 + fi + retries=$((retries - 1)) + echo "Waiting 10 seconds before retrying. Retries left: $retries" + sleep 10s + done + + unzip -q -d $tempFolder $localZipFile + + mkdir $buildFolder + cp -r $tempFolder/**/build/** $buildFolder + + chmod +x $buildFile + + # Cleanup + if test ! -d $tempFolder; then + rm -rf $tempFolder + fi +fi + +$buildFile -r $repoFolder "$@" \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 0000000000..7d8f1bffa2 --- /dev/null +++ b/global.json @@ -0,0 +1,3 @@ +{ + "projects": [ "src" ] +} diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.xproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.xproj new file mode 100644 index 0000000000..669a5002d7 --- /dev/null +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 6f3d43f7-9546-4b41-af04-cf4708b62051 + .\obj + .\bin\ + v4.5.1 + + + + 2.0 + + + diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json new file mode 100644 index 0000000000..52259023b3 --- /dev/null +++ b/src/Microsoft.AspNetCore/project.json @@ -0,0 +1,23 @@ +{ + "version": "1.0.1-*", + + "dependencies": { + "Microsoft.AspNetCore.Diagnostics": "1.0.0", + "Microsoft.AspNetCore.Hosting": "1.0.0", + "Microsoft.AspNetCore.Routing": "1.0.1", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", + "Microsoft.AspNetCore.StaticFiles": "1.0.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", + "Microsoft.Extensions.Configuration.Json": "1.0.0", + "Microsoft.Extensions.Logging": "1.0.0", + "Microsoft.Extensions.Logging.Console": "1.0.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", + "NETStandard.Library": "1.6.0" + }, + "frameworks": { + "netstandard1.3": {}, + "net451": {} + } +} From 8b037016011a6a01b6bb31723b6aa48bbcbc0fb2 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Thu, 13 Oct 2016 12:37:33 -0700 Subject: [PATCH 005/361] Remove version suffix --- src/Microsoft.AspNetCore/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json index 52259023b3..8990174a41 100644 --- a/src/Microsoft.AspNetCore/project.json +++ b/src/Microsoft.AspNetCore/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.1-*", + "version": "1.0.1", "dependencies": { "Microsoft.AspNetCore.Diagnostics": "1.0.0", From 44cc97adb9d0f555e46d6772017e2bd7e5bc2b21 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 13 Oct 2016 14:32:44 -0700 Subject: [PATCH 006/361] chmod +x build.sh --- build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build.sh diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 From f5ac590e5333e911feb67c6eea68e6cf47efd102 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Wed, 12 Oct 2016 15:19:42 -0700 Subject: [PATCH 007/361] 1.1.0 dependencies --- NuGet.config | 3 +-- build.ps1 | 2 +- build.sh | 2 +- makefile.shade | 6 ++++++ src/Microsoft.AspNetCore/project.json | 28 +++++++++++++-------------- 5 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 makefile.shade diff --git a/NuGet.config b/NuGet.config index 9f4165645a..2ad0f8ba84 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,8 +1,7 @@ - - + \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 6d49c4dccd..8f2f99691a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/1.0.0.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index a55d3ebc12..f4208100eb 100644 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/1.0.0.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/makefile.shade b/makefile.shade new file mode 100644 index 0000000000..3b0f5f69bf --- /dev/null +++ b/makefile.shade @@ -0,0 +1,6 @@ +var AUTHORS='Microsoft Open Technologies, Inc.' + +use-standard-lifecycle +k-standard-goals + +-Environment.SetEnvironmentVariable("KOREBUILD_ADD_ASSEMBLY_INFO", "0"); \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json index 52259023b3..fc3219c84a 100644 --- a/src/Microsoft.AspNetCore/project.json +++ b/src/Microsoft.AspNetCore/project.json @@ -1,20 +1,20 @@ { - "version": "1.0.1-*", + "version": "1.1.0-*", "dependencies": { - "Microsoft.AspNetCore.Diagnostics": "1.0.0", - "Microsoft.AspNetCore.Hosting": "1.0.0", - "Microsoft.AspNetCore.Routing": "1.0.1", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", - "Microsoft.AspNetCore.StaticFiles": "1.0.0", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", - "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", - "Microsoft.Extensions.Configuration.Json": "1.0.0", - "Microsoft.Extensions.Logging": "1.0.0", - "Microsoft.Extensions.Logging.Console": "1.0.0", - "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", - "NETStandard.Library": "1.6.0" + "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", + "Microsoft.AspNetCore.Hosting": "1.1.0-*", + "Microsoft.AspNetCore.Routing": "1.1.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.1.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", + "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0-*", + "Microsoft.Extensions.Configuration.Json": "1.1.0-*", + "Microsoft.Extensions.Logging": "1.1.0-*", + "Microsoft.Extensions.Logging.Console": "1.1.0-*", + "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { "netstandard1.3": {}, From 5323cef7485b79c52b5962f5d84091b71768f266 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Thu, 13 Oct 2016 16:28:18 -0700 Subject: [PATCH 008/361] Fix verify and assembly creation --- NuGetPackageVerifier.json | 7 ------- makefile.shade | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) delete mode 100644 NuGetPackageVerifier.json create mode 100644 makefile.shade diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json deleted file mode 100644 index 45b04454bf..0000000000 --- a/NuGetPackageVerifier.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "Default": { // Rules to run for packages not listed in any other set. - "rules": [ - "DefaultCompositeRule" - ] - } -} \ No newline at end of file diff --git a/makefile.shade b/makefile.shade new file mode 100644 index 0000000000..3b0f5f69bf --- /dev/null +++ b/makefile.shade @@ -0,0 +1,6 @@ +var AUTHORS='Microsoft Open Technologies, Inc.' + +use-standard-lifecycle +k-standard-goals + +-Environment.SetEnvironmentVariable("KOREBUILD_ADD_ASSEMBLY_INFO", "0"); \ No newline at end of file From b7f3ea4451cf536cce1d7e3c1c77819953e40cc9 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 17 Oct 2016 16:31:52 +0000 Subject: [PATCH 009/361] Make build script executable --- build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build.sh diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 From 04f986329347c55408eaeb19386d6794510fba46 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 24 Oct 2016 08:53:39 -0700 Subject: [PATCH 010/361] Remove StaticFiles from AspNetCore meta package --- src/Microsoft.AspNetCore/project.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json index 8990174a41..2948f1e2fe 100644 --- a/src/Microsoft.AspNetCore/project.json +++ b/src/Microsoft.AspNetCore/project.json @@ -7,7 +7,6 @@ "Microsoft.AspNetCore.Routing": "1.0.1", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", - "Microsoft.AspNetCore.StaticFiles": "1.0.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", From 75ab32926bacba24975c09cfef586327cec3e5a0 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 28 Oct 2016 14:55:07 -0700 Subject: [PATCH 011/361] Target netcoreapp and reference NETCore.App --- src/Microsoft.AspNetCore/project.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json index fc3219c84a..b0289eb08a 100644 --- a/src/Microsoft.AspNetCore/project.json +++ b/src/Microsoft.AspNetCore/project.json @@ -14,10 +14,22 @@ "Microsoft.Extensions.Logging": "1.1.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0-*", - "NETStandard.Library": "1.6.1-*" }, "frameworks": { - "netstandard1.3": {}, - "net451": {} + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": "1.1.0-*" + } + }, + "netcoreapp1.1": { + "dependencies": { + "Microsoft.NETCore.App": "1.1.0-*" + } + }, + "net451": { + "dependencies": { + "NETStandard.Library": "1.6.1-*" + } + } } } From 522e30ae19ac65d7e46b5f0c799df74cf63c1e65 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 31 Oct 2016 08:34:33 -0700 Subject: [PATCH 012/361] Re-Add NuGetPackageVerifier --- NuGetPackageVerifier.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 NuGetPackageVerifier.json diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json new file mode 100644 index 0000000000..45b04454bf --- /dev/null +++ b/NuGetPackageVerifier.json @@ -0,0 +1,7 @@ +{ + "Default": { // Rules to run for packages not listed in any other set. + "rules": [ + "DefaultCompositeRule" + ] + } +} \ No newline at end of file From 88571e6cf7060c74eba568783c135895b8deeed4 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Fri, 4 Nov 2016 13:30:24 -0700 Subject: [PATCH 013/361] Revert "Target netcoreapp and reference NETCore.App" This reverts commit 75ab32926bacba24975c09cfef586327cec3e5a0. --- src/Microsoft.AspNetCore/project.json | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json index 72257f197f..207ea117ed 100644 --- a/src/Microsoft.AspNetCore/project.json +++ b/src/Microsoft.AspNetCore/project.json @@ -13,22 +13,10 @@ "Microsoft.Extensions.Logging": "1.1.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0-*", + "NETStandard.Library": "1.6.1-*" }, "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": "1.1.0-*" - } - }, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": "1.1.0-*" - } - }, - "net451": { - "dependencies": { - "NETStandard.Library": "1.6.1-*" - } - } + "netstandard1.3": {}, + "net451": {} } } From eed17848800b65ed9f6fd8098da9a1dc6b5f2983 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Sat, 5 Nov 2016 23:45:24 -0700 Subject: [PATCH 014/361] Added tags to project.json --- src/Microsoft.AspNetCore/project.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json index 207ea117ed..fde0c67e65 100644 --- a/src/Microsoft.AspNetCore/project.json +++ b/src/Microsoft.AspNetCore/project.json @@ -1,6 +1,8 @@ { "version": "1.1.0-*", - + "tags": [ + "aspnetcore" + ], "dependencies": { "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", "Microsoft.AspNetCore.Hosting": "1.1.0-*", From 49012632b16aa69e4ba61847b08e6a15464b7cb3 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Nov 2016 11:31:53 -0800 Subject: [PATCH 015/361] Branching for 1.1.0 --- NuGet.config | 2 +- build.ps1 | 2 +- build.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index 2ad0f8ba84..6197c93176 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..24ca167cf6 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index f4208100eb..fea9ac64ad 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/1.1.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From 8af98eb301ceeb38191b6195a166d929bc2c48d6 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 Nov 2016 14:18:30 -0800 Subject: [PATCH 016/361] Updating versions to 1.2.0-* --- src/Microsoft.AspNetCore/project.json | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json index fde0c67e65..22d5d3c66e 100644 --- a/src/Microsoft.AspNetCore/project.json +++ b/src/Microsoft.AspNetCore/project.json @@ -1,24 +1,24 @@ -{ - "version": "1.1.0-*", +{ + "version": "1.2.0-*", "tags": [ "aspnetcore" ], "dependencies": { - "Microsoft.AspNetCore.Diagnostics": "1.1.0-*", - "Microsoft.AspNetCore.Hosting": "1.1.0-*", - "Microsoft.AspNetCore.Routing": "1.1.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-*", - "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0-*", - "Microsoft.Extensions.Configuration.Json": "1.1.0-*", - "Microsoft.Extensions.Logging": "1.1.0-*", - "Microsoft.Extensions.Logging.Console": "1.1.0-*", - "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0-*", + "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", + "Microsoft.AspNetCore.Hosting": "1.2.0-*", + "Microsoft.AspNetCore.Routing": "1.2.0-*", + "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", + "Microsoft.Extensions.Configuration.FileExtensions": "1.2.0-*", + "Microsoft.Extensions.Configuration.Json": "1.2.0-*", + "Microsoft.Extensions.Logging": "1.2.0-*", + "Microsoft.Extensions.Logging.Console": "1.2.0-*", + "Microsoft.Extensions.Options.ConfigurationExtensions": "1.2.0-*", "NETStandard.Library": "1.6.1-*" }, "frameworks": { "netstandard1.3": {}, "net451": {} } -} +} \ No newline at end of file From 61dedc3a38d60869da554bd9bb90c5d5cc5b1ce8 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 18 Nov 2016 10:56:58 -0800 Subject: [PATCH 017/361] Clean tmp folder after unzipping KoreBuild --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index f4208100eb..4fd7ede788 100755 --- a/build.sh +++ b/build.sh @@ -38,7 +38,7 @@ if test ! -d $buildFolder; then chmod +x $buildFile # Cleanup - if test ! -d $tempFolder; then + if test -d $tempFolder; then rm -rf $tempFolder fi fi From 83397a6d06085d3dcd65156aae0a4ea5e2117ce4 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 23 Nov 2016 16:01:53 -0800 Subject: [PATCH 018/361] Pin global.json SDK to 1.0.0-preview2-1-003177. --- global.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/global.json b/global.json index 7d8f1bffa2..f45e8cc925 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,8 @@ -{ - "projects": [ "src" ] -} +{ + "projects": [ + "src" + ], + "sdk": { + "version": "1.0.0-preview2-1-003177" + } +} \ No newline at end of file From 6eb489007a0a49917b5e8692abbdfe08a1790bb1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 5 Dec 2016 09:03:06 -0800 Subject: [PATCH 019/361] Updating to 4.4 CoreFx packages --- global.json | 2 +- src/Microsoft.AspNetCore/project.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index f45e8cc925..0ad1995dd2 100644 --- a/global.json +++ b/global.json @@ -3,6 +3,6 @@ "src" ], "sdk": { - "version": "1.0.0-preview2-1-003177" + "version": "1.0.0-preview2-1-003180" } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json index 22d5d3c66e..105eafeb72 100644 --- a/src/Microsoft.AspNetCore/project.json +++ b/src/Microsoft.AspNetCore/project.json @@ -15,7 +15,7 @@ "Microsoft.Extensions.Logging": "1.2.0-*", "Microsoft.Extensions.Logging.Console": "1.2.0-*", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.2.0-*", - "NETStandard.Library": "1.6.1-*" + "NETStandard.Library": "1.6.2-*" }, "frameworks": { "netstandard1.3": {}, From 6a38859cf7515342e150baeb8fc689fc1c60d7ce Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Feb 2017 16:13:01 -0800 Subject: [PATCH 020/361] Upgrade to VS 2017 --- MetaPackages.sln | 13 +++------- NuGet.config | 3 ++- NuGetPackageVerifier.json | 2 +- build.ps1 | 2 +- build.sh | 2 +- build/common.props | 21 +++++++++++++++ global.json | 8 ------ makefile.shade | 6 ----- .../Microsoft.AspNetCore.csproj | 26 +++++++++++++++++++ .../Microsoft.AspNetCore.xproj | 20 -------------- src/Microsoft.AspNetCore/project.json | 24 ----------------- version.props | 7 +++++ 12 files changed, 63 insertions(+), 71 deletions(-) create mode 100644 build/common.props delete mode 100644 global.json delete mode 100644 makefile.shade create mode 100644 src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj delete mode 100644 src/Microsoft.AspNetCore/Microsoft.AspNetCore.xproj delete mode 100644 src/Microsoft.AspNetCore/project.json create mode 100644 version.props diff --git a/MetaPackages.sln b/MetaPackages.sln index 320802fac1..6103295817 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,16 +1,11 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26127.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8DFE5055-E413-45B8-B584-3FDC84B2D5F2}" - ProjectSection(SolutionItems) = preProject - global.json = global.json - EndProjectSection -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.xproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/NuGet.config b/NuGet.config index 2ad0f8ba84..8e65695611 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,6 +2,7 @@ + - \ No newline at end of file + diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index 45b04454bf..b153ab1515 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -1,5 +1,5 @@ { - "Default": { // Rules to run for packages not listed in any other set. + "Default": { "rules": [ "DefaultCompositeRule" ] diff --git a/build.ps1 b/build.ps1 index 8f2f99691a..0605b59c01 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index 4fd7ede788..07997d6c83 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/build/common.props b/build/common.props new file mode 100644 index 0000000000..e9627f2b22 --- /dev/null +++ b/build/common.props @@ -0,0 +1,21 @@ + + + + + Microsoft ASP.NET Core + https://github.com/aspnet/MetaPackages + git + 1.2.0-* + 1.6.2-* + $(VersionSuffix)-$(BuildNumber) + + + + + + + + + + + diff --git a/global.json b/global.json deleted file mode 100644 index 0ad1995dd2..0000000000 --- a/global.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "projects": [ - "src" - ], - "sdk": { - "version": "1.0.0-preview2-1-003180" - } -} \ No newline at end of file diff --git a/makefile.shade b/makefile.shade deleted file mode 100644 index 3b0f5f69bf..0000000000 --- a/makefile.shade +++ /dev/null @@ -1,6 +0,0 @@ -var AUTHORS='Microsoft Open Technologies, Inc.' - -use-standard-lifecycle -k-standard-goals - --Environment.SetEnvironmentVariable("KOREBUILD_ADD_ASSEMBLY_INFO", "0"); \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj new file mode 100644 index 0000000000..27ac376b0f --- /dev/null +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -0,0 +1,26 @@ + + + + + + false + netstandard1.3;net451 + aspnetcore + Microsoft.AspNetCore + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.xproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.xproj deleted file mode 100644 index 669a5002d7..0000000000 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 6f3d43f7-9546-4b41-af04-cf4708b62051 - .\obj - .\bin\ - v4.5.1 - - - - 2.0 - - - diff --git a/src/Microsoft.AspNetCore/project.json b/src/Microsoft.AspNetCore/project.json deleted file mode 100644 index 105eafeb72..0000000000 --- a/src/Microsoft.AspNetCore/project.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": "1.2.0-*", - "tags": [ - "aspnetcore" - ], - "dependencies": { - "Microsoft.AspNetCore.Diagnostics": "1.2.0-*", - "Microsoft.AspNetCore.Hosting": "1.2.0-*", - "Microsoft.AspNetCore.Routing": "1.2.0-*", - "Microsoft.AspNetCore.Server.IISIntegration": "1.2.0-*", - "Microsoft.AspNetCore.Server.Kestrel": "1.2.0-*", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.2.0-*", - "Microsoft.Extensions.Configuration.FileExtensions": "1.2.0-*", - "Microsoft.Extensions.Configuration.Json": "1.2.0-*", - "Microsoft.Extensions.Logging": "1.2.0-*", - "Microsoft.Extensions.Logging.Console": "1.2.0-*", - "Microsoft.Extensions.Options.ConfigurationExtensions": "1.2.0-*", - "NETStandard.Library": "1.6.2-*" - }, - "frameworks": { - "netstandard1.3": {}, - "net451": {} - } -} \ No newline at end of file diff --git a/version.props b/version.props new file mode 100644 index 0000000000..17fd5ac36d --- /dev/null +++ b/version.props @@ -0,0 +1,7 @@ + + + + 1.2.0 + preview1 + + From 412c41118bc64810d0d0b6d9036a4bbf94ebd863 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 8 Feb 2017 16:39:18 -0800 Subject: [PATCH 021/361] Set references to PrivateAssets=None --- .../Microsoft.AspNetCore.csproj | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 27ac376b0f..e8772047ac 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -10,17 +10,18 @@ - - - - - - - - - - - + + + + + + + + + + + + From 52c684ec13b945e0bf5cba5a5097e4fe96342e88 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 14 Feb 2017 16:03:53 -0800 Subject: [PATCH 022/361] Downgrade to stable packages --- build/common.props | 3 +-- build/dependencies.props | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 build/dependencies.props diff --git a/build/common.props b/build/common.props index e9627f2b22..ee96847c7e 100644 --- a/build/common.props +++ b/build/common.props @@ -1,12 +1,11 @@ + Microsoft ASP.NET Core https://github.com/aspnet/MetaPackages git - 1.2.0-* - 1.6.2-* $(VersionSuffix)-$(BuildNumber) diff --git a/build/dependencies.props b/build/dependencies.props new file mode 100644 index 0000000000..e704edaec0 --- /dev/null +++ b/build/dependencies.props @@ -0,0 +1,6 @@ + + + 1.6.1 + 4.3.0 + + From 9fff55bb8e141b498e14fc11c0130a33416be499 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 1 Mar 2017 18:14:14 -0800 Subject: [PATCH 023/361] Change korebuild branch and fix argument forwarding in bootstrapper --- build.ps1 | 16 ++++++++-------- build.sh | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/build.ps1 b/build.ps1 index 0605b59c01..5bf0e2c113 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,6 @@ $ErrorActionPreference = "Stop" -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) +function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) { while($true) { @@ -19,7 +19,7 @@ function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $ret Start-Sleep -Seconds 10 } - else + else { $exception = $_.Exception throw $exception @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP @@ -43,18 +43,18 @@ $buildFolder = ".build" $buildFile="$buildFolder\KoreBuild.ps1" if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" - + Write-Host "Downloading KoreBuild from $koreBuildZip" + $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() New-Item -Path "$tempFolder" -Type directory | Out-Null $localZipFile="$tempFolder\korebuild.zip" - + DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) - + New-Item -Path "$buildFolder" -Type directory | Out-Null copy-item "$tempFolder\**\build\*" $buildFolder -Recurse @@ -64,4 +64,4 @@ if (!(Test-Path $buildFolder)) { } } -&"$buildFile" $args \ No newline at end of file +&"$buildFile" @args diff --git a/build.sh b/build.sh index 07997d6c83..b0bcadb579 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/feature/msbuild.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi @@ -12,12 +12,12 @@ buildFile="$buildFolder/KoreBuild.sh" if test ! -d $buildFolder; then echo "Downloading KoreBuild from $koreBuildZip" - - tempFolder="/tmp/KoreBuild-$(uuidgen)" + + tempFolder="/tmp/KoreBuild-$(uuidgen)" mkdir $tempFolder - + localZipFile="$tempFolder/korebuild.zip" - + retries=6 until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) do @@ -29,18 +29,18 @@ if test ! -d $buildFolder; then echo "Waiting 10 seconds before retrying. Retries left: $retries" sleep 10s done - + unzip -q -d $tempFolder $localZipFile - + mkdir $buildFolder cp -r $tempFolder/**/build/** $buildFolder - + chmod +x $buildFile - + # Cleanup if test -d $tempFolder; then - rm -rf $tempFolder + rm -rf $tempFolder fi fi -$buildFile -r $repoFolder "$@" \ No newline at end of file +$buildFile -r $repoFolder "$@" From 890a81562f26e34da304418def3536e545a56121 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 15 Mar 2017 15:36:33 -0700 Subject: [PATCH 024/361] Unify dependency versions --- build/dependencies.props | 3 ++- .../Microsoft.AspNetCore.csproj | 22 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index e704edaec0..13153a03ff 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,7 @@ - 1.6.1 + 1.2.0-* 4.3.0 + 1.6.1 diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index e8772047ac..594a211f7d 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -11,17 +11,17 @@ - - - - - - - - - - - + + + + + + + + + + + From 81f2543810a7913f534c2463eff76f22a91c9511 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Mar 2017 17:59:35 -0700 Subject: [PATCH 025/361] Remove net451 as a cross compile target --- .gitignore | 3 ++- src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0fb89cd896..ec975e873c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ nuget.exe project.lock.json .vs .build/ -.testPublish/ \ No newline at end of file +.testPublish/ +global.json diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 594a211f7d..22ff45b49a 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -4,7 +4,7 @@ false - netstandard1.3;net451 + netstandard1.3 aspnetcore Microsoft.AspNetCore From afef0e3e2a550851594d0a185e16eac4a0ad75f1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Mar 2017 11:30:35 -0700 Subject: [PATCH 026/361] Updating to 2.0.0 Internal.AspNetCore.Sdk --- build/common.props | 2 +- build/dependencies.props | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/common.props b/build/common.props index ee96847c7e..28fead4f8d 100644 --- a/build/common.props +++ b/build/common.props @@ -10,7 +10,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index 13153a03ff..3375713a75 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,6 +2,7 @@ 1.2.0-* 4.3.0 + 2.0.0-* 1.6.1 - + \ No newline at end of file From 4ea73f7e70b55295a09307a3357e5001ed4c586b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Apr 2017 21:41:10 -0700 Subject: [PATCH 027/361] Updating versions to 2.0.0-preview1 --- build/dependencies.props | 2 +- version.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3375713a75..a985d1e299 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 1.2.0-* + 2.0.0-* 4.3.0 2.0.0-* 1.6.1 diff --git a/version.props b/version.props index 17fd5ac36d..c7150e64f4 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 1.2.0 + 2.0.0 preview1 From 36cd2b899b29e6ae5db2c3f39315306979985015 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 24 Mar 2017 01:47:48 -0700 Subject: [PATCH 028/361] Add Microsoft.AspNetCore.All metapackage and build package cache --- MetaPackages.sln | 12 +- build/common.props | 4 + build/dependencies.props | 1 + build/repo.targets | 30 ++++ .../Microsoft.AspNetCore.All.csproj | 148 ++++++++++++++++++ 5 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 build/repo.targets create mode 100644 src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj diff --git a/MetaPackages.sln b/MetaPackages.sln index 6103295817..960c168fd4 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,11 +1,12 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26127.0 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.All", "src\Microsoft.AspNetCore.All\Microsoft.AspNetCore.All.csproj", "{CC8F551E-213A-45E8-AECA-507C4DB4F164}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,11 +18,16 @@ Global {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Debug|Any CPU.Build.0 = Debug|Any CPU {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.ActiveCfg = Release|Any CPU {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.Build.0 = Release|Any CPU + {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/build/common.props b/build/common.props index 28fead4f8d..714e11e12c 100644 --- a/build/common.props +++ b/build/common.props @@ -7,6 +7,10 @@ https://github.com/aspnet/MetaPackages git $(VersionSuffix)-$(BuildNumber) + + + 2.0.0-$(VersionSuffix) + 1.0.0-$(VersionSuffix) diff --git a/build/dependencies.props b/build/dependencies.props index a985d1e299..b8b54468e7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,7 @@ 2.0.0-* + 1.0.0-* 4.3.0 2.0.0-* 1.6.1 diff --git a/build/repo.targets b/build/repo.targets new file mode 100644 index 0000000000..58cdeb1cfd --- /dev/null +++ b/build/repo.targets @@ -0,0 +1,30 @@ + + + + + + $(CompileDependsOn); + BuildPackageCache + + + + + + + $(RepositoryRoot)src\Microsoft.AspNetCore.All\ + $(MetaPackagePath)Microsoft.AspNetCore.All.csproj + $(MetaPackagePath)bin\work\ + $(MetaPackagePath)bin\packageCache\ + $(RepositoryRoot)artifacts\AspNetCorePackageCache.$(AspNetCoreVersion).zip + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj new file mode 100644 index 0000000000..a487dab8ac --- /dev/null +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -0,0 +1,148 @@ + + + + + + false + netstandard1.6 + aspnetcore + Microsoft.AspNetCore.All + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c6c267507afef56be16d402d17ada2a7d73e99b5 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 5 Apr 2017 17:26:38 -0700 Subject: [PATCH 029/361] Temporarity skip AzureIntegration packages due to rename --- src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index a487dab8ac..f1e220da7f 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -139,9 +139,6 @@ - - - From 89de0e52d7de9898eb958ec33df4e83ff5a0effb Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 5 Apr 2017 19:27:19 -0700 Subject: [PATCH 030/361] Generate package cache for each RID --- MetaPackages.sln | 15 ++++++++++++++- build/repo.targets | 20 +++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/MetaPackages.sln b/MetaPackages.sln index 960c168fd4..a44e361e0a 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26323.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -8,6 +8,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore", "src EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.All", "src\Microsoft.AspNetCore.All\Microsoft.AspNetCore.All.csproj", "{CC8F551E-213A-45E8-AECA-507C4DB4F164}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97D53BEB-A511-4FBE-B784-AB407D9A219F}" + ProjectSection(SolutionItems) = preProject + version.props = version.props + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1-C38E-408C-A7EC-A5C040D041E1}" + ProjectSection(SolutionItems) = preProject + build\common.props = build\common.props + build\dependencies.props = build\dependencies.props + build\repo.targets = build\repo.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,5 +41,6 @@ Global GlobalSection(NestedProjects) = preSolution {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} EndGlobalSection EndGlobal diff --git a/build/repo.targets b/build/repo.targets index 58cdeb1cfd..43c77ccc1c 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -9,22 +9,36 @@ + + + + $(RepositoryRoot)src\Microsoft.AspNetCore.All\ $(MetaPackagePath)Microsoft.AspNetCore.All.csproj $(MetaPackagePath)bin\work\ $(MetaPackagePath)bin\packageCache\ - $(RepositoryRoot)artifacts\AspNetCorePackageCache.$(AspNetCoreVersion).zip + $(RepositoryRoot)artifacts\AspNetCorePackageCache.win.zip + $(RepositoryRoot)artifacts\AspNetCorePackageCache.linux.zip + $(RepositoryRoot)artifacts\AspNetCorePackageCache.osx.zip + + + + + + + - - + + + \ No newline at end of file From eb918fc4b21fe7c359358c16bb30844d1474cce4 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 6 Apr 2017 12:32:47 -0700 Subject: [PATCH 031/361] Use osx.10.12-x64 RID on macOS --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 43c77ccc1c..69fa75e396 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -28,7 +28,7 @@ - + From 6c7d09954844d7db48b348927dfe1030bea08bd1 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 6 Apr 2017 12:38:51 -0700 Subject: [PATCH 032/361] Fix directory name --- build/repo.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 69fa75e396..fadd7230be 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -17,7 +17,7 @@ $(RepositoryRoot)src\Microsoft.AspNetCore.All\ $(MetaPackagePath)Microsoft.AspNetCore.All.csproj - $(MetaPackagePath)bin\work\ + $(MetaPackagePath)bin\work $(MetaPackagePath)bin\packageCache\ $(RepositoryRoot)artifacts\AspNetCorePackageCache.win.zip $(RepositoryRoot)artifacts\AspNetCorePackageCache.linux.zip @@ -32,8 +32,8 @@ - - + + From c85a0ff7ef0caba61e48bd13d341c6dac6611346 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 6 Apr 2017 16:13:02 -0700 Subject: [PATCH 033/361] Use dependencies when available --- build/repo.targets | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build/repo.targets b/build/repo.targets index fadd7230be..c31127202a 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -2,12 +2,25 @@ + $(RepositoryRoot).deps\build\ + + $(PrepareDependsOn); + UpdateNuGetConfig + $(CompileDependsOn); BuildPackageCache + + + + From 25842d5f745a42c58cc3d8b0caecc57d3f00de4c Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 6 Apr 2017 19:00:35 -0700 Subject: [PATCH 034/361] Add more packages to cache #21 --- src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index f1e220da7f..fe02e7a8da 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -30,6 +30,7 @@ + @@ -139,6 +140,9 @@ + + + From 0b324b8ca12d31a455783d4b9809723afa15d131 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 10 Apr 2017 11:53:05 -0700 Subject: [PATCH 035/361] React to Microsoft.AspNetCore.Razor.Evolution => Microsoft.AspNetCore.Razor.Language. aspnet/Razor#1169 --- src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index fe02e7a8da..04b01ef15a 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -66,7 +66,7 @@ - + From 936231f32713e66f17f4a2ed136bf92bfd4db7eb Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 11 Apr 2017 20:10:36 -0700 Subject: [PATCH 036/361] React to cli command rename --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index c31127202a..0d5507fbf2 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -46,7 +46,7 @@ - + From 77b2ffba00b03d3224d3cbc85e3798e7f8febd46 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 11 Apr 2017 21:45:41 -0700 Subject: [PATCH 037/361] React to dotnet store command update --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 0d5507fbf2..a130a09f0a 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -46,7 +46,7 @@ - + From b49fc08f8b6366b72976a67de9e5a113898bf9f9 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 12 Apr 2017 13:24:04 -0700 Subject: [PATCH 038/361] Prevent USERSECRETS001 warnings while building cache --- src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 04b01ef15a..684cda7073 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -7,6 +7,7 @@ netstandard1.6 aspnetcore Microsoft.AspNetCore.All + false From fa96eaf6550b16cc4202f551a7bb3ce84e22a77b Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 13 Apr 2017 15:39:23 -0700 Subject: [PATCH 039/361] Add build version number to package cache zip names --- build/repo.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index a130a09f0a..023d31ea8b 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -32,9 +32,9 @@ $(MetaPackagePath)Microsoft.AspNetCore.All.csproj $(MetaPackagePath)bin\work $(MetaPackagePath)bin\packageCache\ - $(RepositoryRoot)artifacts\AspNetCorePackageCache.win.zip - $(RepositoryRoot)artifacts\AspNetCorePackageCache.linux.zip - $(RepositoryRoot)artifacts\AspNetCorePackageCache.osx.zip + $(RepositoryRoot)artifacts\AspNetCorePackageCache.win-$(VersionSuffix).zip + $(RepositoryRoot)artifacts\AspNetCorePackageCache.linux-$(VersionSuffix).zip + $(RepositoryRoot)artifacts\AspNetCorePackageCache.osx-$(VersionSuffix).zip From 404960ce1a305e0e212431372260070431b7c283 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 13 Apr 2017 16:10:30 -0700 Subject: [PATCH 040/361] Use name suggested in Coherence-Signed#439 --- build/repo.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 023d31ea8b..c378f8928d 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -32,9 +32,9 @@ $(MetaPackagePath)Microsoft.AspNetCore.All.csproj $(MetaPackagePath)bin\work $(MetaPackagePath)bin\packageCache\ - $(RepositoryRoot)artifacts\AspNetCorePackageCache.win-$(VersionSuffix).zip - $(RepositoryRoot)artifacts\AspNetCorePackageCache.linux-$(VersionSuffix).zip - $(RepositoryRoot)artifacts\AspNetCorePackageCache.osx-$(VersionSuffix).zip + $(RepositoryRoot)artifacts\Microsoft.Internal.AspNetCorePackageCache.win-$(VersionSuffix).zip + $(RepositoryRoot)artifacts\Microsoft.Internal.AspNetCorePackageCache.linux-$(VersionSuffix).zip + $(RepositoryRoot)artifacts\Microsoft.Internal.AspNetCorePackageCache.osx-$(VersionSuffix).zip From 4d6bdba5546ff8bf886d7db65a36e3b2ffa4abee Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 13 Apr 2017 17:32:23 -0700 Subject: [PATCH 041/361] Add nuspec and version.txt to artifacts --- .../Microsoft.Internal.AspNetCore.PackageCache.nuspec | 11 +++++++++++ build/repo.targets | 11 ++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 build/Microsoft.Internal.AspNetCore.PackageCache.nuspec diff --git a/build/Microsoft.Internal.AspNetCore.PackageCache.nuspec b/build/Microsoft.Internal.AspNetCore.PackageCache.nuspec new file mode 100644 index 0000000000..75da6498d7 --- /dev/null +++ b/build/Microsoft.Internal.AspNetCore.PackageCache.nuspec @@ -0,0 +1,11 @@ + + + + Microsoft.Internal.AspNetCore.PackageCache + Microsoft + Runtime Package Store for ASP.NET Core + + + + + \ No newline at end of file diff --git a/build/repo.targets b/build/repo.targets index c378f8928d..3692ed2cd5 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -32,9 +32,10 @@ $(MetaPackagePath)Microsoft.AspNetCore.All.csproj $(MetaPackagePath)bin\work $(MetaPackagePath)bin\packageCache\ - $(RepositoryRoot)artifacts\Microsoft.Internal.AspNetCorePackageCache.win-$(VersionSuffix).zip - $(RepositoryRoot)artifacts\Microsoft.Internal.AspNetCorePackageCache.linux-$(VersionSuffix).zip - $(RepositoryRoot)artifacts\Microsoft.Internal.AspNetCorePackageCache.osx-$(VersionSuffix).zip + $(RepositoryRoot)artifacts\ + $(ArtifactsDir)Microsoft.Internal.AspNetCorePackageCache.win-$(VersionSuffix).zip + $(ArtifactsDir)Microsoft.Internal.AspNetCorePackageCache.linux-$(VersionSuffix).zip + $(ArtifactsDir)Microsoft.Internal.AspNetCorePackageCache.osx-$(VersionSuffix).zip @@ -53,5 +54,9 @@ + + + + \ No newline at end of file From 9e92b1189bcbe04ccfab984d62d0efaf70bc1aa0 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 14 Apr 2017 00:33:00 -0700 Subject: [PATCH 042/361] Fix typo --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 3692ed2cd5..dde27569e2 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -56,7 +56,7 @@ - + \ No newline at end of file From da403d4d1680fd52f595ae97eb984ae57563a7f2 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 14 Apr 2017 10:50:24 -0700 Subject: [PATCH 043/361] Long path woes --- ...Core.PackageCache.nuspec => Build.PackageStore.nuspec} | 4 ++-- build/repo.targets | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename build/{Microsoft.Internal.AspNetCore.PackageCache.nuspec => Build.PackageStore.nuspec} (52%) diff --git a/build/Microsoft.Internal.AspNetCore.PackageCache.nuspec b/build/Build.PackageStore.nuspec similarity index 52% rename from build/Microsoft.Internal.AspNetCore.PackageCache.nuspec rename to build/Build.PackageStore.nuspec index 75da6498d7..ea5ae50ef7 100644 --- a/build/Microsoft.Internal.AspNetCore.PackageCache.nuspec +++ b/build/Build.PackageStore.nuspec @@ -1,9 +1,9 @@ - Microsoft.Internal.AspNetCore.PackageCache + PackageStore.Int Microsoft - Runtime Package Store for ASP.NET Core + Runtime Package Store for ASP.NET Core, for internal builds diff --git a/build/repo.targets b/build/repo.targets index dde27569e2..5cfca01b90 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -33,9 +33,9 @@ $(MetaPackagePath)bin\work $(MetaPackagePath)bin\packageCache\ $(RepositoryRoot)artifacts\ - $(ArtifactsDir)Microsoft.Internal.AspNetCorePackageCache.win-$(VersionSuffix).zip - $(ArtifactsDir)Microsoft.Internal.AspNetCorePackageCache.linux-$(VersionSuffix).zip - $(ArtifactsDir)Microsoft.Internal.AspNetCorePackageCache.osx-$(VersionSuffix).zip + $(ArtifactsDir)Build.RuntimeStore.win-$(VersionSuffix).zip + $(ArtifactsDir)Build.RuntimeStore.linux-$(VersionSuffix).zip + $(ArtifactsDir)Build.RuntimeStore.osx-$(VersionSuffix).zip @@ -56,7 +56,7 @@ - + \ No newline at end of file From 6e22dbcdc6900213c90c4b2b72d979047fe963bb Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 14 Apr 2017 12:14:26 -0700 Subject: [PATCH 044/361] Missed rename in commit --- build/{Build.PackageStore.nuspec => Build.RuntimeStore.nuspec} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename build/{Build.PackageStore.nuspec => Build.RuntimeStore.nuspec} (100%) diff --git a/build/Build.PackageStore.nuspec b/build/Build.RuntimeStore.nuspec similarity index 100% rename from build/Build.PackageStore.nuspec rename to build/Build.RuntimeStore.nuspec From b19a46f3c2f81e0884127b665c4f99abdc3aca02 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 14 Apr 2017 17:06:33 -0700 Subject: [PATCH 045/361] Write complete version number --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 5cfca01b90..204f028a9d 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -57,6 +57,6 @@ - + \ No newline at end of file From 04c86c65b628ccb57408ef1254c4bdfd10a37e21 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sat, 15 Apr 2017 00:59:33 -0700 Subject: [PATCH 046/361] Nuget pack requires a version attribute Even when you override with -Version on the command line. --- build/Build.RuntimeStore.nuspec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/Build.RuntimeStore.nuspec b/build/Build.RuntimeStore.nuspec index ea5ae50ef7..089762039d 100644 --- a/build/Build.RuntimeStore.nuspec +++ b/build/Build.RuntimeStore.nuspec @@ -1,11 +1,12 @@ - PackageStore.Int + Build.RuntimeStore + $version$ Microsoft Runtime Package Store for ASP.NET Core, for internal builds - \ No newline at end of file + From ce365799a61655397645f76fb3a1763450464005 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 17 Apr 2017 11:01:42 -0700 Subject: [PATCH 047/361] Remove Microsoft.Extensions.Logging.Filter --- src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 684cda7073..08402e2910 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -131,7 +131,6 @@ - From 87c513b0d86fe4d0eba6cd7625bb3944ed6d1d3f Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 17 Apr 2017 15:13:02 -0700 Subject: [PATCH 048/361] Add target to set default target manifest --- .../Microsoft.AspNetCore.All.csproj | 7 ++- ...ublishWithAspNetCoreTargetManifest.targets | 48 +++++++++++++++++++ .../Microsoft.AspNetCore.All.targets | 3 ++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets create mode 100644 src/Microsoft.AspNetCore.All/build/netstandard1.6/Microsoft.AspNetCore.All.targets diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 08402e2910..5a9ac58b14 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -146,4 +146,9 @@ - \ No newline at end of file + + + + + + diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets new file mode 100644 index 0000000000..5fdccb650e --- /dev/null +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -0,0 +1,48 @@ + + + + true + + + + + + + $(AspNetCoreTargetManifestRuntimeIdentifier) + + + + win7-x64 + win7-x86 + osx.10.12-x64 + linux-x64 + + + + + + + + $(TargetManifest);$(MSBuildThisFileDirectory)manifest.$(ManifestRuntimeIdentifier).xml + + + diff --git a/src/Microsoft.AspNetCore.All/build/netstandard1.6/Microsoft.AspNetCore.All.targets b/src/Microsoft.AspNetCore.All/build/netstandard1.6/Microsoft.AspNetCore.All.targets new file mode 100644 index 0000000000..0bed51f606 --- /dev/null +++ b/src/Microsoft.AspNetCore.All/build/netstandard1.6/Microsoft.AspNetCore.All.targets @@ -0,0 +1,3 @@ + + + From 2d15ba89174ba261f2503a79ea4d8d4d77b22f90 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 17 Apr 2017 20:18:55 -0700 Subject: [PATCH 049/361] Add manifests to .All MetaPackage --- build/repo.targets | 62 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 204f028a9d..daef738119 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -2,6 +2,13 @@ + $(RepositoryRoot)src\Microsoft.AspNetCore.All\ + $(MetaPackagePath)Microsoft.AspNetCore.All.csproj + $(MetaPackagePath)bin\work\ + $(MetaPackagePath)bin\packageCache\ + $(RepositoryRoot)artifacts\ + $(ArtifactsDir)temp\ + $(RepositoryRoot)tools\ $(RepositoryRoot).deps\build\ $(PrepareDependsOn); @@ -28,35 +35,54 @@ - $(RepositoryRoot)src\Microsoft.AspNetCore.All\ - $(MetaPackagePath)Microsoft.AspNetCore.All.csproj - $(MetaPackagePath)bin\work - $(MetaPackagePath)bin\packageCache\ - $(RepositoryRoot)artifacts\ - $(ArtifactsDir)Build.RuntimeStore.win-$(VersionSuffix).zip - $(ArtifactsDir)Build.RuntimeStore.linux-$(VersionSuffix).zip - $(ArtifactsDir)Build.RuntimeStore.osx-$(VersionSuffix).zip + $(ArtifactsDir)Build.RuntimeStore.win-$(VersionSuffix).zip + $(ArtifactsDir)Build.RuntimeStore.linux-$(VersionSuffix).zip + $(ArtifactsDir)Build.RuntimeStore.osx-$(VersionSuffix).zip - - - - + + + - - - + + + - + + + manifest.%(RIDs.Identity).xml + + + - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c202608f199d7d3b2d2b0e752d4a9fff84a98dd2 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 18 Apr 2017 16:23:36 -0700 Subject: [PATCH 050/361] Platform specific path separator --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index daef738119..406bbf7028 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -48,7 +48,7 @@ - + From 16eae43d3810a5c2d14990b9bcdc4dea7d765097 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 18 Apr 2017 17:39:13 -0700 Subject: [PATCH 051/361] Missed repository update --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 406bbf7028..d4f5530dee 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -57,7 +57,7 @@ - + From 7ee08665c1ce4964dc449d277916b12927a5e1c1 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 19 Apr 2017 11:42:25 -0700 Subject: [PATCH 052/361] Fix build script --- build/repo.targets | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index d4f5530dee..f79428cca4 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -41,23 +41,32 @@ - - - + + x64 + + + x86 + + + x64 + + + x64 + - + - + - - + + manifest.%(RIDs.Identity).xml - + From 5f4eb5cbbdd7f0a80d0ac7c4c2bacc4612ed801c Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 20 Apr 2017 08:39:47 -0700 Subject: [PATCH 053/361] Package *.HostingStartup.deps.json files as part of package cache build (#34) --- MetaPackages.sln | 9 +- build/common.props | 142 ++++++++++++++++++ build/repo.props | 5 + build/repo.targets | 17 ++- .../Microsoft.AspNetCore.All.csproj | 135 +---------------- .../Microsoft.AspNetCore.RuntimeStore.csproj | 20 +++ .../Microsoft.AspNetCore.csproj | 13 +- 7 files changed, 189 insertions(+), 152 deletions(-) create mode 100644 build/repo.props create mode 100644 src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj diff --git a/MetaPackages.sln b/MetaPackages.sln index a44e361e0a..c5c63d90c3 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26323.1 +VisualStudioVersion = 15.0.26412.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -20,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1 build\repo.targets = build\repo.targets EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RuntimeStore", "src\Microsoft.AspNetCore.RuntimeStore\Microsoft.AspNetCore.RuntimeStore.csproj", "{A4585E19-FC49-43B4-9416-0BD3120EAD32}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -34,6 +36,10 @@ Global {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.Build.0 = Debug|Any CPU {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.ActiveCfg = Release|Any CPU {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.Build.0 = Release|Any CPU + {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -42,5 +48,6 @@ Global {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} + {A4585E19-FC49-43B4-9416-0BD3120EAD32} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/build/common.props b/build/common.props index 714e11e12c..3bef86b4cd 100644 --- a/build/common.props +++ b/build/common.props @@ -20,5 +20,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/repo.props b/build/repo.props new file mode 100644 index 0000000000..c7b2520845 --- /dev/null +++ b/build/repo.props @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/build/repo.targets b/build/repo.targets index f79428cca4..9f7e31a399 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -2,10 +2,11 @@ - $(RepositoryRoot)src\Microsoft.AspNetCore.All\ - $(MetaPackagePath)Microsoft.AspNetCore.All.csproj + $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ + $(MetaPackagePath)Microsoft.AspNetCore.RuntimeStore.csproj $(MetaPackagePath)bin\work\ $(MetaPackagePath)bin\packageCache\ + $(MetaPackagePath)bin\deps\ $(RepositoryRoot)artifacts\ $(ArtifactsDir)temp\ $(RepositoryRoot)tools\ @@ -35,9 +36,12 @@ - $(ArtifactsDir)Build.RuntimeStore.win-$(VersionSuffix).zip - $(ArtifactsDir)Build.RuntimeStore.linux-$(VersionSuffix).zip - $(ArtifactsDir)Build.RuntimeStore.osx-$(VersionSuffix).zip + win + linux + osx + + $(ArtifactsDir)Build.RuntimeStore.$(OutputZipSufix)-$(VersionSuffix).zip + $(ArtifactsDir)Build.Deps.$(OutputZipSufix)-$(VersionSuffix).zip @@ -59,14 +63,17 @@ + manifest.%(RIDs.Identity).xml + + diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 5a9ac58b14..3f4f051db9 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -11,141 +11,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj new file mode 100644 index 0000000000..6331331da8 --- /dev/null +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -0,0 +1,20 @@ + + + + + + netcoreapp2.0 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 22ff45b49a..1299f3569e 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -10,18 +10,7 @@ - - - - - - - - - - - - + From 198fe3481384ed3377a909e4db927c70d3407df3 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 20 Apr 2017 11:09:29 -0700 Subject: [PATCH 054/361] react to removal of PlatformAbstractions (#36) --- build/common.props | 1 - 1 file changed, 1 deletion(-) diff --git a/build/common.props b/build/common.props index 3bef86b4cd..30a0a74a67 100644 --- a/build/common.props +++ b/build/common.props @@ -150,7 +150,6 @@ - From 55d50b2d4181445c49a326b86191ebd3d506d0fc Mon Sep 17 00:00:00 2001 From: damianedwards Date: Thu, 6 Apr 2017 18:09:58 -0700 Subject: [PATCH 055/361] Adds new WebHost API for creating IWebHost & IWebHostBuilder with defaults: - #24 --- MetaPackages.sln | 10 + build/Key.snk | Bin 0 -> 596 bytes build/common.props | 4 +- build/dependencies.props | 1 + samples/SampleApp/Program.cs | 63 ++++++ .../SampleApp/Properties/launchSettings.json | 27 +++ samples/SampleApp/SampleApp.csproj | 18 ++ samples/SampleApp/Startup.cs | 28 +++ .../Microsoft.AspNetCore.csproj | 8 +- src/Microsoft.AspNetCore/WebHost.cs | 179 ++++++++++++++++++ .../WebHostStartupFilter.cs | 26 +++ 11 files changed, 360 insertions(+), 4 deletions(-) create mode 100644 build/Key.snk create mode 100644 samples/SampleApp/Program.cs create mode 100644 samples/SampleApp/Properties/launchSettings.json create mode 100644 samples/SampleApp/SampleApp.csproj create mode 100644 samples/SampleApp/Startup.cs create mode 100644 src/Microsoft.AspNetCore/WebHost.cs create mode 100644 src/Microsoft.AspNetCore/WebHostStartupFilter.cs diff --git a/MetaPackages.sln b/MetaPackages.sln index c5c63d90c3..6de1068cba 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -20,8 +20,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1 build\repo.targets = build\repo.targets EndProjectSection EndProject + Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RuntimeStore", "src\Microsoft.AspNetCore.RuntimeStore\Microsoft.AspNetCore.RuntimeStore.csproj", "{A4585E19-FC49-43B4-9416-0BD3120EAD32}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F583C-C4CA-43E5-B31C-D21B7806E274}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -36,6 +41,10 @@ Global {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.Build.0 = Debug|Any CPU {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.ActiveCfg = Release|Any CPU {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.Build.0 = Release|Any CPU + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -48,6 +57,7 @@ Global {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274} {A4585E19-FC49-43B4-9416-0BD3120EAD32} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/build/Key.snk b/build/Key.snk new file mode 100644 index 0000000000000000000000000000000000000000..e10e4889c125d3120cd9e81582243d70f7cbb806 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098=Iw=HCsnz~#iVhm& zj%TU(_THUee?3yHBjk$37ysB?i5#7WD$={H zV4B!OxRPrb|8)HPg~A}8P>^=#y<)56#=E&NzcjOtPK~<4n6GHt=K$ro*T(lhby_@U zEk(hLzk1H)0yXj{A_5>fk-TgNoP|q6(tP2xo8zt8i%212CWM#AeCd?`hS|4~L({h~Moo(~vy&3Z z1uI}`fd^*>o=rwbAGymj6RM^pZm(*Kfhs+Y1#`-2JPWZMK8@;ZWCk2+9bX4YP);~fj-BU*R zQPvWv$89!{Rl9wM+zR>_TSkn^voYxA?2G iKnV#iZ6Ah`K>b=@=IjYJXrxL124zR(38)nxe+&q_$QXwJ literal 0 HcmV?d00001 diff --git a/build/common.props b/build/common.props index 30a0a74a67..dfd6c25f34 100644 --- a/build/common.props +++ b/build/common.props @@ -31,6 +31,8 @@ + + @@ -129,10 +131,8 @@ - - diff --git a/build/dependencies.props b/build/dependencies.props index b8b54468e7..f5484bca6f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,5 +5,6 @@ 4.3.0 2.0.0-* 1.6.1 + 2.0.0-* \ No newline at end of file diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs new file mode 100644 index 0000000000..e78eab19d1 --- /dev/null +++ b/samples/SampleApp/Program.cs @@ -0,0 +1,63 @@ +using System; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; + +namespace SampleApp +{ + public class Program + { + public static void Main(string[] args) + { + //HelloWorld(); + + //CustomUrl(); + + Router(); + + //StartupClass(args); + } + + private static void HelloWorld() + { + var host = WebHost.Start(context => context.Response.WriteAsync("Hello, World!")); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); + } + + private static void CustomUrl() + { + // Changing the listening URL + var host = WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!")); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); + } + + private static void Router() + { + // Using a router + var host = WebHost.Start(router => router + .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}")) + .MapGet("goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}")) + .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) + .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}")) + .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")) + ); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); + } + + private static void StartupClass(string[] args) + { + // Using defaults with a Startup class + var host = WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build(); + host.Run(); + } + } +} diff --git a/samples/SampleApp/Properties/launchSettings.json b/samples/SampleApp/Properties/launchSettings.json new file mode 100644 index 0000000000..f0370cf22b --- /dev/null +++ b/samples/SampleApp/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:53432/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "SampleApp": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:53433" + } + } +} diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj new file mode 100644 index 0000000000..a3520ca464 --- /dev/null +++ b/samples/SampleApp/SampleApp.csproj @@ -0,0 +1,18 @@ + + + + + + netcoreapp2.0 + aspnetcore-MetaPackagesSampleApp-20170406180413 + + + + + + + + + + + diff --git a/samples/SampleApp/Startup.cs b/samples/SampleApp/Startup.cs new file mode 100644 index 0000000000..0f8e756160 --- /dev/null +++ b/samples/SampleApp/Startup.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace SampleApp +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + app.Run(async (context) => + { + await context.Response.WriteAsync($"Hello from {nameof(Startup)}!"); + }); + } + } +} diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 1299f3569e..1ce6696c7a 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,10 +3,14 @@ - false - netstandard1.3 + true + netstandard1.5 aspnetcore Microsoft.AspNetCore + false + ..\..\build\Key.snk + true + true diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs new file mode 100644 index 0000000000..4aa1a87df8 --- /dev/null +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -0,0 +1,179 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore +{ + /// + /// Provides convenience methods for creating instances of and with pre-configured defaults. + /// + public static class WebHost + { + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// A delegate that handles requests to the application. + /// A started that hosts the application. + public static IWebHost Start(RequestDelegate app) => + Start(null, app); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// The URL the hosted application will listen on. + /// A delegate that handles requests to the application. + /// A started that hosts the application. + public static IWebHost Start(string url, RequestDelegate app) => + StartWith(url, appBuilder => appBuilder.Run(app)); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// A delegate that configures the router for handling requests to the application. + /// A started that hosts the application. + public static IWebHost Start(Action routeBuilder) => + Start(null, routeBuilder); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// The URL the hosted application will listen on. + /// A delegate that configures the router for handling requests to the application. + /// A started that hosts the application. + public static IWebHost Start(string url, Action routeBuilder) => + StartWith(url, services => services.AddRouting(), app => app.UseRouter(routeBuilder)); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// A delegate that handles requests to the application. + /// A started that hosts the application. + public static IWebHost StartWith(Action app) => + StartWith(null, app); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// The URL the hosted application will listen on. + /// The delegate that configures the . + /// A started that hosts the application. + public static IWebHost StartWith(string url, Action app) => + StartWith(url, null, app); + + private static IWebHost StartWith(string url, Action configureServices, Action app) + { + var builder = CreateDefaultBuilder(); + + if (!string.IsNullOrEmpty(url)) + { + builder.UseUrls(url); + } + + if (configureServices != null) + { + builder.ConfigureServices(configureServices); + } + + var host = builder + .Configure(app) + .Build(); + + host.Start(); + + return host; + } + + /// + /// Initializes a new instance of the class with pre-configured defaults. + /// + /// + /// The following defaults are applied to the returned : + /// use Kestrel as the web server, + /// set the to the result of , + /// load from 'appsettings.json' and 'appsettings.[].json', + /// load from User Secrets when is 'Development' using the entry assembly, + /// load from environment variables, + /// configures the to log to the console, + /// enables IIS integration, + /// and adds the developer exception page when is 'Development' + /// + /// The initialized . + public static IWebHostBuilder CreateDefaultBuilder() => + CreateDefaultBuilder(null); + + /// + /// Initializes a new instance of the class with pre-configured defaults. + /// + /// + /// The following defaults are applied to the returned : + /// use Kestrel as the web server, + /// set the to the result of , + /// load from 'appsettings.json' and 'appsettings.[].json', + /// load from User Secrets when is 'Development' using the entry assembly, + /// load from environment variables, + /// load from supplied command line args, + /// configures the to log to the console, + /// enables IIS integration, + /// and adds the developer exception page when is 'Development' + /// + /// The command line args. + /// The initialized . + public static IWebHostBuilder CreateDefaultBuilder(string[] args) + { + var builder = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .ConfigureConfiguration((hostingContext, config) => + { + var env = hostingContext.HostingEnvironment; + + config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); + + if (env.IsDevelopment()) + { + var appAssembly = Assembly.GetEntryAssembly(); + if (appAssembly != null) + { + config.AddUserSecrets(appAssembly); + } + } + + config.AddEnvironmentVariables(); + + if (args != null) + { + config.AddCommandLine(args); + } + }) + .ConfigureLogging(logging => + { + logging.AddConsole(); + }) + // TODO: Remove this when ANCM injects it by default + .UseIISIntegration() + .ConfigureServices(services => + { + services.AddSingleton(); + }); + + return builder; + } + } +} diff --git a/src/Microsoft.AspNetCore/WebHostStartupFilter.cs b/src/Microsoft.AspNetCore/WebHostStartupFilter.cs new file mode 100644 index 0000000000..43690799ce --- /dev/null +++ b/src/Microsoft.AspNetCore/WebHostStartupFilter.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.AspNetCore +{ + internal class WebHostStartupFilter : IStartupFilter + { + public Action Configure(Action next) + { + return app => + { + var env = app.ApplicationServices.GetService(); + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + next(app); + }; + } + } +} From 587985b49731a8edcdae885688664819886a84b6 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 20 Apr 2017 14:54:31 -0700 Subject: [PATCH 056/361] Update build targets and clean up --- build/common.props | 8 ++- samples/SampleApp/Program.cs | 56 +++++++++++-------- samples/SampleApp/Startup.cs | 10 ++-- .../Microsoft.AspNetCore.All.csproj | 2 +- .../Microsoft.AspNetCore.RuntimeStore.csproj | 4 +- .../Microsoft.AspNetCore.csproj | 7 +-- src/Microsoft.AspNetCore/WebHost.cs | 27 +++++---- 7 files changed, 61 insertions(+), 53 deletions(-) diff --git a/build/common.props b/build/common.props index dfd6c25f34..6a1fb41e41 100644 --- a/build/common.props +++ b/build/common.props @@ -6,6 +6,10 @@ Microsoft ASP.NET Core https://github.com/aspnet/MetaPackages git + false + ..\..\build\Key.snk + true + true $(VersionSuffix)-$(BuildNumber) @@ -20,7 +24,7 @@ - + @@ -28,6 +32,7 @@ + @@ -102,7 +107,6 @@ - diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs index e78eab19d1..30ba926b95 100644 --- a/samples/SampleApp/Program.cs +++ b/samples/SampleApp/Program.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -10,54 +13,61 @@ namespace SampleApp { public static void Main(string[] args) { - //HelloWorld(); + HelloWorld(); - //CustomUrl(); + CustomUrl(); - Router(); + CustomRouter(); - //StartupClass(args); + StartupClass(args); } private static void HelloWorld() { - var host = WebHost.Start(context => context.Response.WriteAsync("Hello, World!")); - //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting - Console.WriteLine("Press any key to shutdown..."); - Console.ReadKey(); + using (WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) + { + //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 + Console.WriteLine("Running HelloWorld: Press any key to shutdown and start the next sample..."); + Console.ReadKey(); + } } private static void CustomUrl() { // Changing the listening URL - var host = WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!")); - //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting - Console.WriteLine("Press any key to shutdown..."); - Console.ReadKey(); + using (WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!"))) + { + //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 + Console.WriteLine("Running CustomUrl: Press any key to shutdown and start the next sample..."); + Console.ReadKey(); + } } - private static void Router() + private static void CustomRouter() { // Using a router - var host = WebHost.Start(router => router + using (WebHost.Start(router => router .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}")) .MapGet("goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}")) .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}")) - .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")) - ); - //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting - Console.WriteLine("Press any key to shutdown..."); - Console.ReadKey(); + .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")))) + { + //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 + Console.WriteLine("Running CustomRouter: Press any key to shutdown and start the next sample..."); + Console.ReadKey(); + } } private static void StartupClass(string[] args) { // Using defaults with a Startup class - var host = WebHost.CreateDefaultBuilder(args) + using (var host = WebHost.CreateDefaultBuilder(args) .UseStartup() - .Build(); - host.Run(); + .Build()) + { + host.Run(); + } } } } diff --git a/samples/SampleApp/Startup.cs b/samples/SampleApp/Startup.cs index 0f8e756160..287fffd27a 100644 --- a/samples/SampleApp/Startup.cs +++ b/samples/SampleApp/Startup.cs @@ -1,12 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace SampleApp { @@ -16,7 +14,7 @@ namespace SampleApp { } - + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.Run(async (context) => diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 3f4f051db9..a8f03f7ce0 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -7,7 +7,7 @@ netstandard1.6 aspnetcore Microsoft.AspNetCore.All - false + false diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 6331331da8..23c1cf58ee 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -12,9 +12,9 @@ - + - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 1ce6696c7a..f63370faad 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,14 +3,11 @@ - true netstandard1.5 aspnetcore Microsoft.AspNetCore - false - ..\..\build\Key.snk - true - true + true + false diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 4aa1a87df8..eca24f56b9 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -21,16 +21,16 @@ namespace Microsoft.AspNetCore { /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// A delegate that handles requests to the application. /// A started that hosts the application. public static IWebHost Start(RequestDelegate app) => - Start(null, app); + Start(url: null, app: app); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// A delegate that handles requests to the application. @@ -40,16 +40,16 @@ namespace Microsoft.AspNetCore /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// A delegate that configures the router for handling requests to the application. /// A started that hosts the application. public static IWebHost Start(Action routeBuilder) => - Start(null, routeBuilder); + Start(url: null, routeBuilder: routeBuilder); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// A delegate that configures the router for handling requests to the application. @@ -59,22 +59,22 @@ namespace Microsoft.AspNetCore /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// - /// A delegate that handles requests to the application. + /// The delegate that configures the . /// A started that hosts the application. public static IWebHost StartWith(Action app) => - StartWith(null, app); + StartWith(url: null, app: app); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// The delegate that configures the . /// A started that hosts the application. public static IWebHost StartWith(string url, Action app) => - StartWith(url, null, app); + StartWith(url: url, configureServices: null, app: app); private static IWebHost StartWith(string url, Action configureServices, Action app) { @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore /// /// The initialized . public static IWebHostBuilder CreateDefaultBuilder() => - CreateDefaultBuilder(null); + CreateDefaultBuilder(args: null); /// /// Initializes a new instance of the class with pre-configured defaults. @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore var builder = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) - .ConfigureConfiguration((hostingContext, config) => + .ConfigureAppConfiguration((hostingContext, config) => { var env = hostingContext.HostingEnvironment; @@ -166,7 +166,6 @@ namespace Microsoft.AspNetCore { logging.AddConsole(); }) - // TODO: Remove this when ANCM injects it by default .UseIISIntegration() .ConfigureServices(services => { From 992407fb35da53658c5c54bf62f06fa163cb02ff Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 20 Apr 2017 18:46:34 -0700 Subject: [PATCH 057/361] Revert "Update build targets and clean up" This reverts commit 587985b49731a8edcdae885688664819886a84b6. --- build/common.props | 8 +-- samples/SampleApp/Program.cs | 56 ++++++++----------- samples/SampleApp/Startup.cs | 10 ++-- .../Microsoft.AspNetCore.All.csproj | 2 +- .../Microsoft.AspNetCore.RuntimeStore.csproj | 4 +- .../Microsoft.AspNetCore.csproj | 7 ++- src/Microsoft.AspNetCore/WebHost.cs | 27 ++++----- 7 files changed, 53 insertions(+), 61 deletions(-) diff --git a/build/common.props b/build/common.props index 6a1fb41e41..dfd6c25f34 100644 --- a/build/common.props +++ b/build/common.props @@ -6,10 +6,6 @@ Microsoft ASP.NET Core https://github.com/aspnet/MetaPackages git - false - ..\..\build\Key.snk - true - true $(VersionSuffix)-$(BuildNumber) @@ -24,7 +20,7 @@ - + @@ -32,7 +28,6 @@ - @@ -107,6 +102,7 @@ + diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs index 30ba926b95..e78eab19d1 100644 --- a/samples/SampleApp/Program.cs +++ b/samples/SampleApp/Program.cs @@ -1,7 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; +using System; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -13,61 +10,54 @@ namespace SampleApp { public static void Main(string[] args) { - HelloWorld(); + //HelloWorld(); - CustomUrl(); + //CustomUrl(); - CustomRouter(); + Router(); - StartupClass(args); + //StartupClass(args); } private static void HelloWorld() { - using (WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) - { - //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 - Console.WriteLine("Running HelloWorld: Press any key to shutdown and start the next sample..."); - Console.ReadKey(); - } + var host = WebHost.Start(context => context.Response.WriteAsync("Hello, World!")); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); } private static void CustomUrl() { // Changing the listening URL - using (WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!"))) - { - //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 - Console.WriteLine("Running CustomUrl: Press any key to shutdown and start the next sample..."); - Console.ReadKey(); - } + var host = WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!")); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); } - private static void CustomRouter() + private static void Router() { // Using a router - using (WebHost.Start(router => router + var host = WebHost.Start(router => router .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}")) .MapGet("goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}")) .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}")) - .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")))) - { - //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 - Console.WriteLine("Running CustomRouter: Press any key to shutdown and start the next sample..."); - Console.ReadKey(); - } + .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")) + ); + //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting + Console.WriteLine("Press any key to shutdown..."); + Console.ReadKey(); } private static void StartupClass(string[] args) { // Using defaults with a Startup class - using (var host = WebHost.CreateDefaultBuilder(args) + var host = WebHost.CreateDefaultBuilder(args) .UseStartup() - .Build()) - { - host.Run(); - } + .Build(); + host.Run(); } } } diff --git a/samples/SampleApp/Startup.cs b/samples/SampleApp/Startup.cs index 287fffd27a..0f8e756160 100644 --- a/samples/SampleApp/Startup.cs +++ b/samples/SampleApp/Startup.cs @@ -1,10 +1,12 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; namespace SampleApp { @@ -14,7 +16,7 @@ namespace SampleApp { } - + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.Run(async (context) => diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index a8f03f7ce0..3f4f051db9 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -7,7 +7,7 @@ netstandard1.6 aspnetcore Microsoft.AspNetCore.All - false + false diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 23c1cf58ee..6331331da8 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -12,9 +12,9 @@ - + - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index f63370faad..1ce6696c7a 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,11 +3,14 @@ + true netstandard1.5 aspnetcore Microsoft.AspNetCore - true - false + false + ..\..\build\Key.snk + true + true diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index eca24f56b9..4aa1a87df8 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -21,16 +21,16 @@ namespace Microsoft.AspNetCore { /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// A delegate that handles requests to the application. /// A started that hosts the application. public static IWebHost Start(RequestDelegate app) => - Start(url: null, app: app); + Start(null, app); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// A delegate that handles requests to the application. @@ -40,16 +40,16 @@ namespace Microsoft.AspNetCore /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// A delegate that configures the router for handling requests to the application. /// A started that hosts the application. public static IWebHost Start(Action routeBuilder) => - Start(url: null, routeBuilder: routeBuilder); + Start(null, routeBuilder); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// A delegate that configures the router for handling requests to the application. @@ -59,22 +59,22 @@ namespace Microsoft.AspNetCore /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// - /// The delegate that configures the . + /// A delegate that handles requests to the application. /// A started that hosts the application. public static IWebHost StartWith(Action app) => - StartWith(url: null, app: app); + StartWith(null, app); /// /// Initializes and starts a new with pre-configured defaults. - /// See for details. + /// See for details. /// /// The URL the hosted application will listen on. /// The delegate that configures the . /// A started that hosts the application. public static IWebHost StartWith(string url, Action app) => - StartWith(url: url, configureServices: null, app: app); + StartWith(url, null, app); private static IWebHost StartWith(string url, Action configureServices, Action app) { @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore /// /// The initialized . public static IWebHostBuilder CreateDefaultBuilder() => - CreateDefaultBuilder(args: null); + CreateDefaultBuilder(null); /// /// Initializes a new instance of the class with pre-configured defaults. @@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore var builder = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) - .ConfigureAppConfiguration((hostingContext, config) => + .ConfigureConfiguration((hostingContext, config) => { var env = hostingContext.HostingEnvironment; @@ -166,6 +166,7 @@ namespace Microsoft.AspNetCore { logging.AddConsole(); }) + // TODO: Remove this when ANCM injects it by default .UseIISIntegration() .ConfigureServices(services => { From 10775adf5bd2fa3a6f916e31339d82c8b77046d6 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 20 Apr 2017 18:47:00 -0700 Subject: [PATCH 058/361] Revert "Adds new WebHost API for creating IWebHost & IWebHostBuilder with defaults:" This reverts commit 55d50b2d4181445c49a326b86191ebd3d506d0fc. --- MetaPackages.sln | 10 - build/Key.snk | Bin 596 -> 0 bytes build/common.props | 4 +- build/dependencies.props | 1 - samples/SampleApp/Program.cs | 63 ------ .../SampleApp/Properties/launchSettings.json | 27 --- samples/SampleApp/SampleApp.csproj | 18 -- samples/SampleApp/Startup.cs | 28 --- .../Microsoft.AspNetCore.csproj | 8 +- src/Microsoft.AspNetCore/WebHost.cs | 179 ------------------ .../WebHostStartupFilter.cs | 26 --- 11 files changed, 4 insertions(+), 360 deletions(-) delete mode 100644 build/Key.snk delete mode 100644 samples/SampleApp/Program.cs delete mode 100644 samples/SampleApp/Properties/launchSettings.json delete mode 100644 samples/SampleApp/SampleApp.csproj delete mode 100644 samples/SampleApp/Startup.cs delete mode 100644 src/Microsoft.AspNetCore/WebHost.cs delete mode 100644 src/Microsoft.AspNetCore/WebHostStartupFilter.cs diff --git a/MetaPackages.sln b/MetaPackages.sln index 6de1068cba..c5c63d90c3 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -20,13 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1 build\repo.targets = build\repo.targets EndProjectSection EndProject - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RuntimeStore", "src\Microsoft.AspNetCore.RuntimeStore\Microsoft.AspNetCore.RuntimeStore.csproj", "{A4585E19-FC49-43B4-9416-0BD3120EAD32}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F583C-C4CA-43E5-B31C-D21B7806E274}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,10 +36,6 @@ Global {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.Build.0 = Debug|Any CPU {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.ActiveCfg = Release|Any CPU {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.Build.0 = Release|Any CPU - {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -57,7 +48,6 @@ Global {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} - {AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274} {A4585E19-FC49-43B4-9416-0BD3120EAD32} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/build/Key.snk b/build/Key.snk deleted file mode 100644 index e10e4889c125d3120cd9e81582243d70f7cbb806..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098=Iw=HCsnz~#iVhm& zj%TU(_THUee?3yHBjk$37ysB?i5#7WD$={H zV4B!OxRPrb|8)HPg~A}8P>^=#y<)56#=E&NzcjOtPK~<4n6GHt=K$ro*T(lhby_@U zEk(hLzk1H)0yXj{A_5>fk-TgNoP|q6(tP2xo8zt8i%212CWM#AeCd?`hS|4~L({h~Moo(~vy&3Z z1uI}`fd^*>o=rwbAGymj6RM^pZm(*Kfhs+Y1#`-2JPWZMK8@;ZWCk2+9bX4YP);~fj-BU*R zQPvWv$89!{Rl9wM+zR>_TSkn^voYxA?2G iKnV#iZ6Ah`K>b=@=IjYJXrxL124zR(38)nxe+&q_$QXwJ diff --git a/build/common.props b/build/common.props index dfd6c25f34..30a0a74a67 100644 --- a/build/common.props +++ b/build/common.props @@ -31,8 +31,6 @@ - - @@ -131,8 +129,10 @@ + + diff --git a/build/dependencies.props b/build/dependencies.props index f5484bca6f..b8b54468e7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,6 +5,5 @@ 4.3.0 2.0.0-* 1.6.1 - 2.0.0-* \ No newline at end of file diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs deleted file mode 100644 index e78eab19d1..0000000000 --- a/samples/SampleApp/Program.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; - -namespace SampleApp -{ - public class Program - { - public static void Main(string[] args) - { - //HelloWorld(); - - //CustomUrl(); - - Router(); - - //StartupClass(args); - } - - private static void HelloWorld() - { - var host = WebHost.Start(context => context.Response.WriteAsync("Hello, World!")); - //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting - Console.WriteLine("Press any key to shutdown..."); - Console.ReadKey(); - } - - private static void CustomUrl() - { - // Changing the listening URL - var host = WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!")); - //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting - Console.WriteLine("Press any key to shutdown..."); - Console.ReadKey(); - } - - private static void Router() - { - // Using a router - var host = WebHost.Start(router => router - .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}")) - .MapGet("goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}")) - .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) - .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}")) - .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")) - ); - //host.WaitForShutdown(); // TODO: This method needs to be added to Hosting - Console.WriteLine("Press any key to shutdown..."); - Console.ReadKey(); - } - - private static void StartupClass(string[] args) - { - // Using defaults with a Startup class - var host = WebHost.CreateDefaultBuilder(args) - .UseStartup() - .Build(); - host.Run(); - } - } -} diff --git a/samples/SampleApp/Properties/launchSettings.json b/samples/SampleApp/Properties/launchSettings.json deleted file mode 100644 index f0370cf22b..0000000000 --- a/samples/SampleApp/Properties/launchSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:53432/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "SampleApp": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:53433" - } - } -} diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj deleted file mode 100644 index a3520ca464..0000000000 --- a/samples/SampleApp/SampleApp.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - netcoreapp2.0 - aspnetcore-MetaPackagesSampleApp-20170406180413 - - - - - - - - - - - diff --git a/samples/SampleApp/Startup.cs b/samples/SampleApp/Startup.cs deleted file mode 100644 index 0f8e756160..0000000000 --- a/samples/SampleApp/Startup.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace SampleApp -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - - } - - public void Configure(IApplicationBuilder app, IHostingEnvironment env) - { - app.Run(async (context) => - { - await context.Response.WriteAsync($"Hello from {nameof(Startup)}!"); - }); - } - } -} diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 1ce6696c7a..1299f3569e 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,14 +3,10 @@ - true - netstandard1.5 + false + netstandard1.3 aspnetcore Microsoft.AspNetCore - false - ..\..\build\Key.snk - true - true diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs deleted file mode 100644 index 4aa1a87df8..0000000000 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; -using System.Reflection; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore -{ - /// - /// Provides convenience methods for creating instances of and with pre-configured defaults. - /// - public static class WebHost - { - /// - /// Initializes and starts a new with pre-configured defaults. - /// See for details. - /// - /// A delegate that handles requests to the application. - /// A started that hosts the application. - public static IWebHost Start(RequestDelegate app) => - Start(null, app); - - /// - /// Initializes and starts a new with pre-configured defaults. - /// See for details. - /// - /// The URL the hosted application will listen on. - /// A delegate that handles requests to the application. - /// A started that hosts the application. - public static IWebHost Start(string url, RequestDelegate app) => - StartWith(url, appBuilder => appBuilder.Run(app)); - - /// - /// Initializes and starts a new with pre-configured defaults. - /// See for details. - /// - /// A delegate that configures the router for handling requests to the application. - /// A started that hosts the application. - public static IWebHost Start(Action routeBuilder) => - Start(null, routeBuilder); - - /// - /// Initializes and starts a new with pre-configured defaults. - /// See for details. - /// - /// The URL the hosted application will listen on. - /// A delegate that configures the router for handling requests to the application. - /// A started that hosts the application. - public static IWebHost Start(string url, Action routeBuilder) => - StartWith(url, services => services.AddRouting(), app => app.UseRouter(routeBuilder)); - - /// - /// Initializes and starts a new with pre-configured defaults. - /// See for details. - /// - /// A delegate that handles requests to the application. - /// A started that hosts the application. - public static IWebHost StartWith(Action app) => - StartWith(null, app); - - /// - /// Initializes and starts a new with pre-configured defaults. - /// See for details. - /// - /// The URL the hosted application will listen on. - /// The delegate that configures the . - /// A started that hosts the application. - public static IWebHost StartWith(string url, Action app) => - StartWith(url, null, app); - - private static IWebHost StartWith(string url, Action configureServices, Action app) - { - var builder = CreateDefaultBuilder(); - - if (!string.IsNullOrEmpty(url)) - { - builder.UseUrls(url); - } - - if (configureServices != null) - { - builder.ConfigureServices(configureServices); - } - - var host = builder - .Configure(app) - .Build(); - - host.Start(); - - return host; - } - - /// - /// Initializes a new instance of the class with pre-configured defaults. - /// - /// - /// The following defaults are applied to the returned : - /// use Kestrel as the web server, - /// set the to the result of , - /// load from 'appsettings.json' and 'appsettings.[].json', - /// load from User Secrets when is 'Development' using the entry assembly, - /// load from environment variables, - /// configures the to log to the console, - /// enables IIS integration, - /// and adds the developer exception page when is 'Development' - /// - /// The initialized . - public static IWebHostBuilder CreateDefaultBuilder() => - CreateDefaultBuilder(null); - - /// - /// Initializes a new instance of the class with pre-configured defaults. - /// - /// - /// The following defaults are applied to the returned : - /// use Kestrel as the web server, - /// set the to the result of , - /// load from 'appsettings.json' and 'appsettings.[].json', - /// load from User Secrets when is 'Development' using the entry assembly, - /// load from environment variables, - /// load from supplied command line args, - /// configures the to log to the console, - /// enables IIS integration, - /// and adds the developer exception page when is 'Development' - /// - /// The command line args. - /// The initialized . - public static IWebHostBuilder CreateDefaultBuilder(string[] args) - { - var builder = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .ConfigureConfiguration((hostingContext, config) => - { - var env = hostingContext.HostingEnvironment; - - config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); - - if (env.IsDevelopment()) - { - var appAssembly = Assembly.GetEntryAssembly(); - if (appAssembly != null) - { - config.AddUserSecrets(appAssembly); - } - } - - config.AddEnvironmentVariables(); - - if (args != null) - { - config.AddCommandLine(args); - } - }) - .ConfigureLogging(logging => - { - logging.AddConsole(); - }) - // TODO: Remove this when ANCM injects it by default - .UseIISIntegration() - .ConfigureServices(services => - { - services.AddSingleton(); - }); - - return builder; - } - } -} diff --git a/src/Microsoft.AspNetCore/WebHostStartupFilter.cs b/src/Microsoft.AspNetCore/WebHostStartupFilter.cs deleted file mode 100644 index 43690799ce..0000000000 --- a/src/Microsoft.AspNetCore/WebHostStartupFilter.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.AspNetCore -{ - internal class WebHostStartupFilter : IStartupFilter - { - public Action Configure(Action next) - { - return app => - { - var env = app.ApplicationServices.GetService(); - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - next(app); - }; - } - } -} From d9661ed70dc4f6d8347d956f787484d8d59ef3e4 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 21 Apr 2017 12:20:44 -0700 Subject: [PATCH 059/361] Un-revert changes for static WebHost API Keeping the same netstandard1.3 TFM so as to not break apps targeting net46. --- MetaPackages.sln | 10 + build/Key.snk | Bin 0 -> 596 bytes build/common.props | 12 +- build/dependencies.props | 1 + samples/SampleApp/Program.cs | 73 +++++++ .../SampleApp/Properties/launchSettings.json | 27 +++ samples/SampleApp/SampleApp.csproj | 18 ++ samples/SampleApp/Startup.cs | 26 +++ .../Microsoft.AspNetCore.All.csproj | 2 +- .../Microsoft.AspNetCore.RuntimeStore.csproj | 4 +- .../Microsoft.AspNetCore.csproj | 3 +- src/Microsoft.AspNetCore/WebHost.cs | 178 ++++++++++++++++++ .../WebHostStartupFilter.cs | 26 +++ 13 files changed, 372 insertions(+), 8 deletions(-) create mode 100644 build/Key.snk create mode 100644 samples/SampleApp/Program.cs create mode 100644 samples/SampleApp/Properties/launchSettings.json create mode 100644 samples/SampleApp/SampleApp.csproj create mode 100644 samples/SampleApp/Startup.cs create mode 100644 src/Microsoft.AspNetCore/WebHost.cs create mode 100644 src/Microsoft.AspNetCore/WebHostStartupFilter.cs diff --git a/MetaPackages.sln b/MetaPackages.sln index c5c63d90c3..6de1068cba 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -20,8 +20,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1 build\repo.targets = build\repo.targets EndProjectSection EndProject + Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RuntimeStore", "src\Microsoft.AspNetCore.RuntimeStore\Microsoft.AspNetCore.RuntimeStore.csproj", "{A4585E19-FC49-43B4-9416-0BD3120EAD32}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F583C-C4CA-43E5-B31C-D21B7806E274}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -36,6 +41,10 @@ Global {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.Build.0 = Debug|Any CPU {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.ActiveCfg = Release|Any CPU {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.Build.0 = Release|Any CPU + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.Build.0 = Debug|Any CPU {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -48,6 +57,7 @@ Global {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} + {AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274} {A4585E19-FC49-43B4-9416-0BD3120EAD32} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/build/Key.snk b/build/Key.snk new file mode 100644 index 0000000000000000000000000000000000000000..e10e4889c125d3120cd9e81582243d70f7cbb806 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098=Iw=HCsnz~#iVhm& zj%TU(_THUee?3yHBjk$37ysB?i5#7WD$={H zV4B!OxRPrb|8)HPg~A}8P>^=#y<)56#=E&NzcjOtPK~<4n6GHt=K$ro*T(lhby_@U zEk(hLzk1H)0yXj{A_5>fk-TgNoP|q6(tP2xo8zt8i%212CWM#AeCd?`hS|4~L({h~Moo(~vy&3Z z1uI}`fd^*>o=rwbAGymj6RM^pZm(*Kfhs+Y1#`-2JPWZMK8@;ZWCk2+9bX4YP);~fj-BU*R zQPvWv$89!{Rl9wM+zR>_TSkn^voYxA?2G iKnV#iZ6Ah`K>b=@=IjYJXrxL124zR(38)nxe+&q_$QXwJ literal 0 HcmV?d00001 diff --git a/build/common.props b/build/common.props index 30a0a74a67..6a1fb41e41 100644 --- a/build/common.props +++ b/build/common.props @@ -6,6 +6,10 @@ Microsoft ASP.NET Core https://github.com/aspnet/MetaPackages git + false + ..\..\build\Key.snk + true + true $(VersionSuffix)-$(BuildNumber) @@ -20,7 +24,7 @@ - + @@ -28,9 +32,12 @@ + + + @@ -100,7 +107,6 @@ - @@ -129,10 +135,8 @@ - - diff --git a/build/dependencies.props b/build/dependencies.props index b8b54468e7..f5484bca6f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,5 +5,6 @@ 4.3.0 2.0.0-* 1.6.1 + 2.0.0-* \ No newline at end of file diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs new file mode 100644 index 0000000000..30ba926b95 --- /dev/null +++ b/samples/SampleApp/Program.cs @@ -0,0 +1,73 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; + +namespace SampleApp +{ + public class Program + { + public static void Main(string[] args) + { + HelloWorld(); + + CustomUrl(); + + CustomRouter(); + + StartupClass(args); + } + + private static void HelloWorld() + { + using (WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) + { + //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 + Console.WriteLine("Running HelloWorld: Press any key to shutdown and start the next sample..."); + Console.ReadKey(); + } + } + + private static void CustomUrl() + { + // Changing the listening URL + using (WebHost.Start("http://localhost:8080", context => context.Response.WriteAsync("Hello, World!"))) + { + //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 + Console.WriteLine("Running CustomUrl: Press any key to shutdown and start the next sample..."); + Console.ReadKey(); + } + } + + private static void CustomRouter() + { + // Using a router + using (WebHost.Start(router => router + .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}")) + .MapGet("goodbye/{name}", (req, res, data) => res.WriteAsync($"Goodbye, {data.Values["name"]}")) + .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) + .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}")) + .MapGet("", (req, res, data) => res.WriteAsync($"Hello, World!")))) + { + //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 + Console.WriteLine("Running CustomRouter: Press any key to shutdown and start the next sample..."); + Console.ReadKey(); + } + } + + private static void StartupClass(string[] args) + { + // Using defaults with a Startup class + using (var host = WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build()) + { + host.Run(); + } + } + } +} diff --git a/samples/SampleApp/Properties/launchSettings.json b/samples/SampleApp/Properties/launchSettings.json new file mode 100644 index 0000000000..f0370cf22b --- /dev/null +++ b/samples/SampleApp/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:53432/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "SampleApp": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:53433" + } + } +} diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj new file mode 100644 index 0000000000..a3520ca464 --- /dev/null +++ b/samples/SampleApp/SampleApp.csproj @@ -0,0 +1,18 @@ + + + + + + netcoreapp2.0 + aspnetcore-MetaPackagesSampleApp-20170406180413 + + + + + + + + + + + diff --git a/samples/SampleApp/Startup.cs b/samples/SampleApp/Startup.cs new file mode 100644 index 0000000000..287fffd27a --- /dev/null +++ b/samples/SampleApp/Startup.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace SampleApp +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + app.Run(async (context) => + { + await context.Response.WriteAsync($"Hello from {nameof(Startup)}!"); + }); + } + } +} diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 3f4f051db9..a8f03f7ce0 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -7,7 +7,7 @@ netstandard1.6 aspnetcore Microsoft.AspNetCore.All - false + false diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 6331331da8..23c1cf58ee 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -12,9 +12,9 @@ - + - + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 1299f3569e..cae574de41 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,10 +3,11 @@ - false netstandard1.3 aspnetcore Microsoft.AspNetCore + true + false diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs new file mode 100644 index 0000000000..c1c9a865a7 --- /dev/null +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -0,0 +1,178 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore +{ + /// + /// Provides convenience methods for creating instances of and with pre-configured defaults. + /// + public static class WebHost + { + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// A delegate that handles requests to the application. + /// A started that hosts the application. + public static IWebHost Start(RequestDelegate app) => + Start(url: null, app: app); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// The URL the hosted application will listen on. + /// A delegate that handles requests to the application. + /// A started that hosts the application. + public static IWebHost Start(string url, RequestDelegate app) => + StartWith(url, appBuilder => appBuilder.Run(app)); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// A delegate that configures the router for handling requests to the application. + /// A started that hosts the application. + public static IWebHost Start(Action routeBuilder) => + Start(url: null, routeBuilder: routeBuilder); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// The URL the hosted application will listen on. + /// A delegate that configures the router for handling requests to the application. + /// A started that hosts the application. + public static IWebHost Start(string url, Action routeBuilder) => + StartWith(url, services => services.AddRouting(), app => app.UseRouter(routeBuilder)); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// The delegate that configures the . + /// A started that hosts the application. + public static IWebHost StartWith(Action app) => + StartWith(url: null, app: app); + + /// + /// Initializes and starts a new with pre-configured defaults. + /// See for details. + /// + /// The URL the hosted application will listen on. + /// The delegate that configures the . + /// A started that hosts the application. + public static IWebHost StartWith(string url, Action app) => + StartWith(url: url, configureServices: null, app: app); + + private static IWebHost StartWith(string url, Action configureServices, Action app) + { + var builder = CreateDefaultBuilder(); + + if (!string.IsNullOrEmpty(url)) + { + builder.UseUrls(url); + } + + if (configureServices != null) + { + builder.ConfigureServices(configureServices); + } + + var host = builder + .Configure(app) + .Build(); + + host.Start(); + + return host; + } + + /// + /// Initializes a new instance of the class with pre-configured defaults. + /// + /// + /// The following defaults are applied to the returned : + /// use Kestrel as the web server, + /// set the to the result of , + /// load from 'appsettings.json' and 'appsettings.[].json', + /// load from User Secrets when is 'Development' using the entry assembly, + /// load from environment variables, + /// configures the to log to the console, + /// enables IIS integration, + /// and adds the developer exception page when is 'Development' + /// + /// The initialized . + public static IWebHostBuilder CreateDefaultBuilder() => + CreateDefaultBuilder(args: null); + + /// + /// Initializes a new instance of the class with pre-configured defaults. + /// + /// + /// The following defaults are applied to the returned : + /// use Kestrel as the web server, + /// set the to the result of , + /// load from 'appsettings.json' and 'appsettings.[].json', + /// load from User Secrets when is 'Development' using the entry assembly, + /// load from environment variables, + /// load from supplied command line args, + /// configures the to log to the console, + /// enables IIS integration, + /// and adds the developer exception page when is 'Development' + /// + /// The command line args. + /// The initialized . + public static IWebHostBuilder CreateDefaultBuilder(string[] args) + { + var builder = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .ConfigureAppConfiguration((hostingContext, config) => + { + var env = hostingContext.HostingEnvironment; + + config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); + + if (env.IsDevelopment()) + { + var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName)); + if (appAssembly != null) + { + config.AddUserSecrets(appAssembly); + } + } + + config.AddEnvironmentVariables(); + + if (args != null) + { + config.AddCommandLine(args); + } + }) + .ConfigureLogging(logging => + { + logging.AddConsole(); + }) + .UseIISIntegration() + .ConfigureServices(services => + { + services.AddSingleton(); + }); + + return builder; + } + } +} diff --git a/src/Microsoft.AspNetCore/WebHostStartupFilter.cs b/src/Microsoft.AspNetCore/WebHostStartupFilter.cs new file mode 100644 index 0000000000..43690799ce --- /dev/null +++ b/src/Microsoft.AspNetCore/WebHostStartupFilter.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.AspNetCore +{ + internal class WebHostStartupFilter : IStartupFilter + { + public Action Configure(Action next) + { + return app => + { + var env = app.ApplicationServices.GetService(); + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + next(app); + }; + } + } +} From 3a4a3ca291e6e82189df3d58d18d92791535691b Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 21 Apr 2017 19:13:33 -0700 Subject: [PATCH 060/361] WebHost static API updates - Specify ApplicationName when wrapping RequestDelegate or RouteBuilder - Add debug logger by default --- build/common.props | 2 +- samples/SampleApp/Program.cs | 22 ++++++++++++++++ samples/SampleApp/SampleApp.csproj | 1 + samples/SampleApp/wwwroot/htmlpage.html | 12 +++++++++ src/Microsoft.AspNetCore/WebHost.cs | 34 +++++++++++++++++-------- 5 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 samples/SampleApp/wwwroot/htmlpage.html diff --git a/build/common.props b/build/common.props index 6a1fb41e41..814ece1d6c 100644 --- a/build/common.props +++ b/build/common.props @@ -40,6 +40,7 @@ + @@ -149,7 +150,6 @@ - diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs index 30ba926b95..9e3da42b41 100644 --- a/samples/SampleApp/Program.cs +++ b/samples/SampleApp/Program.cs @@ -2,7 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Threading.Tasks; using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; @@ -19,6 +21,8 @@ namespace SampleApp CustomRouter(); + CustomApplicationBuilder(); + StartupClass(args); } @@ -59,6 +63,24 @@ namespace SampleApp } } + private static void CustomApplicationBuilder() + { + // Using a application builder + using (WebHost.StartWith(app => + { + app.UseStaticFiles(); + app.Run(async context => + { + await context.Response.WriteAsync("Hello, World!"); + }); + })) + { + //host.WaitForShutdown(); // TODO: https://github.com/aspnet/Hosting/issues/1022 + Console.WriteLine("Running CustomApplicationBuilder: Press any key to shutdown and start the next sample..."); + Console.ReadKey(); + } + } + private static void StartupClass(string[] args) { // Using defaults with a Startup class diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index a3520ca464..6f2a348a9f 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -12,6 +12,7 @@ + diff --git a/samples/SampleApp/wwwroot/htmlpage.html b/samples/SampleApp/wwwroot/htmlpage.html new file mode 100644 index 0000000000..ab3af6d3f7 --- /dev/null +++ b/samples/SampleApp/wwwroot/htmlpage.html @@ -0,0 +1,12 @@ + + + + + + + + + + A static HTML file. + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index c1c9a865a7..5bd9d11ba9 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -35,8 +35,11 @@ namespace Microsoft.AspNetCore /// The URL the hosted application will listen on. /// A delegate that handles requests to the application. /// A started that hosts the application. - public static IWebHost Start(string url, RequestDelegate app) => - StartWith(url, appBuilder => appBuilder.Run(app)); + public static IWebHost Start(string url, RequestDelegate app) + { + var startupAssemblyName = app.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name; + return StartWith(url: url, configureServices: null, app: appBuilder => appBuilder.Run(app), applicationName: startupAssemblyName); + } /// /// Initializes and starts a new with pre-configured defaults. @@ -54,8 +57,11 @@ namespace Microsoft.AspNetCore /// The URL the hosted application will listen on. /// A delegate that configures the router for handling requests to the application. /// A started that hosts the application. - public static IWebHost Start(string url, Action routeBuilder) => - StartWith(url, services => services.AddRouting(), app => app.UseRouter(routeBuilder)); + public static IWebHost Start(string url, Action routeBuilder) + { + var startupAssemblyName = routeBuilder.GetMethodInfo().DeclaringType.GetTypeInfo().Assembly.GetName().Name; + return StartWith(url, services => services.AddRouting(), appBuilder => appBuilder.UseRouter(routeBuilder), applicationName: startupAssemblyName); + } /// /// Initializes and starts a new with pre-configured defaults. @@ -74,9 +80,9 @@ namespace Microsoft.AspNetCore /// The delegate that configures the . /// A started that hosts the application. public static IWebHost StartWith(string url, Action app) => - StartWith(url: url, configureServices: null, app: app); + StartWith(url: url, configureServices: null, app: app, applicationName: null); - private static IWebHost StartWith(string url, Action configureServices, Action app) + private static IWebHost StartWith(string url, Action configureServices, Action app, string applicationName) { var builder = CreateDefaultBuilder(); @@ -90,9 +96,14 @@ namespace Microsoft.AspNetCore builder.ConfigureServices(configureServices); } - var host = builder - .Configure(app) - .Build(); + builder.Configure(app); + + if (!string.IsNullOrEmpty(applicationName)) + { + builder.UseSetting(WebHostDefaults.ApplicationKey, applicationName); + } + + var host = builder.Build(); host.Start(); @@ -109,7 +120,7 @@ namespace Microsoft.AspNetCore /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, - /// configures the to log to the console, + /// configures the to log to the console and debug output, /// enables IIS integration, /// and adds the developer exception page when is 'Development' /// @@ -128,7 +139,7 @@ namespace Microsoft.AspNetCore /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, /// load from supplied command line args, - /// configures the to log to the console, + /// configures the to log to the console and debug output, /// enables IIS integration, /// and adds the developer exception page when is 'Development' /// @@ -165,6 +176,7 @@ namespace Microsoft.AspNetCore .ConfigureLogging(logging => { logging.AddConsole(); + logging.AddDebug(); }) .UseIISIntegration() .ConfigureServices(services => From c6fcd743db6f0db4aae0db79f0c3d026f9ba976d Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 23 Apr 2017 23:43:30 -0700 Subject: [PATCH 061/361] Add more package to package cache. --- build/common.props | 14 ++++++++++++++ build/dependencies.props | 1 + .../Microsoft.AspNetCore.All.csproj | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/build/common.props b/build/common.props index 814ece1d6c..0b7e93f43f 100644 --- a/build/common.props +++ b/build/common.props @@ -69,6 +69,7 @@ + @@ -79,6 +80,12 @@ + + + + + + @@ -94,6 +101,7 @@ + @@ -125,13 +133,18 @@ + + + + + @@ -157,6 +170,7 @@ + diff --git a/build/dependencies.props b/build/dependencies.props index f5484bca6f..eb946addb3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,6 +2,7 @@ 2.0.0-* 1.0.0-* + 1.0.0-* 4.3.0 2.0.0-* 1.6.1 diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index a8f03f7ce0..80069f3af9 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -4,7 +4,7 @@ false - netstandard1.6 + netcoreapp2.0 aspnetcore Microsoft.AspNetCore.All false From 0f28da1234b9a3d564fddfc533e13f8c43d6a458 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 24 Apr 2017 14:31:07 -0700 Subject: [PATCH 062/361] Use correct version of M.A.Diagnostics.Identity.Service --- build/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/common.props b/build/common.props index 0b7e93f43f..821421aa3f 100644 --- a/build/common.props +++ b/build/common.props @@ -69,7 +69,7 @@ - + From 280a84906063d4fef2efab426b069c57a1f883af Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 24 Apr 2017 15:41:28 -0700 Subject: [PATCH 063/361] Move the target files to the correct location in .nupkg --- build/repo.targets | 2 +- src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 4 ++-- .../Microsoft.AspNetCore.All.targets | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename src/Microsoft.AspNetCore.All/build/{netstandard1.6 => netcoreapp2.0}/Microsoft.AspNetCore.All.targets (100%) diff --git a/build/repo.targets b/build/repo.targets index 9f7e31a399..d0f0df1dd6 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -93,7 +93,7 @@ - + diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 80069f3af9..5e2d6cb395 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/src/Microsoft.AspNetCore.All/build/netstandard1.6/Microsoft.AspNetCore.All.targets b/src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets similarity index 100% rename from src/Microsoft.AspNetCore.All/build/netstandard1.6/Microsoft.AspNetCore.All.targets rename to src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets From c77f7b7c778ba50dabf3fc429cc3532e83cb4419 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 24 Apr 2017 16:47:18 -0700 Subject: [PATCH 064/361] Add Microsoft.AspNetCore to Microsoft.AspNetCore.All This metapackage now contains the static WebHost API --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index 821421aa3f..df19991dbf 100644 --- a/build/common.props +++ b/build/common.props @@ -46,6 +46,7 @@ + From 8d1ac47d9f06ee03a15edf4fff17d66039a64095 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 24 Apr 2017 17:11:43 -0700 Subject: [PATCH 065/361] Remove cyclic dependency on self --- build/common.props | 10 ++++++++-- .../Microsoft.AspNetCore.All.csproj | 2 ++ .../Microsoft.AspNetCore.RuntimeStore.csproj | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/build/common.props b/build/common.props index df19991dbf..3e91ed6fb1 100644 --- a/build/common.props +++ b/build/common.props @@ -46,8 +46,6 @@ - - @@ -174,6 +172,10 @@ + + + + @@ -181,4 +183,8 @@ + + + + diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 5e2d6cb395..9607a4186a 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -12,7 +12,9 @@ + + diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 23c1cf58ee..8c2f6817ed 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -8,6 +8,7 @@ + From b1ef447ac32f2722afff850591d9fad4d06c9bf0 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 24 Apr 2017 18:02:08 -0700 Subject: [PATCH 066/361] Accidentally removed Antiforgery --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index 3e91ed6fb1..4fe5433f52 100644 --- a/build/common.props +++ b/build/common.props @@ -46,6 +46,7 @@ + From b5125caa44db4c3320088e23825bc0d29dc526f4 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 24 Apr 2017 19:05:45 -0700 Subject: [PATCH 067/361] Remove runtime store from sln --- MetaPackages.sln | 12 ++---------- build/common.props | 5 +---- .../Microsoft.AspNetCore.RuntimeStore.csproj | 1 - 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/MetaPackages.sln b/MetaPackages.sln index 6de1068cba..94b2aad881 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,12 +1,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26412.1 +VisualStudioVersion = 15.0.26419.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.All", "src\Microsoft.AspNetCore.All\Microsoft.AspNetCore.All.csproj", "{CC8F551E-213A-45E8-AECA-507C4DB4F164}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.All", "src\Microsoft.AspNetCore.All\Microsoft.AspNetCore.All.csproj", "{CC8F551E-213A-45E8-AECA-507C4DB4F164}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97D53BEB-A511-4FBE-B784-AB407D9A219F}" ProjectSection(SolutionItems) = preProject @@ -20,9 +20,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1 build\repo.targets = build\repo.targets EndProjectSection EndProject - -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.RuntimeStore", "src\Microsoft.AspNetCore.RuntimeStore\Microsoft.AspNetCore.RuntimeStore.csproj", "{A4585E19-FC49-43B4-9416-0BD3120EAD32}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F583C-C4CA-43E5-B31C-D21B7806E274}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" @@ -45,10 +42,6 @@ Global {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU - {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A4585E19-FC49-43B4-9416-0BD3120EAD32}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -58,6 +51,5 @@ Global {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} {AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274} - {A4585E19-FC49-43B4-9416-0BD3120EAD32} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/build/common.props b/build/common.props index 4fe5433f52..03c3d37eba 100644 --- a/build/common.props +++ b/build/common.props @@ -179,13 +179,10 @@ + - - - - diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 8c2f6817ed..23c1cf58ee 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -8,7 +8,6 @@ - From 98b1945d6529b56a39929cc3153c8930fd368d31 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 25 Apr 2017 03:04:32 -0700 Subject: [PATCH 068/361] Set TargetManifestFiles in PropertyGroup --- ...ublishWithAspNetCoreTargetManifest.targets | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets index 5fdccb650e..dc525e8c65 100644 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -1,14 +1,31 @@ - true + $(AspNetCoreTargetManifestRuntimeIdentifier) + + + + win7-x64 + win7-x86 + osx.10.12-x64 + linux-x64 + + + + $(TargetManifestFiles);$(MSBuildThisFileDirectory)manifest.$(ManifestRuntimeIdentifier).xml - - $(AspNetCoreTargetManifestRuntimeIdentifier) - - - - win7-x64 - win7-x86 - osx.10.12-x64 - linux-x64 - - @@ -40,9 +40,5 @@ Append the default ASP.NET Core runtime package store manifest during publish - - - $(TargetManifest);$(MSBuildThisFileDirectory)manifest.$(ManifestRuntimeIdentifier).xml - From 2004897188456e52e70338d15181d0476d84be3a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Apr 2017 11:04:09 -0700 Subject: [PATCH 069/361] Use Bundled NETStandard.Library \ NETCoreApp versions instead of explicitly specifying one --- build/common.props | 2 +- build/dependencies.props | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build/common.props b/build/common.props index 03c3d37eba..a1d8f8f90f 100644 --- a/build/common.props +++ b/build/common.props @@ -22,7 +22,7 @@ - + diff --git a/build/dependencies.props b/build/dependencies.props index eb946addb3..6484ded4ee 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,7 +5,5 @@ 1.0.0-* 4.3.0 2.0.0-* - 1.6.1 - 2.0.0-* - \ No newline at end of file + From c0d7d2cd4c793fa456c60a37708696e3e2ae6e8d Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 25 Apr 2017 14:36:17 -0700 Subject: [PATCH 070/361] Remove SignalR from .All MetaPackage and RuntimeStore --- build/common.props | 9 +-------- build/dependencies.props | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/build/common.props b/build/common.props index a1d8f8f90f..e3d6635a98 100644 --- a/build/common.props +++ b/build/common.props @@ -14,7 +14,7 @@ 2.0.0-$(VersionSuffix) - 1.0.0-$(VersionSuffix) + 1.0.0-$(VersionSuffix) @@ -119,13 +119,6 @@ - - - - - - - diff --git a/build/dependencies.props b/build/dependencies.props index 6484ded4ee..dc11d345dd 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,6 @@ 2.0.0-* - 1.0.0-* 1.0.0-* 4.3.0 2.0.0-* From e1a29f1b61ee379fef64ebab2f00fee65360575d Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 25 Apr 2017 17:38:12 -0700 Subject: [PATCH 071/361] Trim by all manifests --- ...ublishWithAspNetCoreTargetManifest.targets | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets index dc525e8c65..530ff2649c 100644 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -1,44 +1,26 @@ - true - $(AspNetCoreTargetManifestRuntimeIdentifier) + true - - win7-x64 - win7-x86 - osx.10.12-x64 - linux-x64 - - - - $(TargetManifestFiles);$(MSBuildThisFileDirectory)manifest.$(ManifestRuntimeIdentifier).xml + + $(TargetManifestFiles);$(MSBuildThisFileDirectory)manifest.win7-x64.xml;$(MSBuildThisFileDirectory)manifest.win7-x86.xml;$(MSBuildThisFileDirectory)manifest.osx.10.12-x64.xml;$(MSBuildThisFileDirectory)manifest.linux-x64.xml + Condition="'$(PublishWithAspNetCoreTargetManifest)'=='true'" > - - + Text="PublishWithAspNetCoreTargetManifest cannot be set to true for standalone apps." + Condition="'$(RuntimeIdentifier)'!='' or '$(RuntimeIdentifiers)'!=''" /> From 253ff713c896a809a8a2ae790d24459ecc4ee8ac Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Apr 2017 22:03:51 -0700 Subject: [PATCH 072/361] Branching for 2.0.0-preview1 --- NuGet.config | 2 +- build.ps1 | 2 +- build.sh | 2 +- build/dependencies.props | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8e65695611..fa4304af9c 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,7 @@ - + diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..225b1fe450 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview1.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..702b25c636 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview1.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi diff --git a/build/dependencies.props b/build/dependencies.props index dc11d345dd..d5c548605b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 2.0.0-* + 2.0.0-preview1-* 1.0.0-* 4.3.0 2.0.0-* From 4331c021b12829d1c0ea548d22d09e90e09d676b Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 26 Apr 2017 10:02:56 -0700 Subject: [PATCH 073/361] Clean up before AddManifestToNupkg --- build/repo.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/build/repo.targets b/build/repo.targets index d0f0df1dd6..5084b3c26c 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -91,6 +91,7 @@ + From 91e989e628d33a98bcdeed0202dc18a150fe2c6c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 26 Apr 2017 07:13:15 -0700 Subject: [PATCH 074/361] Updating package version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index c7150e64f4..6af4f81de2 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview1 + preview2 From 0d66125fdaee47e602a8387dfe68fc5c99a4333a Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 21 Apr 2017 19:13:33 -0700 Subject: [PATCH 075/361] WebHost static API updates - Specify ApplicationName when wrapping RequestDelegate or RouteBuilder - Add debug logger by default --- samples/SampleApp/SampleApp.csproj | 2 +- src/Microsoft.AspNetCore/WebHost.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index 6f2a348a9f..29af1bc91f 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 5bd9d11ba9..450d157ddd 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -69,8 +69,8 @@ namespace Microsoft.AspNetCore /// /// The delegate that configures the . /// A started that hosts the application. - public static IWebHost StartWith(Action app) => - StartWith(url: null, app: app); + public static IWebHost Start(Action app) => + Start(url: null, app: app); /// /// Initializes and starts a new with pre-configured defaults. From 735337f586cf06ae6819a6530cef538a3c260789 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 23 Apr 2017 23:21:59 -0700 Subject: [PATCH 076/361] Add functional tests --- MetaPackages.sln | 40 +++++ build/dependencies.props | 3 + src/Microsoft.AspNetCore/WebHost.cs | 4 +- ...icrosoft.AspNetCore.FunctionalTests.csproj | 20 +++ .../WebHostFunctionalTests.cs | 139 ++++++++++++++++++ .../CreateDefaultBuilderApp.csproj | 13 ++ .../CreateDefaultBuilderApp/Program.cs | 110 ++++++++++++++ .../appsettings.Development.json | 3 + .../CreateDefaultBuilderApp/appsettings.json | 3 + .../StartRequestDelegateUrlApp/Program.cs | 43 ++++++ .../StartRequestDelegateUrlApp.csproj | 12 ++ .../StartRouteBuilderUrlApp/Program.cs | 43 ++++++ .../StartRouteBuilderUrlApp.csproj | 12 ++ .../Program.cs | 45 ++++++ .../StartWithIApplicationBuilderUrlApp.csproj | 12 ++ 15 files changed, 500 insertions(+), 2 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.FunctionalTests.csproj create mode 100644 test/Microsoft.AspNetCore.Tests/WebHostFunctionalTests.cs create mode 100644 test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj create mode 100644 test/TestSites/CreateDefaultBuilderApp/Program.cs create mode 100644 test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json create mode 100644 test/TestSites/CreateDefaultBuilderApp/appsettings.json create mode 100644 test/TestSites/StartRequestDelegateUrlApp/Program.cs create mode 100644 test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj create mode 100644 test/TestSites/StartRouteBuilderUrlApp/Program.cs create mode 100644 test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj create mode 100644 test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs create mode 100644 test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj diff --git a/MetaPackages.sln b/MetaPackages.sln index 94b2aad881..5fbde25dd9 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -24,6 +24,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.Tests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestSites", "TestSites", "{EC22261D-0DE1-47DE-8F7C-072675D6F5B4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRouteBuilderUrlApp", "test\TestSites\StartRouteBuilderUrlApp\StartRouteBuilderUrlApp.csproj", "{AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartWithIApplicationBuilderUrlApp", "test\TestSites\StartWithIApplicationBuilderUrlApp\StartWithIApplicationBuilderUrlApp.csproj", "{3A85FA52-F601-422E-A42E-9F187DB28492}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRequestDelegateUrlApp", "test\TestSites\StartRequestDelegateUrlApp\StartRequestDelegateUrlApp.csproj", "{401C741B-6C7C-4E08-9F09-C3D43D22C0DE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateDefaultBuilderApp", "test\TestSites\CreateDefaultBuilderApp\CreateDefaultBuilderApp.csproj", "{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -42,6 +56,26 @@ Global {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU + {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Release|Any CPU.Build.0 = Release|Any CPU + {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA}.Release|Any CPU.Build.0 = Release|Any CPU + {3A85FA52-F601-422E-A42E-9F187DB28492}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A85FA52-F601-422E-A42E-9F187DB28492}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A85FA52-F601-422E-A42E-9F187DB28492}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A85FA52-F601-422E-A42E-9F187DB28492}.Release|Any CPU.Build.0 = Release|Any CPU + {401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {401C741B-6C7C-4E08-9F09-C3D43D22C0DE}.Release|Any CPU.Build.0 = Release|Any CPU + {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -51,5 +85,11 @@ Global {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} {AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274} + {C72A756A-D29D-44C7-83D4-821DBE82DBCA} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} + {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} + {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + {3A85FA52-F601-422E-A42E-9F187DB28492} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + {401C741B-6C7C-4E08-9F09-C3D43D22C0DE} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} EndGlobalSection EndGlobal diff --git a/build/dependencies.props b/build/dependencies.props index d5c548605b..ee92e50823 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,8 +1,11 @@ + 0.4.0-* 2.0.0-preview1-* 1.0.0-* 4.3.0 2.0.0-* + 15.0.0 + 2.2.0 diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 450d157ddd..5bd9d11ba9 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -69,8 +69,8 @@ namespace Microsoft.AspNetCore /// /// The delegate that configures the . /// A started that hosts the application. - public static IWebHost Start(Action app) => - Start(url: null, app: app); + public static IWebHost StartWith(Action app) => + StartWith(url: null, app: app); /// /// Initializes and starts a new with pre-configured defaults. diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.FunctionalTests.csproj new file mode 100644 index 0000000000..d29ae617ca --- /dev/null +++ b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -0,0 +1,20 @@ + + + + + + netcoreapp2.0 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Tests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.Tests/WebHostFunctionalTests.cs new file mode 100644 index 0000000000..f925eb91f4 --- /dev/null +++ b/test/Microsoft.AspNetCore.Tests/WebHostFunctionalTests.cs @@ -0,0 +1,139 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace Microsoft.AspNetCore.Tests +{ + public class WebHostFunctionalTests : LoggedTest + { + private readonly string _testSitesPath; + + public WebHostFunctionalTests(ITestOutputHelper output) : base(output) + { + _testSitesPath = GetTestSitesPath(); + } + + [Fact] + public async Task Start_RequestDelegate_Url() + { + await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync(string.Empty), "StartRequestDelegateUrlApp"); + } + + [Fact] + public async Task Start_RouteBuilder_Url() + { + await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync("/route"), "StartRouteBuilderUrlApp"); + } + + [Fact] + public async Task StartWith_IApplicationBuilder_Url() + { + await ExecuteStartOrStartWithTest(deploymentResult => deploymentResult.HttpClient.GetAsync(string.Empty), "StartWithIApplicationBuilderUrlApp"); + } + + [Fact] + public async Task CreateDefaultBuilder_InitializeWithDefaults() + { + var applicationName = "CreateDefaultBuilderApp"; + await ExecuteTestApp(applicationName, async (deploymentResult, logger) => + { + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var errorResponse = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync("/error"), logger, deploymentResult.HostShutdownToken); + + var responseText = await response.Content.ReadAsStringAsync(); + var errorResponseText = await errorResponse.Content.ReadAsStringAsync(); + try + { + // Assert server is Kestrel + Assert.Equal("Kestrel", response.Headers.Server.ToString()); + + // The application name will be sent in response when all asserts succeed in the test app. + Assert.Equal(applicationName, responseText); + + // Assert UseDeveloperExceptionPage is called in WebHostStartupFilter. + Assert.Contains("An unhandled exception occurred while processing the request.", errorResponseText); + } + catch (XunitException) + { + logger.LogWarning(response.ToString()); + logger.LogWarning(responseText); + throw; + } + }, setTestEnvVars: true); + } + + private async Task ExecuteStartOrStartWithTest(Func> getResponse, string applicationName) + { + await ExecuteTestApp(applicationName, async (deploymentResult, logger) => + { + var response = await RetryHelper.RetryRequest(() => getResponse(deploymentResult), logger, deploymentResult.HostShutdownToken); + + var responseText = await response.Content.ReadAsStringAsync(); + try + { + Assert.Equal(applicationName, responseText); + } + catch (XunitException) + { + logger.LogWarning(response.ToString()); + logger.LogWarning(responseText); + throw; + } + }); + } + + private async Task ExecuteTestApp(string applicationName, Func assertAction, bool setTestEnvVars = false) + { + using (StartLog(out var loggerFactory, applicationName)) + { + var logger = loggerFactory.CreateLogger(nameof(WebHost.Start)); + var deploymentParameters = new DeploymentParameters(Path.Combine(_testSitesPath, applicationName), ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64); + + if (setTestEnvVars) + { + deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("aspnetcore_environment", "Development")); + deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("envKey", "envValue")); + } + + using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) + { + var deploymentResult = await deployer.DeployAsync(); + + await assertAction(deploymentResult, logger); + } + } + } + + private static string GetTestSitesPath() + { + var applicationBasePath = AppContext.BaseDirectory; + + var directoryInfo = new DirectoryInfo(applicationBasePath); + do + { + var solutionFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, "MetaPackages.sln")); + if (solutionFileInfo.Exists) + { + return Path.GetFullPath(Path.Combine(directoryInfo.FullName, "test", "TestSites")); + } + + directoryInfo = directoryInfo.Parent; + } + while (directoryInfo.Parent != null); + + throw new Exception($"Solution root could not be found using {applicationBasePath}"); + } + } +} diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj new file mode 100644 index 0000000000..0956c47f07 --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp2.0 + aspnetcore-CreateDefaultBuilder-20170424224131 + + + + + + + \ No newline at end of file diff --git a/test/TestSites/CreateDefaultBuilderApp/Program.cs b/test/TestSites/CreateDefaultBuilderApp/Program.cs new file mode 100644 index 0000000000..f14aec8f93 --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderApp/Program.cs @@ -0,0 +1,110 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Console; +using Microsoft.Extensions.Logging.Debug; + +namespace CreateDefaultBuilderApp +{ + public class Program + { + static void Main(string[] args) + { + string responseMessage = string.Empty; + + WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) + .UseLoggerFactory(new TestLoggerFactory()) + .ConfigureServices((context, services) => + { + responseMessage = GetResponseMessage(context, services); + }) + .Configure(app => + { + app.Map("/error", subApp => + { + subApp.Run(context => throw new Exception()); + }); + app.Run(context => + { + return context.Response.WriteAsync(responseMessage); + }); + }) + .Build().Run(); + } + + private static string GetResponseMessage(WebHostBuilderContext context, IServiceCollection services) + { + // Verify ContentRootPath set + if (!string.Equals(Directory.GetCurrentDirectory(), context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) + { + return $"Current directory incorrect. Expected: {Directory.GetCurrentDirectory()} Actual: {context.HostingEnvironment.ContentRootPath}"; + } + + // Verify appsettings.json loaded + if (!string.Equals("settingsValue", context.Configuration["settingsKey"], StringComparison.Ordinal)) + { + return $"appsettings.json not loaded into Configuration."; + } + + // Verify appsettings.environment.json loaded + if (!string.Equals("devSettingsValue", context.Configuration["devSettingsKey"], StringComparison.Ordinal)) + { + return $"appsettings.{context.HostingEnvironment.EnvironmentName}.json not loaded into Configuration."; + } + + // TODO: Verify UserSecrets loaded + + // Verify environment variables loaded + if (!string.Equals("envValue", context.Configuration["envKey"], StringComparison.Ordinal)) + { + return $"Environment variables not loaded into Configuration."; + } + + // Verify command line arguments loaded + if (!string.Equals("cliValue", context.Configuration["cliKey"], StringComparison.Ordinal)) + { + return $"Command line arguments not loaded into Configuration."; + } + + var testLoggerFactory = (TestLoggerFactory)context.LoggerFactory; + + // Verify AddConsole called + if (!testLoggerFactory.Providers.Any(provider => provider is ConsoleLoggerProvider)) + { + return $"Console logger not added to ILoggerFactory."; + } + + // Verify AddDebug called + if (!testLoggerFactory.Providers.Any(provider => provider is DebugLoggerProvider)) + { + return $"Debug logger not added to ILoggerFactory."; + } + + // TODO: Verify UseIISIntegration called + + return context.HostingEnvironment.ApplicationName; + } + + private class TestLoggerFactory : ILoggerFactory + { + public IList Providers { get; } = new List(); + + public void AddProvider(ILoggerProvider provider) => Providers.Add(provider); + + public ILogger CreateLogger(string categoryName) => NullLogger.Instance; + + public void Dispose() { } + } + } +} \ No newline at end of file diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json b/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json new file mode 100644 index 0000000000..d2ccc50d64 --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json @@ -0,0 +1,3 @@ +{ + "devSettingsKey": "devSettingsValue" +} diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.json b/test/TestSites/CreateDefaultBuilderApp/appsettings.json new file mode 100644 index 0000000000..bc5ff92c67 --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderApp/appsettings.json @@ -0,0 +1,3 @@ +{ + "settingsKey": "settingsValue" +} diff --git a/test/TestSites/StartRequestDelegateUrlApp/Program.cs b/test/TestSites/StartRequestDelegateUrlApp/Program.cs new file mode 100644 index 0000000000..351f870b56 --- /dev/null +++ b/test/TestSites/StartRequestDelegateUrlApp/Program.cs @@ -0,0 +1,43 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace StartRequestDelegateUrlApp +{ + public class Program + { + static void Main(string[] args) + { + var messageSent = new ManualResetEventSlim(false); + + using (var host = WebHost.Start("http://127.0.0.1:0", async context => + { + // Respond with the ApplicationName. + var env = context.RequestServices.GetRequiredService(); + await context.Response.WriteAsync(env.ApplicationName); + messageSent.Set(); + })) + { + // Need these for test deployer to consider host deployment successful + // The address written here is used by the client to send requests + var addresses = host.ServerFeatures.Get().Addresses; + foreach (var address in addresses) + { + Console.WriteLine($"Now listening on: {address}"); + } + Console.WriteLine("Application started. Press Ctrl+C to shut down."); + + // Shut down after message sent or timeout + messageSent.Wait(TimeSpan.FromSeconds(30)); + + } + } + } +} \ No newline at end of file diff --git a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj new file mode 100644 index 0000000000..0c089dbc33 --- /dev/null +++ b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.0 + + + + + + + \ No newline at end of file diff --git a/test/TestSites/StartRouteBuilderUrlApp/Program.cs b/test/TestSites/StartRouteBuilderUrlApp/Program.cs new file mode 100644 index 0000000000..5aa13ea396 --- /dev/null +++ b/test/TestSites/StartRouteBuilderUrlApp/Program.cs @@ -0,0 +1,43 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.DependencyInjection; + +namespace StartRequestDelegateUrlApp +{ + public class Program + { + static void Main(string[] args) + { + var messageSent = new ManualResetEventSlim(false); + + using (var host = WebHost.Start("http://127.0.0.1:0", router => + router.MapGet("route", async (req, res, data) => + { + var env = req.HttpContext.RequestServices.GetRequiredService(); + await res.WriteAsync(env.ApplicationName); + messageSent.Set(); + }))) + { + // Need these for test deployer to consider host deployment successful + // The address written here is used by the client to send requests + var addresses = host.ServerFeatures.Get().Addresses; + foreach (var address in addresses) + { + Console.WriteLine($"Now listening on: {address}"); + } + Console.WriteLine("Application started. Press Ctrl+C to shut down."); + + // Shut down after message sent or timeout + messageSent.Wait(TimeSpan.FromSeconds(30)); + } + } + } +} \ No newline at end of file diff --git a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj new file mode 100644 index 0000000000..0c089dbc33 --- /dev/null +++ b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.0 + + + + + + + \ No newline at end of file diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs b/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs new file mode 100644 index 0000000000..f904dcff57 --- /dev/null +++ b/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs @@ -0,0 +1,45 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace StartWithIApplicationBuilderUrlApp +{ + public class Program + { + static void Main(string[] args) + { + var messageSent = new ManualResetEventSlim(false); + + using (var host = WebHost.StartWith("http://127.0.0.1:0", app => + { + app.Run(async context => + { + var env = context.RequestServices.GetRequiredService(); + await context.Response.WriteAsync(env.ApplicationName); + messageSent.Set(); + }); + })) + { + // Need these for test deployer to consider host deployment successful + // The address written here is used by the client to send requests + var addresses = host.ServerFeatures.Get().Addresses; + foreach (var address in addresses) + { + Console.WriteLine($"Now listening on: {address}"); + } + Console.WriteLine("Application started. Press Ctrl+C to shut down."); + + // Shut down after message sent or timeout + messageSent.Wait(TimeSpan.FromSeconds(30)); + } + } + } +} \ No newline at end of file diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj new file mode 100644 index 0000000000..0c089dbc33 --- /dev/null +++ b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.0 + + + + + + + \ No newline at end of file From ab0bf52f3b83d98502509b1c24f01c07c731b12a Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 26 Apr 2017 14:38:16 -0700 Subject: [PATCH 077/361] Rebase fix --- samples/SampleApp/SampleApp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index 29af1bc91f..6f2a348a9f 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -8,7 +8,7 @@ - + From 1160784d089a482e0c8b5ce23644a7b9af66df79 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 26 Apr 2017 14:13:45 -0700 Subject: [PATCH 078/361] Add Microsoft.Extensions.Hosting.Abstractions --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index e3d6635a98..b8f34e09fe 100644 --- a/build/common.props +++ b/build/common.props @@ -153,6 +153,7 @@ + From 3ae799c9c8395c61403332f3a41ea36170de7394 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 26 Apr 2017 13:17:26 -0700 Subject: [PATCH 079/361] Zip store and deps together --- build/repo.targets | 26 ++++++++++++------- .../Microsoft.AspNetCore.RuntimeStore.csproj | 6 +++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 5084b3c26c..787bead341 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -5,9 +5,10 @@ $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ $(MetaPackagePath)Microsoft.AspNetCore.RuntimeStore.csproj $(MetaPackagePath)bin\work\ - $(MetaPackagePath)bin\packageCache\ + $(MetaPackagePath)bin\packageCache\ $(MetaPackagePath)bin\deps\ $(RepositoryRoot)artifacts\ + $(ArtifactsDir)zip\ $(ArtifactsDir)temp\ $(RepositoryRoot)tools\ $(RepositoryRoot).deps\build\ @@ -41,7 +42,6 @@ osx $(ArtifactsDir)Build.RuntimeStore.$(OutputZipSufix)-$(VersionSuffix).zip - $(ArtifactsDir)Build.Deps.$(OutputZipSufix)-$(VersionSuffix).zip @@ -59,23 +59,29 @@ - + - - + + - - + manifest.%(RIDs.Identity).xml + - - + - + + + + + + + + diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 23c1cf58ee..27d7905342 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -12,9 +12,11 @@ - + + $([System.String]::Copy('%(Filename)').Replace('.deps','')) + - + \ No newline at end of file From 21de3069630130b761d5f79cb29866f954b35024 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Wed, 26 Apr 2017 16:47:51 -0700 Subject: [PATCH 080/361] Bind Kestrel options to config by default (#30). --- MetaPackages.sln | 15 +- samples/AppSettings/AppSettings.csproj | 23 +++ samples/AppSettings/Program.cs | 21 +++ .../Properties/launchSettings.json | 27 +++ samples/AppSettings/appsettings.json | 63 +++++++ samples/AppSettings/testCert.pfx | Bin 0 -> 2483 bytes samples/SampleApp/SampleApp.csproj | 2 +- src/Microsoft.AspNetCore/CertificateLoader.cs | 173 ++++++++++++++++++ .../KestrelServerOptionsSetup.cs | 103 +++++++++++ .../Microsoft.AspNetCore.csproj | 2 +- src/Microsoft.AspNetCore/WebHost.cs | 3 + ...icrosoft.AspNetCore.FunctionalTests.csproj | 8 + .../WebHostFunctionalTests.cs | 133 +++++++++++++- test/TestArtifacts/testCert.pfx | Bin 0 -> 2483 bytes 14 files changed, 569 insertions(+), 4 deletions(-) create mode 100644 samples/AppSettings/AppSettings.csproj create mode 100644 samples/AppSettings/Program.cs create mode 100644 samples/AppSettings/Properties/launchSettings.json create mode 100644 samples/AppSettings/appsettings.json create mode 100644 samples/AppSettings/testCert.pfx create mode 100644 src/Microsoft.AspNetCore/CertificateLoader.cs create mode 100644 src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs rename test/{Microsoft.AspNetCore.Tests => Microsoft.AspNetCore.FunctionalTests}/Microsoft.AspNetCore.FunctionalTests.csproj (75%) rename test/{Microsoft.AspNetCore.Tests => Microsoft.AspNetCore.FunctionalTests}/WebHostFunctionalTests.cs (58%) create mode 100644 test/TestArtifacts/testCert.pfx diff --git a/MetaPackages.sln b/MetaPackages.sln index 5fbde25dd9..d70150c623 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26419.0 +VisualStudioVersion = 15.0.26424.2 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -24,6 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{192F EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppSettings", "samples\AppSettings\AppSettings.csproj", "{5009D7C8-6061-49CF-9A30-23B309BBEFB0}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.Tests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}" @@ -38,6 +40,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRequestDelegateUrlApp" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateDefaultBuilderApp", "test\TestSites\CreateDefaultBuilderApp\CreateDefaultBuilderApp.csproj", "{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestArtifacts", "TestArtifacts", "{9BBA7A0A-109A-4AC8-B6EF-A52EA7CF1D90}" + ProjectSection(SolutionItems) = preProject + test\TestArtifacts\testCert.pfx = test\TestArtifacts\testCert.pfx + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -56,6 +63,10 @@ Global {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.Build.0 = Release|Any CPU + {5009D7C8-6061-49CF-9A30-23B309BBEFB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5009D7C8-6061-49CF-9A30-23B309BBEFB0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5009D7C8-6061-49CF-9A30-23B309BBEFB0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5009D7C8-6061-49CF-9A30-23B309BBEFB0}.Release|Any CPU.Build.0 = Release|Any CPU {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Debug|Any CPU.Build.0 = Debug|Any CPU {C72A756A-D29D-44C7-83D4-821DBE82DBCA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -85,11 +96,13 @@ Global {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} {AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274} + {5009D7C8-6061-49CF-9A30-23B309BBEFB0} = {192F583C-C4CA-43E5-B31C-D21B7806E274} {C72A756A-D29D-44C7-83D4-821DBE82DBCA} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} {AB42054B-1801-4FEE-B5C3-8529C6D7BFDA} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {3A85FA52-F601-422E-A42E-9F187DB28492} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {401C741B-6C7C-4E08-9F09-C3D43D22C0DE} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + {9BBA7A0A-109A-4AC8-B6EF-A52EA7CF1D90} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} EndGlobalSection EndGlobal diff --git a/samples/AppSettings/AppSettings.csproj b/samples/AppSettings/AppSettings.csproj new file mode 100644 index 0000000000..621da3c9ca --- /dev/null +++ b/samples/AppSettings/AppSettings.csproj @@ -0,0 +1,23 @@ + + + + + + netcoreapp2.0 + aspnetcore-MetaPackagesAppSettings-20170421155031 + + + + + + + + + + + + + + + + diff --git a/samples/AppSettings/Program.cs b/samples/AppSettings/Program.cs new file mode 100644 index 0000000000..5db5710d52 --- /dev/null +++ b/samples/AppSettings/Program.cs @@ -0,0 +1,21 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Http; + +namespace AppSettings +{ + public class Program + { + public static void Main(string[] args) + { + using (WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) + { + Console.WriteLine("Running application: Press any key to shutdown..."); + Console.ReadKey(); + } + } + } +} diff --git a/samples/AppSettings/Properties/launchSettings.json b/samples/AppSettings/Properties/launchSettings.json new file mode 100644 index 0000000000..fe806c5dc4 --- /dev/null +++ b/samples/AppSettings/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:53434/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "AppSettings": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:53435" + } + } +} diff --git a/samples/AppSettings/appsettings.json b/samples/AppSettings/appsettings.json new file mode 100644 index 0000000000..da7253554d --- /dev/null +++ b/samples/AppSettings/appsettings.json @@ -0,0 +1,63 @@ +{ + "Kestrel": { + "EndPoints": { + "Http": { + "Address": "127.0.0.1", + "Port": 8081 + }, + "HttpV6": { + "Address": "::1", + "Port": 8081 + }, + // Add testCert.pfx to the current user's certificate store to enable this scenario. + //"HttpsInlineCertStore": { + // "Address": "127.0.0.1", + // "Port": 8082, + // "Certificate": { + // "Source": "Store", + // "Subject": "cn=localhost", + // "StoreName": "My", + // "StoreLocation": "CurrentUser", + // "AllowInvalid": "True" + // } + //}, + "HttpsInlineCertFile": { + "Address": "127.0.0.1", + "Port": 8083, + "Certificate": { + "Source": "File", + "Path": "testCert.pfx", + // TODO: remove when dotnet user-secrets is working again + "Password": "testPassword", + } + }, + // Add testCert.pfx to the current user's certificate store to enable this scenario. + //"HttpsCertStore": { + // "Address": "127.0.0.1", + // "Port": 8084, + // "Certificate": "TestCertInStore" + //}, + "HttpsCertFile": { + "Address": "127.0.0.1", + "Port": 8085, + "Certificate": "TestCert" + } + } + }, + "Certificates": { + "TestCert": { + "Source": "File", + "Path": "testCert.pfx", + // TODO: remove when dotnet user-secrets is working again + "Password": "testPassword" + }, + // Add testCert.pfx to the current user's certificate store to enable this scenario. + //"TestCertInStore": { + // "Source": "Store", + // "Subject": "cn=localhost", + // "StoreName": "My", + // "StoreLocation": "CurrentUser", + // "AllowInvalid": "True" + //} + } +} diff --git a/samples/AppSettings/testCert.pfx b/samples/AppSettings/testCert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..7118908c2d730670c16e9f8b2c532a262c951989 GIT binary patch literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b literal 0 HcmV?d00001 diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index 6f2a348a9f..37ac635939 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -1,6 +1,6 @@  - + netcoreapp2.0 diff --git a/src/Microsoft.AspNetCore/CertificateLoader.cs b/src/Microsoft.AspNetCore/CertificateLoader.cs new file mode 100644 index 0000000000..95339040a1 --- /dev/null +++ b/src/Microsoft.AspNetCore/CertificateLoader.cs @@ -0,0 +1,173 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using Microsoft.Extensions.Configuration; + +namespace Microsoft.AspNetCore +{ + /// + /// A helper class to load certificates from files and certificate stores based on data. + /// + public static class CertificateLoader + { + /// + /// Loads one or more certificates from a single source. + /// + /// An with information about a certificate source. + /// The certificate password, in case it's being loaded from a file. + /// The loaded certificates. + public static X509Certificate2 Load(IConfiguration certificateConfiguration, string password) + { + var sourceKind = certificateConfiguration.GetValue("Source"); + + CertificateSource certificateSource; + switch (sourceKind.ToLowerInvariant()) + { + case "file": + certificateSource = new CertificateFileSource(password); + break; + case "store": + certificateSource = new CertificateStoreSource(); + break; + default: + throw new InvalidOperationException($"Invalid certificate source kind: {sourceKind}"); + } + + certificateConfiguration.Bind(certificateSource); + return certificateSource.Load(); + } + + /// + /// Loads all certificates specified in an . + /// + /// The root . + /// + /// A dictionary mapping certificate names to loaded certificates. + /// + public static Dictionary LoadAll(IConfiguration configurationRoot) + { + return configurationRoot.GetSection("Certificates").GetChildren() + .ToDictionary( + certificateSource => certificateSource.Key, + certificateSource => Load(certificateSource, certificateSource["Password"])); + } + + private abstract class CertificateSource + { + public string Source { get; set; } + + public abstract X509Certificate2 Load(); + } + + private class CertificateFileSource : CertificateSource + { + private readonly string _password; + + public CertificateFileSource(string password) + { + _password = password; + } + + public string Path { get; set; } + + public override X509Certificate2 Load() + { + var certificate = TryLoad(X509KeyStorageFlags.DefaultKeySet, out var error) + ?? TryLoad(X509KeyStorageFlags.UserKeySet, out error) + #if NETCOREAPP2_0 + ?? TryLoad(X509KeyStorageFlags.EphemeralKeySet, out error) + #endif + ; + + if (error != null) + { + throw error; + } + + return certificate; + } + + private X509Certificate2 TryLoad(X509KeyStorageFlags flags, out Exception exception) + { + try + { + var loadedCertificate = new X509Certificate2(Path, _password, flags); + exception = null; + return loadedCertificate; + } + catch (Exception e) + { + exception = e; + return null; + } + } + } + + private class CertificateStoreSource : CertificateSource + { + public string Subject { get; set; } + public string StoreName { get; set; } + public string StoreLocation { get; set; } + public bool AllowInvalid { get; set; } + + public override X509Certificate2 Load() + { + if (!Enum.TryParse(StoreLocation, ignoreCase: true, result: out StoreLocation storeLocation)) + { + throw new InvalidOperationException($"Invalid store location: {StoreLocation}"); + } + + using (var store = new X509Store(StoreName, storeLocation)) + { + X509Certificate2Collection storeCertificates = null; + X509Certificate2Collection foundCertificates = null; + X509Certificate2 foundCertificate = null; + + try + { + store.Open(OpenFlags.ReadOnly); + storeCertificates = store.Certificates; + foundCertificates = storeCertificates.Find(X509FindType.FindBySubjectDistinguishedName, Subject, validOnly: !AllowInvalid); + foundCertificate = foundCertificates + .OfType() + .OrderByDescending(certificate => certificate.NotAfter) + .FirstOrDefault(); + + if (foundCertificate == null) + { + throw new InvalidOperationException($"No certificate found for {Subject} in store {StoreName} in {StoreLocation}"); + } + + return foundCertificate; + } + finally + { + if (foundCertificate != null) + { + storeCertificates.Remove(foundCertificate); + foundCertificates.Remove(foundCertificate); + } + + DisposeCertificates(storeCertificates); + DisposeCertificates(foundCertificates); + } + } + } + + private void DisposeCertificates(X509Certificate2Collection certificates) + { + if (certificates != null) + { + foreach (var certificate in certificates) + { + certificate.Dispose(); + } + } + } + } + } +} diff --git a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs new file mode 100644 index 0000000000..888ece3903 --- /dev/null +++ b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs @@ -0,0 +1,103 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Security.Cryptography.X509Certificates; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Server.Kestrel.Core; +using Microsoft.AspNetCore.Server.Kestrel.Https; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; + +namespace Microsoft.AspNetCore +{ + /// + /// Binds Kestrel configuration. + /// + public class KestrelServerOptionsSetup : IConfigureOptions + { + private readonly IConfiguration _configurationRoot; + + /// + /// Creates a new instance of . + /// + /// The root . + public KestrelServerOptionsSetup(IConfiguration configurationRoot) + { + _configurationRoot = configurationRoot; + } + + /// + /// Configures a instance. + /// + /// The to configure. + public void Configure(KestrelServerOptions options) + { + BindConfiguration(options); + } + + private void BindConfiguration(KestrelServerOptions options) + { + var certificates = CertificateLoader.LoadAll(_configurationRoot); + var endPoints = _configurationRoot.GetSection("Kestrel:EndPoints"); + + foreach (var endPoint in endPoints.GetChildren()) + { + BindEndPoint(options, endPoint, certificates); + } + } + + private void BindEndPoint( + KestrelServerOptions options, + IConfigurationSection endPoint, + Dictionary certificates) + { + var addressValue = endPoint.GetValue("Address"); + var portValue = endPoint.GetValue("Port"); + + IPAddress address; + if (!IPAddress.TryParse(addressValue, out address)) + { + throw new InvalidOperationException($"Invalid IP address: {addressValue}"); + } + + int port; + if (!int.TryParse(portValue, out port)) + { + throw new InvalidOperationException($"Invalid port: {portValue}"); + } + + options.Listen(address, port, listenOptions => + { + var certificateName = endPoint.GetValue("Certificate"); + + X509Certificate2 endPointCertificate = null; + if (certificateName != null) + { + if (!certificates.TryGetValue(certificateName, out endPointCertificate)) + { + throw new InvalidOperationException($"No certificate named {certificateName} found in configuration"); + } + } + else + { + var certificate = endPoint.GetSection("Certificate"); + + if (certificate.GetChildren().Any()) + { + endPointCertificate = CertificateLoader.Load(certificate, certificate["Password"]); + } + } + + if (endPointCertificate != null) + { + listenOptions.UseHttps(endPointCertificate); + } + }); + } + } +} diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index cae574de41..5350bf93a3 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 5bd9d11ba9..5cc626fd5e 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -8,9 +8,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore { @@ -182,6 +184,7 @@ namespace Microsoft.AspNetCore .ConfigureServices(services => { services.AddSingleton(); + services.AddTransient, KestrelServerOptionsSetup>(); }); return builder; diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj similarity index 75% rename from test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.FunctionalTests.csproj rename to test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index d29ae617ca..a4676dcc7f 100644 --- a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -6,6 +6,10 @@ netcoreapp2.0 + + + + @@ -17,4 +21,8 @@ + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Tests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs similarity index 58% rename from test/Microsoft.AspNetCore.Tests/WebHostFunctionalTests.cs rename to test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index f925eb91f4..99485cab7d 100644 --- a/test/Microsoft.AspNetCore.Tests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -4,9 +4,12 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Net.Http; -using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; @@ -74,6 +77,129 @@ namespace Microsoft.AspNetCore.Tests }, setTestEnvVars: true); } + [Theory] + [InlineData("127.0.0.1", "127.0.0.1")] + [InlineData("::1", "[::1]")] + public async Task BindsKestrelHttpEndPointFromConfiguration(string endPointAddress, string requestAddress) + { + try + { + File.WriteAllText("appsettings.json", @" +{ + ""Kestrel"": { + ""EndPoints"": { + ""EndPoint"": { + ""Address"": """ + endPointAddress + @""", + ""Port"": 0 + } + } + } +} +"); + using (var webHost = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) + { + var port = GetWebHostPort(webHost); + + Assert.NotEqual(0, port); + + using (var client = new HttpClient()) + { + var response = await client.GetAsync($"http://{requestAddress}:{port}"); + response.EnsureSuccessStatusCode(); + } + } + } + finally + { + File.Delete("appsettings.json"); + } + } + + [Fact] + public async Task BindsKestrelHttpsEndPointFromConfiguration_ReferencedCertificateFile() + { + try + { + File.WriteAllText("appsettings.json", @" +{ + ""Kestrel"": { + ""EndPoints"": { + ""EndPoint"": { + ""Address"": ""127.0.0.1"", + ""Port"": 0, + ""Certificate"": ""TestCert"" + } + } + }, + ""Certificates"": { + ""TestCert"": { + ""Source"": ""File"", + ""Path"": ""testCert.pfx"", + ""Password"": ""testPassword"" + } + } +} +"); + using (var webHost = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) + { + var port = GetWebHostPort(webHost); + + Assert.NotEqual(0, port); + + using (var client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = (msg, cert, chain, errors) => true })) + { + var response = await client.GetAsync($"https://127.0.0.1:{port}"); + response.EnsureSuccessStatusCode(); + } + } + } + finally + { + File.Delete("appsettings.json"); + } + } + + [Fact] + public async Task BindsKestrelHttpsEndPointFromConfiguration_InlineCertificateFile() + { + try + { + File.WriteAllText("appsettings.json", @" +{ + ""Kestrel"": { + ""EndPoints"": { + ""EndPoint"": { + ""Address"": ""127.0.0.1"", + ""Port"": 0, + ""Certificate"": { + ""Source"": ""File"", + ""Path"": ""testCert.pfx"", + ""Password"": ""testPassword"" + } + } + } + } +} +"); + using (var webHost = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) + { + var port = GetWebHostPort(webHost); + + Assert.NotEqual(0, port); + + using (var client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = (msg, cert, chain, errors) => true })) + { + var response = await client.GetAsync($"https://127.0.0.1:{port}"); + response.EnsureSuccessStatusCode(); + } + } + } + finally + { + File.Delete("appsettings.json"); + } + } + private async Task ExecuteStartOrStartWithTest(Func> getResponse, string applicationName) { await ExecuteTestApp(applicationName, async (deploymentResult, logger) => @@ -135,5 +261,10 @@ namespace Microsoft.AspNetCore.Tests throw new Exception($"Solution root could not be found using {applicationBasePath}"); } + + private static int GetWebHostPort(IWebHost webHost) + => webHost.ServerFeatures.Get().Addresses + .Select(serverAddress => new Uri(serverAddress).Port) + .FirstOrDefault(); } } diff --git a/test/TestArtifacts/testCert.pfx b/test/TestArtifacts/testCert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..7118908c2d730670c16e9f8b2c532a262c951989 GIT binary patch literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b literal 0 HcmV?d00001 From bd9c6600e8868c482527425feed8eb1d251ff490 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Wed, 26 Apr 2017 16:50:44 -0700 Subject: [PATCH 081/361] Fix reference to Microsoft.AspNetCore.FunctionalTests.csproj in solution file. --- MetaPackages.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MetaPackages.sln b/MetaPackages.sln index d70150c623..de2568595f 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -28,7 +28,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppSettings", "samples\AppS EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.Tests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.FunctionalTests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestSites", "TestSites", "{EC22261D-0DE1-47DE-8F7C-072675D6F5B4}" EndProject From a7abb0d78fc8588b368e6fdd47036336d35dc01f Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Wed, 26 Apr 2017 16:53:02 -0700 Subject: [PATCH 082/361] Remove Microsoft.Extensions.SecretManager.Tools tool reference so the build passes. --- samples/AppSettings/AppSettings.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/AppSettings/AppSettings.csproj b/samples/AppSettings/AppSettings.csproj index 621da3c9ca..bf6be606f3 100644 --- a/samples/AppSettings/AppSettings.csproj +++ b/samples/AppSettings/AppSettings.csproj @@ -16,8 +16,10 @@ + From cb4d44cb8e8b99a5f4e4f38c6272d35be8b01e98 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 26 Apr 2017 17:14:57 -0700 Subject: [PATCH 083/361] Fix MSB4011 warnings --- build/repo.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 787bead341..ded422ae3a 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -1,4 +1,4 @@ - + @@ -108,4 +108,4 @@ - \ No newline at end of file + From d4f39bf56b4cefadbc803e95c6379eab5431db77 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 27 Apr 2017 08:43:40 -0700 Subject: [PATCH 084/361] Validate scopes in Development environment in CreateDefaultBuilder (#61) --- src/Microsoft.AspNetCore/WebHost.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 5cc626fd5e..594eb6a0c5 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -181,6 +181,10 @@ namespace Microsoft.AspNetCore logging.AddDebug(); }) .UseIISIntegration() + .UseDefaultServiceProvider((context, options) => + { + options.ValidateScopes = context.HostingEnvironment.IsDevelopment(); + }) .ConfigureServices(services => { services.AddSingleton(); From 4ccb09c444a6711d672562e79f09045275630666 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 09:04:52 -0700 Subject: [PATCH 085/361] Package Fallback Folder archive generation (#70) --- .gitignore | 3 + MetaPackages.sln | 14 + build/BuildArchive.proj | 19 + build/common.props | 10 +- build/repo.props | 5 +- build/repo.targets | 83 +- .../Archive.AspNetCore.All.csproj | 31 + .../Microsoft.AspNetCore.RuntimeStore.csproj | 2 +- .../CompressionUtility.cs | 107 ++ .../ConsoleProgressReport.cs | 59 + .../IndexedArchive.cs | 538 ++++++ .../LZMA/Common/CRC.cs | 58 + .../LZMA/Common/InBuffer.cs | 75 + .../LZMA/Common/OutBuffer.cs | 50 + .../LZMA/Compress/LZ/IMatchFinder.cs | 27 + .../LZMA/Compress/LZ/LzBinTree.cs | 370 ++++ .../LZMA/Compress/LZ/LzInWindow.cs | 135 ++ .../LZMA/Compress/LZ/LzOutWindow.cs | 113 ++ .../LZMA/Compress/LZMA/LzmaBase.cs | 79 + .../LZMA/Compress/LZMA/LzmaDecoder.cs | 402 +++++ .../LZMA/Compress/LZMA/LzmaEncoder.cs | 1483 +++++++++++++++++ .../LZMA/Compress/RangeCoder/RangeCoder.cs | 237 +++ .../LZMA/Compress/RangeCoder/RangeCoderBit.cs | 120 ++ .../Compress/RangeCoder/RangeCoderBitTree.cs | 160 ++ src/Microsoft.DotNet.Archive/LZMA/ICoder.cs | 160 ++ src/Microsoft.DotNet.Archive/LZMA/README.md | 10 + .../Microsoft.DotNet.Archive.csproj | 14 + .../ProgressReport.cs | 29 + .../Properties/AssemblyInfo.cs | 6 + .../ThreadLocalZipArchive.cs | 59 + .../CommandLine/CommandArgument.cs | 29 + .../CommandLine/CommandLineApplication.cs | 693 ++++++++ .../CommandLine/CommandOption.cs | 135 ++ .../CommandLine/CommandOptionType.cs | 14 + .../CommandLine/CommandParsingException.cs | 45 + .../CommandLine/HelpMessageStrings.cs | 10 + .../CommandLine/LocalizableStrings.cs | 50 + .../CommonLocalizableStrings.cs | 189 +++ src/dotnet-archive/Program.cs | 96 ++ src/dotnet-archive/dotnet-archive.csproj | 15 + 40 files changed, 5727 insertions(+), 7 deletions(-) create mode 100644 build/BuildArchive.proj create mode 100644 src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj create mode 100644 src/Microsoft.DotNet.Archive/CompressionUtility.cs create mode 100644 src/Microsoft.DotNet.Archive/ConsoleProgressReport.cs create mode 100644 src/Microsoft.DotNet.Archive/IndexedArchive.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Common/CRC.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Common/InBuffer.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Common/OutBuffer.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/IMatchFinder.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzBinTree.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzInWindow.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzOutWindow.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaBase.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaDecoder.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaEncoder.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoder.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBit.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/ICoder.cs create mode 100644 src/Microsoft.DotNet.Archive/LZMA/README.md create mode 100644 src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj create mode 100644 src/Microsoft.DotNet.Archive/ProgressReport.cs create mode 100644 src/Microsoft.DotNet.Archive/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.DotNet.Archive/ThreadLocalZipArchive.cs create mode 100644 src/dotnet-archive/CommandLine/CommandArgument.cs create mode 100644 src/dotnet-archive/CommandLine/CommandLineApplication.cs create mode 100644 src/dotnet-archive/CommandLine/CommandOption.cs create mode 100644 src/dotnet-archive/CommandLine/CommandOptionType.cs create mode 100644 src/dotnet-archive/CommandLine/CommandParsingException.cs create mode 100644 src/dotnet-archive/CommandLine/HelpMessageStrings.cs create mode 100644 src/dotnet-archive/CommandLine/LocalizableStrings.cs create mode 100644 src/dotnet-archive/CommonLocalizableStrings.cs create mode 100644 src/dotnet-archive/Program.cs create mode 100644 src/dotnet-archive/dotnet-archive.csproj diff --git a/.gitignore b/.gitignore index ec975e873c..366d1c3744 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ project.lock.json .build/ .testPublish/ global.json + +# Dependencies from pre-requisite builds +.deps/ diff --git a/MetaPackages.sln b/MetaPackages.sln index de2568595f..95ab066bb5 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -45,6 +45,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestArtifacts", "TestArtifa test\TestArtifacts\testCert.pfx = test\TestArtifacts\testCert.pfx EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-archive", "src\dotnet-archive\dotnet-archive.csproj", "{AE4216BF-D471-471B-82F3-6B6D004F7D17}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Archive", "src\Microsoft.DotNet.Archive\Microsoft.DotNet.Archive.csproj", "{302400A0-98BB-4C04-88D4-C32DC2D4B945}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -87,6 +91,14 @@ Global {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.Build.0 = Debug|Any CPU {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.ActiveCfg = Release|Any CPU {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.Build.0 = Release|Any CPU + {AE4216BF-D471-471B-82F3-6B6D004F7D17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE4216BF-D471-471B-82F3-6B6D004F7D17}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE4216BF-D471-471B-82F3-6B6D004F7D17}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE4216BF-D471-471B-82F3-6B6D004F7D17}.Release|Any CPU.Build.0 = Release|Any CPU + {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Debug|Any CPU.Build.0 = Debug|Any CPU + {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Release|Any CPU.ActiveCfg = Release|Any CPU + {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -104,5 +116,7 @@ Global {401C741B-6C7C-4E08-9F09-C3D43D22C0DE} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {9BBA7A0A-109A-4AC8-B6EF-A52EA7CF1D90} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} + {AE4216BF-D471-471B-82F3-6B6D004F7D17} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + {302400A0-98BB-4C04-88D4-C32DC2D4B945} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/build/BuildArchive.proj b/build/BuildArchive.proj new file mode 100644 index 0000000000..eadad66b41 --- /dev/null +++ b/build/BuildArchive.proj @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/build/common.props b/build/common.props index b8f34e09fe..fcf40a899f 100644 --- a/build/common.props +++ b/build/common.props @@ -10,11 +10,15 @@ ..\..\build\Key.snk true true - $(VersionSuffix)-$(BuildNumber) + $(VersionSuffix) + + + $(VersionSuffix) + $(VersionSuffix)-$(BuildNumber) - 2.0.0-$(VersionSuffix) - 1.0.0-$(VersionSuffix) + 2.0.0-$(BuildVersionSuffix) + 1.0.0-$(BuildVersionSuffix) diff --git a/build/repo.props b/build/repo.props index c7b2520845..0b28f5ecaa 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,5 +1,8 @@ + + + - \ No newline at end of file + diff --git a/build/repo.targets b/build/repo.targets index 787bead341..09a0f36d7d 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -1,9 +1,17 @@ - + + $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ $(MetaPackagePath)Microsoft.AspNetCore.RuntimeStore.csproj + + + $(RepositoryRoot)src\Archive.AspNetCore.All\ + $(FallbackArchiveDir)Archive.AspNetCore.All.csproj + $(RepositoryRoot)src\dotnet-archive\dotnet-archive.csproj + $(RepositoryRoot)src\dotnet-archive\bin\$(Configuration)\netcoreapp2.0\dotnet-archive.dll + $(MetaPackagePath)bin\work\ $(MetaPackagePath)bin\packageCache\ $(MetaPackagePath)bin\deps\ @@ -20,6 +28,10 @@ $(CompileDependsOn); BuildPackageCache + + $(CompileDependsOn); + BuildFallbackArchive + @@ -88,6 +100,73 @@ + + + + + + + + + + + $(FallbackArchiveDir)obj/$(OutputPackageName) + $(RepositoryRoot)artifacts\$(OutputPackageName).lzma + $(FallbackArchiveDir)\obj\$(OutputPackageName).NuGet.config + + + + + + + + + + + + + + + + + + + + + + + + + $(COHERENCE_SIGNED_DROP_ROOT) + \\aspnetci\Drops\Coherence-Signed\dev + + $(TIMESTAMP_FREE_VERSION) + final + + $(VersionPrefix)-$(VersionSuffix)-$(NoTimestampSuffix) + $(VersionPrefix)-$(VersionSuffix)-$(BuildNumber) + + $(CoherenceSignedRoot)\$(BuildNumber)\Signed\Packages-NoTimeStamp + $(CoherenceSignedRoot)\$(BuildNumber)\Signed\Packages + + + + + + + + + + + $(PublishShare)\fallbackArchives + + + + + @@ -108,4 +187,4 @@ - \ No newline at end of file + diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj new file mode 100644 index 0000000000..5d1de6a2bb --- /dev/null +++ b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj @@ -0,0 +1,31 @@ + + + + netcoreapp2.0 + $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; + false + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 27d7905342..0fbcd07cd7 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -19,4 +19,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.DotNet.Archive/CompressionUtility.cs b/src/Microsoft.DotNet.Archive/CompressionUtility.cs new file mode 100644 index 0000000000..0b4e937dc6 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/CompressionUtility.cs @@ -0,0 +1,107 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using SevenZip; +using System; +using System.IO; + +namespace Microsoft.DotNet.Archive +{ + internal static class CompressionUtility + { + enum MeasureBy + { + Input, + Output + } + + private class LzmaProgress : ICodeProgress + { + private IProgress progress; + private long totalSize; + private string phase; + private MeasureBy measureBy; + + public LzmaProgress(IProgress progress, string phase, long totalSize, MeasureBy measureBy) + { + this.progress = progress; + this.totalSize = totalSize; + this.phase = phase; + this.measureBy = measureBy; + } + + public void SetProgress(long inSize, long outSize) + { + progress.Report(phase, measureBy == MeasureBy.Input ? inSize : outSize, totalSize); + } + } + + public static void Compress(Stream inStream, Stream outStream, IProgress progress) + { + SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder(); + + CoderPropID[] propIDs = + { + CoderPropID.DictionarySize, + CoderPropID.PosStateBits, + CoderPropID.LitContextBits, + CoderPropID.LitPosBits, + CoderPropID.Algorithm, + CoderPropID.NumFastBytes, + CoderPropID.MatchFinder, + CoderPropID.EndMarker + }; + object[] properties = + { + (Int32)(1 << 26), + (Int32)(1), + (Int32)(8), + (Int32)(0), + (Int32)(2), + (Int32)(96), + "bt4", + false + }; + + encoder.SetCoderProperties(propIDs, properties); + encoder.WriteCoderProperties(outStream); + + Int64 inSize = inStream.Length; + for (int i = 0; i < 8; i++) + { + outStream.WriteByte((Byte)(inSize >> (8 * i))); + } + + var lzmaProgress = new LzmaProgress(progress, "Compressing", inSize, MeasureBy.Input); + lzmaProgress.SetProgress(0, 0); + encoder.Code(inStream, outStream, -1, -1, lzmaProgress); + lzmaProgress.SetProgress(inSize, outStream.Length); + } + + public static void Decompress(Stream inStream, Stream outStream, IProgress progress) + { + byte[] properties = new byte[5]; + + if (inStream.Read(properties, 0, 5) != 5) + throw (new Exception("input .lzma is too short")); + + SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); + decoder.SetDecoderProperties(properties); + + long outSize = 0; + for (int i = 0; i < 8; i++) + { + int v = inStream.ReadByte(); + if (v < 0) + throw (new Exception("Can't Read 1")); + outSize |= ((long)(byte)v) << (8 * i); + } + + long compressedSize = inStream.Length - inStream.Position; + var lzmaProgress = new LzmaProgress(progress, "Decompressing", outSize, MeasureBy.Output); + lzmaProgress.SetProgress(0, 0); + decoder.Code(inStream, outStream, compressedSize, outSize, lzmaProgress); + lzmaProgress.SetProgress(inStream.Length, outSize); + } + } +} diff --git a/src/Microsoft.DotNet.Archive/ConsoleProgressReport.cs b/src/Microsoft.DotNet.Archive/ConsoleProgressReport.cs new file mode 100644 index 0000000000..e8f6cd0dff --- /dev/null +++ b/src/Microsoft.DotNet.Archive/ConsoleProgressReport.cs @@ -0,0 +1,59 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Diagnostics; + +namespace Microsoft.DotNet.Archive +{ + public class ConsoleProgressReport : IProgress + { + private string _currentPhase; + private int _lastLineLength = 0; + private double _lastProgress = -1; + private Stopwatch _stopwatch; + private object _stateLock = new object(); + + public void Report(ProgressReport value) + { + long progress = (long)(100 * ((double)value.Ticks / value.Total)); + + if (progress == _lastProgress && value.Phase == _currentPhase) + { + return; + } + _lastProgress = progress; + + lock (_stateLock) + { + string line = $"{value.Phase} {progress}%"; + if (value.Phase == _currentPhase) + { + if (Console.IsOutputRedirected) + { + Console.Write($"...{progress}%"); + } + else + { + Console.Write(new string('\b', _lastLineLength)); + Console.Write(line); + } + + _lastLineLength = line.Length; + + if (progress == 100) + { + Console.WriteLine($" {_stopwatch.ElapsedMilliseconds} ms"); + } + } + else + { + Console.Write(line); + _currentPhase = value.Phase; + _lastLineLength = line.Length; + _stopwatch = Stopwatch.StartNew(); + } + } + } + } +} diff --git a/src/Microsoft.DotNet.Archive/IndexedArchive.cs b/src/Microsoft.DotNet.Archive/IndexedArchive.cs new file mode 100644 index 0000000000..bb4c9bbd14 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/IndexedArchive.cs @@ -0,0 +1,538 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading; + +namespace Microsoft.DotNet.Archive +{ + public class IndexedArchive : IDisposable + { + private class DestinationFileInfo + { + public DestinationFileInfo(string destinationPath, string hash) + { + DestinationPath = destinationPath; + Hash = hash; + } + + public string DestinationPath { get; } + public string Hash { get; } + } + + private class ArchiveSource + { + public ArchiveSource(string sourceArchive, string sourceFile, string archivePath, string hash, long size) + { + SourceArchive = sourceArchive; + SourceFile = sourceFile; + ArchivePath = archivePath; + Hash = hash; + Size = size; + } + + public string SourceArchive { get; set; } + public string SourceFile { get; set; } + public string ArchivePath { get; } + public string Hash { get; } + public string FileName { get { return Path.GetFileNameWithoutExtension(ArchivePath); } } + public string Extension { get { return Path.GetExtension(ArchivePath); } } + public long Size { get; } + + public void CopyTo(Stream destination) + { + if (!String.IsNullOrEmpty(SourceArchive)) + { + using (var zip = new ZipArchive(File.OpenRead(SourceArchive), ZipArchiveMode.Read)) + using (var sourceStream = zip.GetEntry(SourceFile)?.Open()) + { + if (sourceStream == null) + { + throw new Exception($"Couldn't find entry {SourceFile} in archive {SourceArchive}"); + } + + sourceStream.CopyTo(destination); + } + } + else + { + using (var sourceStream = File.OpenRead(SourceFile)) + { + sourceStream.CopyTo(destination); + } + } + } + } + + static string[] ZipExtensions = new[] { ".zip", ".nupkg" }; + static string IndexFileName = "index.txt"; + + // maps file hash to archve path + // $ prefix indicates that the file is not in the archive and path is a hash + private Dictionary _archiveFiles = new Dictionary(); + // maps file hash to external path + private Dictionary _externalFiles = new Dictionary(); + // lists all extracted files & hashes + private List _destFiles = new List(); + private bool _disposed = false; + private ThreadLocal _sha = new ThreadLocal(() => SHA256.Create()); + + public IndexedArchive() + { } + + private static Stream CreateTemporaryStream() + { + string temp = Path.GetTempPath(); + string tempFile = Path.Combine(temp, Guid.NewGuid().ToString()); + return File.Create(tempFile, 4096, FileOptions.DeleteOnClose); + } + + private static FileStream CreateTemporaryFileStream() + { + string temp = Path.GetTempPath(); + string tempFile = Path.Combine(temp, Guid.NewGuid().ToString()); + return new FileStream(tempFile, FileMode.Create, FileAccess.ReadWrite, FileShare.Read | FileShare.Delete, 4096, FileOptions.DeleteOnClose); + } + + public void Save(string archivePath, IProgress progress) + { + CheckDisposed(); + + using (var archiveStream = CreateTemporaryStream()) + { + using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create, true)) + { + BuildArchive(archive, progress); + } // close archive + + archiveStream.Seek(0, SeekOrigin.Begin); + + using (var lzmaStream = File.Create(archivePath)) + { + CompressionUtility.Compress(archiveStream, lzmaStream, progress); + } + } // close archiveStream + } + + private void BuildArchive(ZipArchive archive, IProgress progress) + { + // write the file index + var indexEntry = archive.CreateEntry(IndexFileName, CompressionLevel.NoCompression); + + using (var stream = indexEntry.Open()) + using (var textWriter = new StreamWriter(stream)) + { + foreach (var entry in _destFiles) + { + var archiveFile = _archiveFiles[entry.Hash]; + string archivePath = _archiveFiles[entry.Hash].ArchivePath; + if (archiveFile.SourceFile == null) + { + archivePath = "$" + archivePath; + } + + textWriter.WriteLine($"{entry.DestinationPath}|{archivePath}"); + } + } + + // sort the files so that similar files are close together + var filesToArchive = _archiveFiles.Values.ToList(); + filesToArchive.Sort((f1, f2) => + { + // first sort by extension + var comp = String.Compare(f1.Extension, f2.Extension, StringComparison.OrdinalIgnoreCase); + + if (comp == 0) + { + // then sort by filename + comp = String.Compare(f1.FileName, f2.FileName, StringComparison.OrdinalIgnoreCase); + } + + if (comp == 0) + { + // sort by file size (helps differentiate ref/lib/facade) + comp = f1.Size.CompareTo(f2.Size); + } + + if (comp == 0) + { + // finally sort by full archive path so we have stable output + comp = String.Compare(f1.ArchivePath, f2.ArchivePath, StringComparison.OrdinalIgnoreCase); + } + + return comp; + }); + + int filesAdded = 0; + // add all the files + foreach (var fileToArchive in filesToArchive) + { + var entry = archive.CreateEntry(fileToArchive.ArchivePath, CompressionLevel.NoCompression); + using (var entryStream = entry.Open()) + { + fileToArchive.CopyTo(entryStream); + } + + progress.Report("Archiving files", ++filesAdded, filesToArchive.Count); + } + } + + private abstract class ExtractOperation + { + public ExtractOperation(string destinationPath) + { + DestinationPath = destinationPath; + } + + public string DestinationPath { get; } + public virtual void DoOperation() + { + string directory = Path.GetDirectoryName(DestinationPath); + + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + + Execute(); + } + protected abstract void Execute(); + } + + private class CopyOperation : ExtractOperation + { + public CopyOperation(ExtractSource source, string destinationPath) : base(destinationPath) + { + Source = source; + } + public ExtractSource Source { get; } + protected override void Execute() + { + if (Source.LocalPath != null) + { + File.Copy(Source.LocalPath, DestinationPath, true); + } + else + { + using (var destinationStream = File.Create(DestinationPath)) + { + Source.CopyToStream(destinationStream); + } + } + } + } + + private class ZipOperation : ExtractOperation + { + public ZipOperation(string destinationPath) : base(destinationPath) + { + } + + private List> entries = new List>(); + + public void AddEntry(string entryName, ExtractSource source) + { + entries.Add(Tuple.Create(entryName, source)); + } + + protected override void Execute() + { + using (var archiveStream = File.Create(DestinationPath)) + using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create)) + { + foreach(var zipSource in entries) + { + var entry = archive.CreateEntry(zipSource.Item1, CompressionLevel.Optimal); + using (var entryStream = entry.Open()) + { + zipSource.Item2.CopyToStream(entryStream); + } + } + } + } + } + + private class ExtractSource + { + private string _entryName; + private readonly string _localPath; + private ThreadLocalZipArchive _archive; + + public ExtractSource(string sourceString, Dictionary externalFiles, ThreadLocalZipArchive archive) + { + if (sourceString[0] == '$') + { + var externalHash = sourceString.Substring(1); + if (!externalFiles.TryGetValue(externalHash, out _localPath)) + { + throw new Exception("Could not find external file with hash {externalHash}."); + } + } + else + { + _entryName = sourceString; + _archive = archive; + } + } + + public string LocalPath { get { return _localPath; } } + + public void CopyToStream(Stream destinationStream) + { + if (_localPath != null) + { + using (var sourceStream = File.OpenRead(_localPath)) + { + sourceStream.CopyTo(destinationStream); + } + } + else + { + using (var sourceStream = _archive.Archive.GetEntry(_entryName).Open()) + { + sourceStream.CopyTo(destinationStream); + } + } + + } + } + + private static char[] pipeSeperator = new[] { '|' }; + public void Extract(string compressedArchivePath, string outputDirectory, IProgress progress) + { + using (var archiveStream = CreateTemporaryFileStream()) + { + // decompress the LZMA stream + using (var lzmaStream = File.OpenRead(compressedArchivePath)) + { + CompressionUtility.Decompress(lzmaStream, archiveStream, progress); + } + + var archivePath = ((FileStream)archiveStream).Name; + + // reset the uncompressed stream + archiveStream.Seek(0, SeekOrigin.Begin); + + // read as a zip archive + using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Read)) + using (var tlArchive = new ThreadLocalZipArchive(archivePath, archive)) + { + List extractOperations = new List(); + Dictionary sourceCache = new Dictionary(); + + // process the index to determine all extraction operations + var indexEntry = archive.GetEntry(IndexFileName); + using (var indexReader = new StreamReader(indexEntry.Open())) + { + Dictionary zipOperations = new Dictionary(StringComparer.OrdinalIgnoreCase); + for (var line = indexReader.ReadLine(); line != null; line = indexReader.ReadLine()) + { + var lineParts = line.Split(pipeSeperator); + if (lineParts.Length != 2) + { + throw new Exception("Unexpected index line format, too many '|'s."); + } + + string target = lineParts[0]; + string source = lineParts[1]; + + ExtractSource extractSource; + if (!sourceCache.TryGetValue(source, out extractSource)) + { + sourceCache[source] = extractSource = new ExtractSource(source, _externalFiles, tlArchive); + } + + var zipSeperatorIndex = target.IndexOf("::", StringComparison.OrdinalIgnoreCase); + + if (zipSeperatorIndex != -1) + { + string zipRelativePath = target.Substring(0, zipSeperatorIndex); + string zipEntryName = target.Substring(zipSeperatorIndex + 2); + string destinationPath = Path.Combine(outputDirectory, zipRelativePath); + + // operations on a zip file will be sequential + ZipOperation currentZipOperation; + + if (!zipOperations.TryGetValue(destinationPath, out currentZipOperation)) + { + extractOperations.Add(currentZipOperation = new ZipOperation(destinationPath)); + zipOperations.Add(destinationPath, currentZipOperation); + } + currentZipOperation.AddEntry(zipEntryName, extractSource); + } + else + { + string destinationPath = Path.Combine(outputDirectory, target); + extractOperations.Add(new CopyOperation(extractSource, destinationPath)); + } + } + } + + int opsExecuted = 0; + // execute all operations + //foreach(var extractOperation in extractOperations) + extractOperations.AsParallel().ForAll(extractOperation => + { + extractOperation.DoOperation(); + progress.Report("Expanding", Interlocked.Increment(ref opsExecuted), extractOperations.Count); + }); + } + } + } + + public void AddExternalDirectory(string externalDirectory) + { + CheckDisposed(); + foreach (var externalFile in Directory.EnumerateFiles(externalDirectory, "*", SearchOption.AllDirectories)) + { + AddExternalFile(externalFile); + } + } + + public void AddExternalFile(string externalFile) + { + CheckDisposed(); + using (var fs = File.OpenRead(externalFile)) + { + string hash = GetHash(fs); + // $ prefix indicates that the file is not in the archive and path is relative to an external directory + _archiveFiles[hash] = new ArchiveSource(null, null, "$" + hash , hash, fs.Length); + _externalFiles[hash] = externalFile; + } + } + public void AddDirectory(string sourceDirectory, IProgress progress, string destinationDirectory = null) + { + var sourceFiles = Directory.EnumerateFiles(sourceDirectory, "*", SearchOption.AllDirectories).ToArray(); + int filesAdded = 0; + sourceFiles.AsParallel().ForAll(sourceFile => + { + // path relative to the destination/extracted directory to write the file + string destinationRelativePath = sourceFile.Substring(sourceDirectory.Length + 1); + + if (destinationDirectory != null) + { + destinationRelativePath = Path.Combine(destinationDirectory, destinationRelativePath); + } + + string extension = Path.GetExtension(sourceFile); + + if (ZipExtensions.Any(ze => ze.Equals(extension, StringComparison.OrdinalIgnoreCase))) + { + AddZip(sourceFile, destinationRelativePath); + } + else + { + AddFile(sourceFile, destinationRelativePath); + } + + progress.Report($"Adding {sourceDirectory}", Interlocked.Increment(ref filesAdded), sourceFiles.Length); + }); + } + + public void AddZip(string sourceZipFile, string destinationZipFile) + { + CheckDisposed(); + + using (var sourceArchive = new ZipArchive(File.OpenRead(sourceZipFile), ZipArchiveMode.Read)) + { + foreach(var entry in sourceArchive.Entries) + { + string hash = null; + long size = entry.Length; + string destinationPath = $"{destinationZipFile}::{entry.FullName}"; + using (var stream = entry.Open()) + { + hash = GetHash(stream); + } + + AddArchiveSource(sourceZipFile, entry.FullName, destinationPath, hash, size); + } + } + } + + public void AddFile(string sourceFilePath, string destinationPath) + { + CheckDisposed(); + + string hash; + long size; + // lifetime of this stream is managed by AddStream + using (var stream = File.Open(sourceFilePath, FileMode.Open)) + { + hash = GetHash(stream); + size = stream.Length; + } + + AddArchiveSource(null, sourceFilePath, destinationPath, hash, size); + } + + private void AddArchiveSource(string sourceArchive, string sourceFile, string destinationPath, string hash, long size) + { + lock (_archiveFiles) + { + _destFiles.Add(new DestinationFileInfo(destinationPath, hash)); + + // see if we already have this file in the archive/external + ArchiveSource existing = null; + if (_archiveFiles.TryGetValue(hash, out existing)) + { + // if we have raw source file, prefer that over a zipped source file + if (sourceArchive == null && existing.SourceArchive != null) + { + existing.SourceArchive = null; + existing.SourceFile = sourceFile; + } + } + else + { + var archivePath = Path.Combine(hash, Path.GetFileName(destinationPath)); + + _archiveFiles.Add(hash, new ArchiveSource(sourceArchive, sourceFile, archivePath, hash, size)); + } + } + } + + public string GetHash(Stream stream) + { + var hashBytes = _sha.Value.ComputeHash(stream); + + return GetHashString(hashBytes); + } + + private static string GetHashString(byte[] hashBytes) + { + StringBuilder builder = new StringBuilder(hashBytes.Length * 2); + foreach (var b in hashBytes) + { + builder.AppendFormat("{0:x2}", b); + } + return builder.ToString(); + } + + public void Dispose() + { + if (!_disposed) + { + if (_sha != null) + { + _sha.Dispose(); + _sha = null; + } + } + } + + private void CheckDisposed() + { + if (_disposed) + { + throw new ObjectDisposedException(nameof(IndexedArchive)); + } + } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Common/CRC.cs b/src/Microsoft.DotNet.Archive/LZMA/Common/CRC.cs new file mode 100644 index 0000000000..5d38bf911b --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Common/CRC.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// Common/CRC.cs + +namespace SevenZip +{ + class CRC + { + public static readonly uint[] Table; + + static CRC() + { + Table = new uint[256]; + const uint kPoly = 0xEDB88320; + for (uint i = 0; i < 256; i++) + { + uint r = i; + for (int j = 0; j < 8; j++) + if ((r & 1) != 0) + r = (r >> 1) ^ kPoly; + else + r >>= 1; + Table[i] = r; + } + } + + uint _value = 0xFFFFFFFF; + + public void Init() { _value = 0xFFFFFFFF; } + + public void UpdateByte(byte b) + { + _value = Table[(((byte)(_value)) ^ b)] ^ (_value >> 8); + } + + public void Update(byte[] data, uint offset, uint size) + { + for (uint i = 0; i < size; i++) + _value = Table[(((byte)(_value)) ^ data[offset + i])] ^ (_value >> 8); + } + + public uint GetDigest() { return _value ^ 0xFFFFFFFF; } + + static uint CalculateDigest(byte[] data, uint offset, uint size) + { + CRC crc = new CRC(); + // crc.Init(); + crc.Update(data, offset, size); + return crc.GetDigest(); + } + + static bool VerifyDigest(uint digest, byte[] data, uint offset, uint size) + { + return (CalculateDigest(data, offset, size) == digest); + } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Common/InBuffer.cs b/src/Microsoft.DotNet.Archive/LZMA/Common/InBuffer.cs new file mode 100644 index 0000000000..a26bf4a29b --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Common/InBuffer.cs @@ -0,0 +1,75 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// InBuffer.cs + +namespace SevenZip.Buffer +{ + public class InBuffer + { + byte[] m_Buffer; + uint m_Pos; + uint m_Limit; + uint m_BufferSize; + System.IO.Stream m_Stream; + bool m_StreamWasExhausted; + ulong m_ProcessedSize; + + public InBuffer(uint bufferSize) + { + m_Buffer = new byte[bufferSize]; + m_BufferSize = bufferSize; + } + + public void Init(System.IO.Stream stream) + { + m_Stream = stream; + m_ProcessedSize = 0; + m_Limit = 0; + m_Pos = 0; + m_StreamWasExhausted = false; + } + + public bool ReadBlock() + { + if (m_StreamWasExhausted) + return false; + m_ProcessedSize += m_Pos; + int aNumProcessedBytes = m_Stream.Read(m_Buffer, 0, (int)m_BufferSize); + m_Pos = 0; + m_Limit = (uint)aNumProcessedBytes; + m_StreamWasExhausted = (aNumProcessedBytes == 0); + return (!m_StreamWasExhausted); + } + + + public void ReleaseStream() + { + // m_Stream.Close(); + m_Stream = null; + } + + public bool ReadByte(byte b) // check it + { + if (m_Pos >= m_Limit) + if (!ReadBlock()) + return false; + b = m_Buffer[m_Pos++]; + return true; + } + + public byte ReadByte() + { + // return (byte)m_Stream.ReadByte(); + if (m_Pos >= m_Limit) + if (!ReadBlock()) + return 0xFF; + return m_Buffer[m_Pos++]; + } + + public ulong GetProcessedSize() + { + return m_ProcessedSize + m_Pos; + } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Common/OutBuffer.cs b/src/Microsoft.DotNet.Archive/LZMA/Common/OutBuffer.cs new file mode 100644 index 0000000000..429bccfc91 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Common/OutBuffer.cs @@ -0,0 +1,50 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// OutBuffer.cs + +namespace SevenZip.Buffer +{ + public class OutBuffer + { + byte[] m_Buffer; + uint m_Pos; + uint m_BufferSize; + System.IO.Stream m_Stream; + ulong m_ProcessedSize; + + public OutBuffer(uint bufferSize) + { + m_Buffer = new byte[bufferSize]; + m_BufferSize = bufferSize; + } + + public void SetStream(System.IO.Stream stream) { m_Stream = stream; } + public void FlushStream() { m_Stream.Flush(); } + public void CloseStream() { m_Stream.Dispose(); } + public void ReleaseStream() { m_Stream = null; } + + public void Init() + { + m_ProcessedSize = 0; + m_Pos = 0; + } + + public void WriteByte(byte b) + { + m_Buffer[m_Pos++] = b; + if (m_Pos >= m_BufferSize) + FlushData(); + } + + public void FlushData() + { + if (m_Pos == 0) + return; + m_Stream.Write(m_Buffer, 0, (int)m_Pos); + m_Pos = 0; + } + + public ulong GetProcessedSize() { return m_ProcessedSize + m_Pos; } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/IMatchFinder.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/IMatchFinder.cs new file mode 100644 index 0000000000..2916aedb0f --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/IMatchFinder.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// IMatchFinder.cs + +using System; + +namespace SevenZip.Compression.LZ +{ + interface IInWindowStream + { + void SetStream(System.IO.Stream inStream); + void Init(); + void ReleaseStream(); + Byte GetIndexByte(Int32 index); + UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit); + UInt32 GetNumAvailableBytes(); + } + + interface IMatchFinder : IInWindowStream + { + void Create(UInt32 historySize, UInt32 keepAddBufferBefore, + UInt32 matchMaxLen, UInt32 keepAddBufferAfter); + UInt32 GetMatches(UInt32[] distances); + void Skip(UInt32 num); + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzBinTree.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzBinTree.cs new file mode 100644 index 0000000000..017cf8ea2f --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzBinTree.cs @@ -0,0 +1,370 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// LzBinTree.cs + +using System; + +namespace SevenZip.Compression.LZ +{ + public class BinTree : InWindow, IMatchFinder + { + UInt32 _cyclicBufferPos; + UInt32 _cyclicBufferSize = 0; + UInt32 _matchMaxLen; + + UInt32[] _son; + UInt32[] _hash; + + UInt32 _cutValue = 0xFF; + UInt32 _hashMask; + UInt32 _hashSizeSum = 0; + + bool HASH_ARRAY = true; + + const UInt32 kHash2Size = 1 << 10; + const UInt32 kHash3Size = 1 << 16; + const UInt32 kBT2HashSize = 1 << 16; + const UInt32 kStartMaxLen = 1; + const UInt32 kHash3Offset = kHash2Size; + const UInt32 kEmptyHashValue = 0; + const UInt32 kMaxValForNormalize = ((UInt32)1 << 31) - 1; + + UInt32 kNumHashDirectBytes = 0; + UInt32 kMinMatchCheck = 4; + UInt32 kFixHashSize = kHash2Size + kHash3Size; + + public void SetType(int numHashBytes) + { + HASH_ARRAY = (numHashBytes > 2); + if (HASH_ARRAY) + { + kNumHashDirectBytes = 0; + kMinMatchCheck = 4; + kFixHashSize = kHash2Size + kHash3Size; + } + else + { + kNumHashDirectBytes = 2; + kMinMatchCheck = 2 + 1; + kFixHashSize = 0; + } + } + + public new void SetStream(System.IO.Stream stream) { base.SetStream(stream); } + public new void ReleaseStream() { base.ReleaseStream(); } + + public new void Init() + { + base.Init(); + for (UInt32 i = 0; i < _hashSizeSum; i++) + _hash[i] = kEmptyHashValue; + _cyclicBufferPos = 0; + ReduceOffsets(-1); + } + + public new void MovePos() + { + if (++_cyclicBufferPos >= _cyclicBufferSize) + _cyclicBufferPos = 0; + base.MovePos(); + if (_pos == kMaxValForNormalize) + Normalize(); + } + + public new Byte GetIndexByte(Int32 index) { return base.GetIndexByte(index); } + + public new UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) + { return base.GetMatchLen(index, distance, limit); } + + public new UInt32 GetNumAvailableBytes() { return base.GetNumAvailableBytes(); } + + public void Create(UInt32 historySize, UInt32 keepAddBufferBefore, + UInt32 matchMaxLen, UInt32 keepAddBufferAfter) + { + if (historySize > kMaxValForNormalize - 256) + throw new Exception(); + _cutValue = 16 + (matchMaxLen >> 1); + + UInt32 windowReservSize = (historySize + keepAddBufferBefore + + matchMaxLen + keepAddBufferAfter) / 2 + 256; + + base.Create(historySize + keepAddBufferBefore, matchMaxLen + keepAddBufferAfter, windowReservSize); + + _matchMaxLen = matchMaxLen; + + UInt32 cyclicBufferSize = historySize + 1; + if (_cyclicBufferSize != cyclicBufferSize) + _son = new UInt32[(_cyclicBufferSize = cyclicBufferSize) * 2]; + + UInt32 hs = kBT2HashSize; + + if (HASH_ARRAY) + { + hs = historySize - 1; + hs |= (hs >> 1); + hs |= (hs >> 2); + hs |= (hs >> 4); + hs |= (hs >> 8); + hs >>= 1; + hs |= 0xFFFF; + if (hs > (1 << 24)) + hs >>= 1; + _hashMask = hs; + hs++; + hs += kFixHashSize; + } + if (hs != _hashSizeSum) + _hash = new UInt32[_hashSizeSum = hs]; + } + + public UInt32 GetMatches(UInt32[] distances) + { + UInt32 lenLimit; + if (_pos + _matchMaxLen <= _streamPos) + lenLimit = _matchMaxLen; + else + { + lenLimit = _streamPos - _pos; + if (lenLimit < kMinMatchCheck) + { + MovePos(); + return 0; + } + } + + UInt32 offset = 0; + UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0; + UInt32 cur = _bufferOffset + _pos; + UInt32 maxLen = kStartMaxLen; // to avoid items for len < hashSize; + UInt32 hashValue, hash2Value = 0, hash3Value = 0; + + if (HASH_ARRAY) + { + UInt32 temp = CRC.Table[_bufferBase[cur]] ^ _bufferBase[cur + 1]; + hash2Value = temp & (kHash2Size - 1); + temp ^= ((UInt32)(_bufferBase[cur + 2]) << 8); + hash3Value = temp & (kHash3Size - 1); + hashValue = (temp ^ (CRC.Table[_bufferBase[cur + 3]] << 5)) & _hashMask; + } + else + hashValue = _bufferBase[cur] ^ ((UInt32)(_bufferBase[cur + 1]) << 8); + + UInt32 curMatch = _hash[kFixHashSize + hashValue]; + if (HASH_ARRAY) + { + UInt32 curMatch2 = _hash[hash2Value]; + UInt32 curMatch3 = _hash[kHash3Offset + hash3Value]; + _hash[hash2Value] = _pos; + _hash[kHash3Offset + hash3Value] = _pos; + if (curMatch2 > matchMinPos) + if (_bufferBase[_bufferOffset + curMatch2] == _bufferBase[cur]) + { + distances[offset++] = maxLen = 2; + distances[offset++] = _pos - curMatch2 - 1; + } + if (curMatch3 > matchMinPos) + if (_bufferBase[_bufferOffset + curMatch3] == _bufferBase[cur]) + { + if (curMatch3 == curMatch2) + offset -= 2; + distances[offset++] = maxLen = 3; + distances[offset++] = _pos - curMatch3 - 1; + curMatch2 = curMatch3; + } + if (offset != 0 && curMatch2 == curMatch) + { + offset -= 2; + maxLen = kStartMaxLen; + } + } + + _hash[kFixHashSize + hashValue] = _pos; + + UInt32 ptr0 = (_cyclicBufferPos << 1) + 1; + UInt32 ptr1 = (_cyclicBufferPos << 1); + + UInt32 len0, len1; + len0 = len1 = kNumHashDirectBytes; + + if (kNumHashDirectBytes != 0) + { + if (curMatch > matchMinPos) + { + if (_bufferBase[_bufferOffset + curMatch + kNumHashDirectBytes] != + _bufferBase[cur + kNumHashDirectBytes]) + { + distances[offset++] = maxLen = kNumHashDirectBytes; + distances[offset++] = _pos - curMatch - 1; + } + } + } + + UInt32 count = _cutValue; + + while(true) + { + if(curMatch <= matchMinPos || count-- == 0) + { + _son[ptr0] = _son[ptr1] = kEmptyHashValue; + break; + } + UInt32 delta = _pos - curMatch; + UInt32 cyclicPos = ((delta <= _cyclicBufferPos) ? + (_cyclicBufferPos - delta) : + (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; + + UInt32 pby1 = _bufferOffset + curMatch; + UInt32 len = Math.Min(len0, len1); + if (_bufferBase[pby1 + len] == _bufferBase[cur + len]) + { + while(++len != lenLimit) + if (_bufferBase[pby1 + len] != _bufferBase[cur + len]) + break; + if (maxLen < len) + { + distances[offset++] = maxLen = len; + distances[offset++] = delta - 1; + if (len == lenLimit) + { + _son[ptr1] = _son[cyclicPos]; + _son[ptr0] = _son[cyclicPos + 1]; + break; + } + } + } + if (_bufferBase[pby1 + len] < _bufferBase[cur + len]) + { + _son[ptr1] = curMatch; + ptr1 = cyclicPos + 1; + curMatch = _son[ptr1]; + len1 = len; + } + else + { + _son[ptr0] = curMatch; + ptr0 = cyclicPos; + curMatch = _son[ptr0]; + len0 = len; + } + } + MovePos(); + return offset; + } + + public void Skip(UInt32 num) + { + do + { + UInt32 lenLimit; + if (_pos + _matchMaxLen <= _streamPos) + lenLimit = _matchMaxLen; + else + { + lenLimit = _streamPos - _pos; + if (lenLimit < kMinMatchCheck) + { + MovePos(); + continue; + } + } + + UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0; + UInt32 cur = _bufferOffset + _pos; + + UInt32 hashValue; + + if (HASH_ARRAY) + { + UInt32 temp = CRC.Table[_bufferBase[cur]] ^ _bufferBase[cur + 1]; + UInt32 hash2Value = temp & (kHash2Size - 1); + _hash[hash2Value] = _pos; + temp ^= ((UInt32)(_bufferBase[cur + 2]) << 8); + UInt32 hash3Value = temp & (kHash3Size - 1); + _hash[kHash3Offset + hash3Value] = _pos; + hashValue = (temp ^ (CRC.Table[_bufferBase[cur + 3]] << 5)) & _hashMask; + } + else + hashValue = _bufferBase[cur] ^ ((UInt32)(_bufferBase[cur + 1]) << 8); + + UInt32 curMatch = _hash[kFixHashSize + hashValue]; + _hash[kFixHashSize + hashValue] = _pos; + + UInt32 ptr0 = (_cyclicBufferPos << 1) + 1; + UInt32 ptr1 = (_cyclicBufferPos << 1); + + UInt32 len0, len1; + len0 = len1 = kNumHashDirectBytes; + + UInt32 count = _cutValue; + while (true) + { + if (curMatch <= matchMinPos || count-- == 0) + { + _son[ptr0] = _son[ptr1] = kEmptyHashValue; + break; + } + + UInt32 delta = _pos - curMatch; + UInt32 cyclicPos = ((delta <= _cyclicBufferPos) ? + (_cyclicBufferPos - delta) : + (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; + + UInt32 pby1 = _bufferOffset + curMatch; + UInt32 len = Math.Min(len0, len1); + if (_bufferBase[pby1 + len] == _bufferBase[cur + len]) + { + while (++len != lenLimit) + if (_bufferBase[pby1 + len] != _bufferBase[cur + len]) + break; + if (len == lenLimit) + { + _son[ptr1] = _son[cyclicPos]; + _son[ptr0] = _son[cyclicPos + 1]; + break; + } + } + if (_bufferBase[pby1 + len] < _bufferBase[cur + len]) + { + _son[ptr1] = curMatch; + ptr1 = cyclicPos + 1; + curMatch = _son[ptr1]; + len1 = len; + } + else + { + _son[ptr0] = curMatch; + ptr0 = cyclicPos; + curMatch = _son[ptr0]; + len0 = len; + } + } + MovePos(); + } + while (--num != 0); + } + + void NormalizeLinks(UInt32[] items, UInt32 numItems, UInt32 subValue) + { + for (UInt32 i = 0; i < numItems; i++) + { + UInt32 value = items[i]; + if (value <= subValue) + value = kEmptyHashValue; + else + value -= subValue; + items[i] = value; + } + } + + void Normalize() + { + UInt32 subValue = _pos - _cyclicBufferSize; + NormalizeLinks(_son, _cyclicBufferSize * 2, subValue); + NormalizeLinks(_hash, _hashSizeSum, subValue); + ReduceOffsets((Int32)subValue); + } + + public void SetCutValue(UInt32 cutValue) { _cutValue = cutValue; } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzInWindow.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzInWindow.cs new file mode 100644 index 0000000000..1ee8282f11 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzInWindow.cs @@ -0,0 +1,135 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// LzInWindow.cs + +using System; + +namespace SevenZip.Compression.LZ +{ + public class InWindow + { + public Byte[] _bufferBase = null; // pointer to buffer with data + System.IO.Stream _stream; + UInt32 _posLimit; // offset (from _buffer) of first byte when new block reading must be done + bool _streamEndWasReached; // if (true) then _streamPos shows real end of stream + + UInt32 _pointerToLastSafePosition; + + public UInt32 _bufferOffset; + + public UInt32 _blockSize; // Size of Allocated memory block + public UInt32 _pos; // offset (from _buffer) of curent byte + UInt32 _keepSizeBefore; // how many BYTEs must be kept in buffer before _pos + UInt32 _keepSizeAfter; // how many BYTEs must be kept buffer after _pos + public UInt32 _streamPos; // offset (from _buffer) of first not read byte from Stream + + public void MoveBlock() + { + UInt32 offset = (UInt32)(_bufferOffset) + _pos - _keepSizeBefore; + // we need one additional byte, since MovePos moves on 1 byte. + if (offset > 0) + offset--; + + UInt32 numBytes = (UInt32)(_bufferOffset) + _streamPos - offset; + + // check negative offset ???? + for (UInt32 i = 0; i < numBytes; i++) + _bufferBase[i] = _bufferBase[offset + i]; + _bufferOffset -= offset; + } + + public virtual void ReadBlock() + { + if (_streamEndWasReached) + return; + while (true) + { + int size = (int)((0 - _bufferOffset) + _blockSize - _streamPos); + if (size == 0) + return; + int numReadBytes = _stream.Read(_bufferBase, (int)(_bufferOffset + _streamPos), size); + if (numReadBytes == 0) + { + _posLimit = _streamPos; + UInt32 pointerToPostion = _bufferOffset + _posLimit; + if (pointerToPostion > _pointerToLastSafePosition) + _posLimit = (UInt32)(_pointerToLastSafePosition - _bufferOffset); + + _streamEndWasReached = true; + return; + } + _streamPos += (UInt32)numReadBytes; + if (_streamPos >= _pos + _keepSizeAfter) + _posLimit = _streamPos - _keepSizeAfter; + } + } + + void Free() { _bufferBase = null; } + + public void Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv) + { + _keepSizeBefore = keepSizeBefore; + _keepSizeAfter = keepSizeAfter; + UInt32 blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv; + if (_bufferBase == null || _blockSize != blockSize) + { + Free(); + _blockSize = blockSize; + _bufferBase = new Byte[_blockSize]; + } + _pointerToLastSafePosition = _blockSize - keepSizeAfter; + } + + public void SetStream(System.IO.Stream stream) { _stream = stream; } + public void ReleaseStream() { _stream = null; } + + public void Init() + { + _bufferOffset = 0; + _pos = 0; + _streamPos = 0; + _streamEndWasReached = false; + ReadBlock(); + } + + public void MovePos() + { + _pos++; + if (_pos > _posLimit) + { + UInt32 pointerToPostion = _bufferOffset + _pos; + if (pointerToPostion > _pointerToLastSafePosition) + MoveBlock(); + ReadBlock(); + } + } + + public Byte GetIndexByte(Int32 index) { return _bufferBase[_bufferOffset + _pos + index]; } + + // index + limit have not to exceed _keepSizeAfter; + public UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) + { + if (_streamEndWasReached) + if ((_pos + index) + limit > _streamPos) + limit = _streamPos - (UInt32)(_pos + index); + distance++; + // Byte *pby = _buffer + (size_t)_pos + index; + UInt32 pby = _bufferOffset + _pos + (UInt32)index; + + UInt32 i; + for (i = 0; i < limit && _bufferBase[pby + i] == _bufferBase[pby + i - distance]; i++); + return i; + } + + public UInt32 GetNumAvailableBytes() { return _streamPos - _pos; } + + public void ReduceOffsets(Int32 subValue) + { + _bufferOffset += (UInt32)subValue; + _posLimit -= (UInt32)subValue; + _pos -= (UInt32)subValue; + _streamPos -= (UInt32)subValue; + } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzOutWindow.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzOutWindow.cs new file mode 100644 index 0000000000..479ae4f130 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzOutWindow.cs @@ -0,0 +1,113 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// LzOutWindow.cs + +namespace SevenZip.Compression.LZ +{ + public class OutWindow + { + byte[] _buffer = null; + uint _pos; + uint _windowSize = 0; + uint _streamPos; + System.IO.Stream _stream; + + public uint TrainSize = 0; + + public void Create(uint windowSize) + { + if (_windowSize != windowSize) + { + // System.GC.Collect(); + _buffer = new byte[windowSize]; + } + _windowSize = windowSize; + _pos = 0; + _streamPos = 0; + } + + public void Init(System.IO.Stream stream, bool solid) + { + ReleaseStream(); + _stream = stream; + if (!solid) + { + _streamPos = 0; + _pos = 0; + TrainSize = 0; + } + } + + public bool Train(System.IO.Stream stream) + { + long len = stream.Length; + uint size = (len < _windowSize) ? (uint)len : _windowSize; + TrainSize = size; + stream.Position = len - size; + _streamPos = _pos = 0; + while (size > 0) + { + uint curSize = _windowSize - _pos; + if (size < curSize) + curSize = size; + int numReadBytes = stream.Read(_buffer, (int)_pos, (int)curSize); + if (numReadBytes == 0) + return false; + size -= (uint)numReadBytes; + _pos += (uint)numReadBytes; + _streamPos += (uint)numReadBytes; + if (_pos == _windowSize) + _streamPos = _pos = 0; + } + return true; + } + + public void ReleaseStream() + { + Flush(); + _stream = null; + } + + public void Flush() + { + uint size = _pos - _streamPos; + if (size == 0) + return; + _stream.Write(_buffer, (int)_streamPos, (int)size); + if (_pos >= _windowSize) + _pos = 0; + _streamPos = _pos; + } + + public void CopyBlock(uint distance, uint len) + { + uint pos = _pos - distance - 1; + if (pos >= _windowSize) + pos += _windowSize; + for (; len > 0; len--) + { + if (pos >= _windowSize) + pos = 0; + _buffer[_pos++] = _buffer[pos++]; + if (_pos >= _windowSize) + Flush(); + } + } + + public void PutByte(byte b) + { + _buffer[_pos++] = b; + if (_pos >= _windowSize) + Flush(); + } + + public byte GetByte(uint distance) + { + uint pos = _pos - distance - 1; + if (pos >= _windowSize) + pos += _windowSize; + return _buffer[pos]; + } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaBase.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaBase.cs new file mode 100644 index 0000000000..f4a8f823f0 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaBase.cs @@ -0,0 +1,79 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// LzmaBase.cs + +namespace SevenZip.Compression.LZMA +{ + internal abstract class Base + { + public const uint kNumRepDistances = 4; + public const uint kNumStates = 12; + + // static byte []kLiteralNextStates = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; + // static byte []kMatchNextStates = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; + // static byte []kRepNextStates = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; + // static byte []kShortRepNextStates = {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; + + public struct State + { + public uint Index; + public void Init() { Index = 0; } + public void UpdateChar() + { + if (Index < 4) Index = 0; + else if (Index < 10) Index -= 3; + else Index -= 6; + } + public void UpdateMatch() { Index = (uint)(Index < 7 ? 7 : 10); } + public void UpdateRep() { Index = (uint)(Index < 7 ? 8 : 11); } + public void UpdateShortRep() { Index = (uint)(Index < 7 ? 9 : 11); } + public bool IsCharState() { return Index < 7; } + } + + public const int kNumPosSlotBits = 6; + public const int kDicLogSizeMin = 0; + // public const int kDicLogSizeMax = 30; + // public const uint kDistTableSizeMax = kDicLogSizeMax * 2; + + public const int kNumLenToPosStatesBits = 2; // it's for speed optimization + public const uint kNumLenToPosStates = 1 << kNumLenToPosStatesBits; + + public const uint kMatchMinLen = 2; + + public static uint GetLenToPosState(uint len) + { + len -= kMatchMinLen; + if (len < kNumLenToPosStates) + return len; + return (uint)(kNumLenToPosStates - 1); + } + + public const int kNumAlignBits = 4; + public const uint kAlignTableSize = 1 << kNumAlignBits; + public const uint kAlignMask = (kAlignTableSize - 1); + + public const uint kStartPosModelIndex = 4; + public const uint kEndPosModelIndex = 14; + public const uint kNumPosModels = kEndPosModelIndex - kStartPosModelIndex; + + public const uint kNumFullDistances = 1 << ((int)kEndPosModelIndex / 2); + + public const uint kNumLitPosStatesBitsEncodingMax = 4; + public const uint kNumLitContextBitsMax = 8; + + public const int kNumPosStatesBitsMax = 4; + public const uint kNumPosStatesMax = (1 << kNumPosStatesBitsMax); + public const int kNumPosStatesBitsEncodingMax = 4; + public const uint kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax); + + public const int kNumLowLenBits = 3; + public const int kNumMidLenBits = 3; + public const int kNumHighLenBits = 8; + public const uint kNumLowLenSymbols = 1 << kNumLowLenBits; + public const uint kNumMidLenSymbols = 1 << kNumMidLenBits; + public const uint kNumLenSymbols = kNumLowLenSymbols + kNumMidLenSymbols + + (1 << kNumHighLenBits); + public const uint kMatchMaxLen = kMatchMinLen + kNumLenSymbols - 1; + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaDecoder.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaDecoder.cs new file mode 100644 index 0000000000..95d42eed06 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaDecoder.cs @@ -0,0 +1,402 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// LzmaDecoder.cs + +using System; + +namespace SevenZip.Compression.LZMA +{ + using RangeCoder; + + public class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream + { + class LenDecoder + { + BitDecoder m_Choice = new BitDecoder(); + BitDecoder m_Choice2 = new BitDecoder(); + BitTreeDecoder[] m_LowCoder = new BitTreeDecoder[Base.kNumPosStatesMax]; + BitTreeDecoder[] m_MidCoder = new BitTreeDecoder[Base.kNumPosStatesMax]; + BitTreeDecoder m_HighCoder = new BitTreeDecoder(Base.kNumHighLenBits); + uint m_NumPosStates = 0; + + public void Create(uint numPosStates) + { + for (uint posState = m_NumPosStates; posState < numPosStates; posState++) + { + m_LowCoder[posState] = new BitTreeDecoder(Base.kNumLowLenBits); + m_MidCoder[posState] = new BitTreeDecoder(Base.kNumMidLenBits); + } + m_NumPosStates = numPosStates; + } + + public void Init() + { + m_Choice.Init(); + for (uint posState = 0; posState < m_NumPosStates; posState++) + { + m_LowCoder[posState].Init(); + m_MidCoder[posState].Init(); + } + m_Choice2.Init(); + m_HighCoder.Init(); + } + + public uint Decode(RangeCoder.Decoder rangeDecoder, uint posState) + { + if (m_Choice.Decode(rangeDecoder) == 0) + return m_LowCoder[posState].Decode(rangeDecoder); + else + { + uint symbol = Base.kNumLowLenSymbols; + if (m_Choice2.Decode(rangeDecoder) == 0) + symbol += m_MidCoder[posState].Decode(rangeDecoder); + else + { + symbol += Base.kNumMidLenSymbols; + symbol += m_HighCoder.Decode(rangeDecoder); + } + return symbol; + } + } + } + + class LiteralDecoder + { + struct Decoder2 + { + BitDecoder[] m_Decoders; + public void Create() { m_Decoders = new BitDecoder[0x300]; } + public void Init() { for (int i = 0; i < 0x300; i++) m_Decoders[i].Init(); } + + public byte DecodeNormal(RangeCoder.Decoder rangeDecoder) + { + uint symbol = 1; + do + symbol = (symbol << 1) | m_Decoders[symbol].Decode(rangeDecoder); + while (symbol < 0x100); + return (byte)symbol; + } + + public byte DecodeWithMatchByte(RangeCoder.Decoder rangeDecoder, byte matchByte) + { + uint symbol = 1; + do + { + uint matchBit = (uint)(matchByte >> 7) & 1; + matchByte <<= 1; + uint bit = m_Decoders[((1 + matchBit) << 8) + symbol].Decode(rangeDecoder); + symbol = (symbol << 1) | bit; + if (matchBit != bit) + { + while (symbol < 0x100) + symbol = (symbol << 1) | m_Decoders[symbol].Decode(rangeDecoder); + break; + } + } + while (symbol < 0x100); + return (byte)symbol; + } + } + + Decoder2[] m_Coders; + int m_NumPrevBits; + int m_NumPosBits; + uint m_PosMask; + + public void Create(int numPosBits, int numPrevBits) + { + if (m_Coders != null && m_NumPrevBits == numPrevBits && + m_NumPosBits == numPosBits) + return; + m_NumPosBits = numPosBits; + m_PosMask = ((uint)1 << numPosBits) - 1; + m_NumPrevBits = numPrevBits; + uint numStates = (uint)1 << (m_NumPrevBits + m_NumPosBits); + m_Coders = new Decoder2[numStates]; + for (uint i = 0; i < numStates; i++) + m_Coders[i].Create(); + } + + public void Init() + { + uint numStates = (uint)1 << (m_NumPrevBits + m_NumPosBits); + for (uint i = 0; i < numStates; i++) + m_Coders[i].Init(); + } + + uint GetState(uint pos, byte prevByte) + { return ((pos & m_PosMask) << m_NumPrevBits) + (uint)(prevByte >> (8 - m_NumPrevBits)); } + + public byte DecodeNormal(RangeCoder.Decoder rangeDecoder, uint pos, byte prevByte) + { return m_Coders[GetState(pos, prevByte)].DecodeNormal(rangeDecoder); } + + public byte DecodeWithMatchByte(RangeCoder.Decoder rangeDecoder, uint pos, byte prevByte, byte matchByte) + { return m_Coders[GetState(pos, prevByte)].DecodeWithMatchByte(rangeDecoder, matchByte); } + }; + + LZ.OutWindow m_OutWindow = new LZ.OutWindow(); + RangeCoder.Decoder m_RangeDecoder = new RangeCoder.Decoder(); + + BitDecoder[] m_IsMatchDecoders = new BitDecoder[Base.kNumStates << Base.kNumPosStatesBitsMax]; + BitDecoder[] m_IsRepDecoders = new BitDecoder[Base.kNumStates]; + BitDecoder[] m_IsRepG0Decoders = new BitDecoder[Base.kNumStates]; + BitDecoder[] m_IsRepG1Decoders = new BitDecoder[Base.kNumStates]; + BitDecoder[] m_IsRepG2Decoders = new BitDecoder[Base.kNumStates]; + BitDecoder[] m_IsRep0LongDecoders = new BitDecoder[Base.kNumStates << Base.kNumPosStatesBitsMax]; + + BitTreeDecoder[] m_PosSlotDecoder = new BitTreeDecoder[Base.kNumLenToPosStates]; + BitDecoder[] m_PosDecoders = new BitDecoder[Base.kNumFullDistances - Base.kEndPosModelIndex]; + + BitTreeDecoder m_PosAlignDecoder = new BitTreeDecoder(Base.kNumAlignBits); + + LenDecoder m_LenDecoder = new LenDecoder(); + LenDecoder m_RepLenDecoder = new LenDecoder(); + + LiteralDecoder m_LiteralDecoder = new LiteralDecoder(); + + uint m_DictionarySize; + uint m_DictionarySizeCheck; + + uint m_PosStateMask; + + public Decoder() + { + m_DictionarySize = 0xFFFFFFFF; + for (int i = 0; i < Base.kNumLenToPosStates; i++) + m_PosSlotDecoder[i] = new BitTreeDecoder(Base.kNumPosSlotBits); + } + + void SetDictionarySize(uint dictionarySize) + { + if (m_DictionarySize != dictionarySize) + { + m_DictionarySize = dictionarySize; + m_DictionarySizeCheck = Math.Max(m_DictionarySize, 1); + uint blockSize = Math.Max(m_DictionarySizeCheck, (1 << 12)); + m_OutWindow.Create(blockSize); + } + } + + void SetLiteralProperties(int lp, int lc) + { + if (lp > 8) + throw new InvalidParamException(); + if (lc > 8) + throw new InvalidParamException(); + m_LiteralDecoder.Create(lp, lc); + } + + void SetPosBitsProperties(int pb) + { + if (pb > Base.kNumPosStatesBitsMax) + throw new InvalidParamException(); + uint numPosStates = (uint)1 << pb; + m_LenDecoder.Create(numPosStates); + m_RepLenDecoder.Create(numPosStates); + m_PosStateMask = numPosStates - 1; + } + + bool _solid = false; + void Init(System.IO.Stream inStream, System.IO.Stream outStream) + { + m_RangeDecoder.Init(inStream); + m_OutWindow.Init(outStream, _solid); + + uint i; + for (i = 0; i < Base.kNumStates; i++) + { + for (uint j = 0; j <= m_PosStateMask; j++) + { + uint index = (i << Base.kNumPosStatesBitsMax) + j; + m_IsMatchDecoders[index].Init(); + m_IsRep0LongDecoders[index].Init(); + } + m_IsRepDecoders[i].Init(); + m_IsRepG0Decoders[i].Init(); + m_IsRepG1Decoders[i].Init(); + m_IsRepG2Decoders[i].Init(); + } + + m_LiteralDecoder.Init(); + for (i = 0; i < Base.kNumLenToPosStates; i++) + m_PosSlotDecoder[i].Init(); + // m_PosSpecDecoder.Init(); + for (i = 0; i < Base.kNumFullDistances - Base.kEndPosModelIndex; i++) + m_PosDecoders[i].Init(); + + m_LenDecoder.Init(); + m_RepLenDecoder.Init(); + m_PosAlignDecoder.Init(); + } + + public void Code(System.IO.Stream inStream, System.IO.Stream outStream, + Int64 inSize, Int64 outSize, ICodeProgress progress) + { + Init(inStream, outStream); + + Base.State state = new Base.State(); + state.Init(); + uint rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0; + + UInt64 nowPos64 = 0; + UInt64 outSize64 = (UInt64)outSize; + if (nowPos64 < outSize64) + { + if (m_IsMatchDecoders[state.Index << Base.kNumPosStatesBitsMax].Decode(m_RangeDecoder) != 0) + throw new DataErrorException(); + state.UpdateChar(); + byte b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, 0, 0); + m_OutWindow.PutByte(b); + nowPos64++; + } + while (nowPos64 < outSize64) + { + progress.SetProgress(inStream.Position, (long)nowPos64); + // UInt64 next = Math.Min(nowPos64 + (1 << 18), outSize64); + // while(nowPos64 < next) + { + uint posState = (uint)nowPos64 & m_PosStateMask; + if (m_IsMatchDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0) + { + byte b; + byte prevByte = m_OutWindow.GetByte(0); + if (!state.IsCharState()) + b = m_LiteralDecoder.DecodeWithMatchByte(m_RangeDecoder, + (uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0)); + else + b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, (uint)nowPos64, prevByte); + m_OutWindow.PutByte(b); + state.UpdateChar(); + nowPos64++; + } + else + { + uint len; + if (m_IsRepDecoders[state.Index].Decode(m_RangeDecoder) == 1) + { + if (m_IsRepG0Decoders[state.Index].Decode(m_RangeDecoder) == 0) + { + if (m_IsRep0LongDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0) + { + state.UpdateShortRep(); + m_OutWindow.PutByte(m_OutWindow.GetByte(rep0)); + nowPos64++; + continue; + } + } + else + { + UInt32 distance; + if (m_IsRepG1Decoders[state.Index].Decode(m_RangeDecoder) == 0) + { + distance = rep1; + } + else + { + if (m_IsRepG2Decoders[state.Index].Decode(m_RangeDecoder) == 0) + distance = rep2; + else + { + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + len = m_RepLenDecoder.Decode(m_RangeDecoder, posState) + Base.kMatchMinLen; + state.UpdateRep(); + } + else + { + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + len = Base.kMatchMinLen + m_LenDecoder.Decode(m_RangeDecoder, posState); + state.UpdateMatch(); + uint posSlot = m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(m_RangeDecoder); + if (posSlot >= Base.kStartPosModelIndex) + { + int numDirectBits = (int)((posSlot >> 1) - 1); + rep0 = ((2 | (posSlot & 1)) << numDirectBits); + if (posSlot < Base.kEndPosModelIndex) + rep0 += BitTreeDecoder.ReverseDecode(m_PosDecoders, + rep0 - posSlot - 1, m_RangeDecoder, numDirectBits); + else + { + rep0 += (m_RangeDecoder.DecodeDirectBits( + numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits); + rep0 += m_PosAlignDecoder.ReverseDecode(m_RangeDecoder); + } + } + else + rep0 = posSlot; + } + if (rep0 >= m_OutWindow.TrainSize + nowPos64 || rep0 >= m_DictionarySizeCheck) + { + if (rep0 == 0xFFFFFFFF) + break; + throw new DataErrorException(); + } + m_OutWindow.CopyBlock(rep0, len); + nowPos64 += len; + } + } + } + m_OutWindow.Flush(); + m_OutWindow.ReleaseStream(); + m_RangeDecoder.ReleaseStream(); + } + + public void SetDecoderProperties(byte[] properties) + { + if (properties.Length < 5) + throw new InvalidParamException(); + int lc = properties[0] % 9; + int remainder = properties[0] / 9; + int lp = remainder % 5; + int pb = remainder / 5; + if (pb > Base.kNumPosStatesBitsMax) + throw new InvalidParamException(); + UInt32 dictionarySize = 0; + for (int i = 0; i < 4; i++) + dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8); + SetDictionarySize(dictionarySize); + SetLiteralProperties(lp, lc); + SetPosBitsProperties(pb); + } + + public bool Train(System.IO.Stream stream) + { + _solid = true; + return m_OutWindow.Train(stream); + } + + /* + public override bool CanRead { get { return true; }} + public override bool CanWrite { get { return true; }} + public override bool CanSeek { get { return true; }} + public override long Length { get { return 0; }} + public override long Position + { + get { return 0; } + set { } + } + public override void Flush() { } + public override int Read(byte[] buffer, int offset, int count) + { + return 0; + } + public override void Write(byte[] buffer, int offset, int count) + { + } + public override long Seek(long offset, System.IO.SeekOrigin origin) + { + return 0; + } + public override void SetLength(long value) {} + */ + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaEncoder.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaEncoder.cs new file mode 100644 index 0000000000..527a67e0ca --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaEncoder.cs @@ -0,0 +1,1483 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// LzmaEncoder.cs + +using System; + +namespace SevenZip.Compression.LZMA +{ + using RangeCoder; + + public class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties + { + enum EMatchFinderType + { + BT2, + BT4, + }; + + const UInt32 kIfinityPrice = 0xFFFFFFF; + + static Byte[] g_FastPos = new Byte[1 << 11]; + + static Encoder() + { + const Byte kFastSlots = 22; + int c = 2; + g_FastPos[0] = 0; + g_FastPos[1] = 1; + for (Byte slotFast = 2; slotFast < kFastSlots; slotFast++) + { + UInt32 k = ((UInt32)1 << ((slotFast >> 1) - 1)); + for (UInt32 j = 0; j < k; j++, c++) + g_FastPos[c] = slotFast; + } + } + + static UInt32 GetPosSlot(UInt32 pos) + { + if (pos < (1 << 11)) + return g_FastPos[pos]; + if (pos < (1 << 21)) + return (UInt32)(g_FastPos[pos >> 10] + 20); + return (UInt32)(g_FastPos[pos >> 20] + 40); + } + + static UInt32 GetPosSlot2(UInt32 pos) + { + if (pos < (1 << 17)) + return (UInt32)(g_FastPos[pos >> 6] + 12); + if (pos < (1 << 27)) + return (UInt32)(g_FastPos[pos >> 16] + 32); + return (UInt32)(g_FastPos[pos >> 26] + 52); + } + + Base.State _state = new Base.State(); + Byte _previousByte; + UInt32[] _repDistances = new UInt32[Base.kNumRepDistances]; + + void BaseInit() + { + _state.Init(); + _previousByte = 0; + for (UInt32 i = 0; i < Base.kNumRepDistances; i++) + _repDistances[i] = 0; + } + + const int kDefaultDictionaryLogSize = 22; + const UInt32 kNumFastBytesDefault = 0x20; + + class LiteralEncoder + { + public struct Encoder2 + { + BitEncoder[] m_Encoders; + + public void Create() { m_Encoders = new BitEncoder[0x300]; } + + public void Init() { for (int i = 0; i < 0x300; i++) m_Encoders[i].Init(); } + + public void Encode(RangeCoder.Encoder rangeEncoder, byte symbol) + { + uint context = 1; + for (int i = 7; i >= 0; i--) + { + uint bit = (uint)((symbol >> i) & 1); + m_Encoders[context].Encode(rangeEncoder, bit); + context = (context << 1) | bit; + } + } + + public void EncodeMatched(RangeCoder.Encoder rangeEncoder, byte matchByte, byte symbol) + { + uint context = 1; + bool same = true; + for (int i = 7; i >= 0; i--) + { + uint bit = (uint)((symbol >> i) & 1); + uint state = context; + if (same) + { + uint matchBit = (uint)((matchByte >> i) & 1); + state += ((1 + matchBit) << 8); + same = (matchBit == bit); + } + m_Encoders[state].Encode(rangeEncoder, bit); + context = (context << 1) | bit; + } + } + + public uint GetPrice(bool matchMode, byte matchByte, byte symbol) + { + uint price = 0; + uint context = 1; + int i = 7; + if (matchMode) + { + for (; i >= 0; i--) + { + uint matchBit = (uint)(matchByte >> i) & 1; + uint bit = (uint)(symbol >> i) & 1; + price += m_Encoders[((1 + matchBit) << 8) + context].GetPrice(bit); + context = (context << 1) | bit; + if (matchBit != bit) + { + i--; + break; + } + } + } + for (; i >= 0; i--) + { + uint bit = (uint)(symbol >> i) & 1; + price += m_Encoders[context].GetPrice(bit); + context = (context << 1) | bit; + } + return price; + } + } + + Encoder2[] m_Coders; + int m_NumPrevBits; + int m_NumPosBits; + uint m_PosMask; + + public void Create(int numPosBits, int numPrevBits) + { + if (m_Coders != null && m_NumPrevBits == numPrevBits && m_NumPosBits == numPosBits) + return; + m_NumPosBits = numPosBits; + m_PosMask = ((uint)1 << numPosBits) - 1; + m_NumPrevBits = numPrevBits; + uint numStates = (uint)1 << (m_NumPrevBits + m_NumPosBits); + m_Coders = new Encoder2[numStates]; + for (uint i = 0; i < numStates; i++) + m_Coders[i].Create(); + } + + public void Init() + { + uint numStates = (uint)1 << (m_NumPrevBits + m_NumPosBits); + for (uint i = 0; i < numStates; i++) + m_Coders[i].Init(); + } + + public Encoder2 GetSubCoder(UInt32 pos, Byte prevByte) + { return m_Coders[((pos & m_PosMask) << m_NumPrevBits) + (uint)(prevByte >> (8 - m_NumPrevBits))]; } + } + + class LenEncoder + { + RangeCoder.BitEncoder _choice = new RangeCoder.BitEncoder(); + RangeCoder.BitEncoder _choice2 = new RangeCoder.BitEncoder(); + RangeCoder.BitTreeEncoder[] _lowCoder = new RangeCoder.BitTreeEncoder[Base.kNumPosStatesEncodingMax]; + RangeCoder.BitTreeEncoder[] _midCoder = new RangeCoder.BitTreeEncoder[Base.kNumPosStatesEncodingMax]; + RangeCoder.BitTreeEncoder _highCoder = new RangeCoder.BitTreeEncoder(Base.kNumHighLenBits); + + public LenEncoder() + { + for (UInt32 posState = 0; posState < Base.kNumPosStatesEncodingMax; posState++) + { + _lowCoder[posState] = new RangeCoder.BitTreeEncoder(Base.kNumLowLenBits); + _midCoder[posState] = new RangeCoder.BitTreeEncoder(Base.kNumMidLenBits); + } + } + + public void Init(UInt32 numPosStates) + { + _choice.Init(); + _choice2.Init(); + for (UInt32 posState = 0; posState < numPosStates; posState++) + { + _lowCoder[posState].Init(); + _midCoder[posState].Init(); + } + _highCoder.Init(); + } + + public void Encode(RangeCoder.Encoder rangeEncoder, UInt32 symbol, UInt32 posState) + { + if (symbol < Base.kNumLowLenSymbols) + { + _choice.Encode(rangeEncoder, 0); + _lowCoder[posState].Encode(rangeEncoder, symbol); + } + else + { + symbol -= Base.kNumLowLenSymbols; + _choice.Encode(rangeEncoder, 1); + if (symbol < Base.kNumMidLenSymbols) + { + _choice2.Encode(rangeEncoder, 0); + _midCoder[posState].Encode(rangeEncoder, symbol); + } + else + { + _choice2.Encode(rangeEncoder, 1); + _highCoder.Encode(rangeEncoder, symbol - Base.kNumMidLenSymbols); + } + } + } + + public void SetPrices(UInt32 posState, UInt32 numSymbols, UInt32[] prices, UInt32 st) + { + UInt32 a0 = _choice.GetPrice0(); + UInt32 a1 = _choice.GetPrice1(); + UInt32 b0 = a1 + _choice2.GetPrice0(); + UInt32 b1 = a1 + _choice2.GetPrice1(); + UInt32 i = 0; + for (i = 0; i < Base.kNumLowLenSymbols; i++) + { + if (i >= numSymbols) + return; + prices[st + i] = a0 + _lowCoder[posState].GetPrice(i); + } + for (; i < Base.kNumLowLenSymbols + Base.kNumMidLenSymbols; i++) + { + if (i >= numSymbols) + return; + prices[st + i] = b0 + _midCoder[posState].GetPrice(i - Base.kNumLowLenSymbols); + } + for (; i < numSymbols; i++) + prices[st + i] = b1 + _highCoder.GetPrice(i - Base.kNumLowLenSymbols - Base.kNumMidLenSymbols); + } + }; + + const UInt32 kNumLenSpecSymbols = Base.kNumLowLenSymbols + Base.kNumMidLenSymbols; + + class LenPriceTableEncoder : LenEncoder + { + UInt32[] _prices = new UInt32[Base.kNumLenSymbols << Base.kNumPosStatesBitsEncodingMax]; + UInt32 _tableSize; + UInt32[] _counters = new UInt32[Base.kNumPosStatesEncodingMax]; + + public void SetTableSize(UInt32 tableSize) { _tableSize = tableSize; } + + public UInt32 GetPrice(UInt32 symbol, UInt32 posState) + { + return _prices[posState * Base.kNumLenSymbols + symbol]; + } + + void UpdateTable(UInt32 posState) + { + SetPrices(posState, _tableSize, _prices, posState * Base.kNumLenSymbols); + _counters[posState] = _tableSize; + } + + public void UpdateTables(UInt32 numPosStates) + { + for (UInt32 posState = 0; posState < numPosStates; posState++) + UpdateTable(posState); + } + + public new void Encode(RangeCoder.Encoder rangeEncoder, UInt32 symbol, UInt32 posState) + { + base.Encode(rangeEncoder, symbol, posState); + if (--_counters[posState] == 0) + UpdateTable(posState); + } + } + + const UInt32 kNumOpts = 1 << 12; + class Optimal + { + public Base.State State; + + public bool Prev1IsChar; + public bool Prev2; + + public UInt32 PosPrev2; + public UInt32 BackPrev2; + + public UInt32 Price; + public UInt32 PosPrev; + public UInt32 BackPrev; + + public UInt32 Backs0; + public UInt32 Backs1; + public UInt32 Backs2; + public UInt32 Backs3; + + public void MakeAsChar() { BackPrev = 0xFFFFFFFF; Prev1IsChar = false; } + public void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; } + public bool IsShortRep() { return (BackPrev == 0); } + }; + Optimal[] _optimum = new Optimal[kNumOpts]; + LZ.IMatchFinder _matchFinder = null; + RangeCoder.Encoder _rangeEncoder = new RangeCoder.Encoder(); + + RangeCoder.BitEncoder[] _isMatch = new RangeCoder.BitEncoder[Base.kNumStates << Base.kNumPosStatesBitsMax]; + RangeCoder.BitEncoder[] _isRep = new RangeCoder.BitEncoder[Base.kNumStates]; + RangeCoder.BitEncoder[] _isRepG0 = new RangeCoder.BitEncoder[Base.kNumStates]; + RangeCoder.BitEncoder[] _isRepG1 = new RangeCoder.BitEncoder[Base.kNumStates]; + RangeCoder.BitEncoder[] _isRepG2 = new RangeCoder.BitEncoder[Base.kNumStates]; + RangeCoder.BitEncoder[] _isRep0Long = new RangeCoder.BitEncoder[Base.kNumStates << Base.kNumPosStatesBitsMax]; + + RangeCoder.BitTreeEncoder[] _posSlotEncoder = new RangeCoder.BitTreeEncoder[Base.kNumLenToPosStates]; + + RangeCoder.BitEncoder[] _posEncoders = new RangeCoder.BitEncoder[Base.kNumFullDistances - Base.kEndPosModelIndex]; + RangeCoder.BitTreeEncoder _posAlignEncoder = new RangeCoder.BitTreeEncoder(Base.kNumAlignBits); + + LenPriceTableEncoder _lenEncoder = new LenPriceTableEncoder(); + LenPriceTableEncoder _repMatchLenEncoder = new LenPriceTableEncoder(); + + LiteralEncoder _literalEncoder = new LiteralEncoder(); + + UInt32[] _matchDistances = new UInt32[Base.kMatchMaxLen * 2 + 2]; + + UInt32 _numFastBytes = kNumFastBytesDefault; + UInt32 _longestMatchLength; + UInt32 _numDistancePairs; + + UInt32 _additionalOffset; + + UInt32 _optimumEndIndex; + UInt32 _optimumCurrentIndex; + + bool _longestMatchWasFound; + + UInt32[] _posSlotPrices = new UInt32[1 << (Base.kNumPosSlotBits + Base.kNumLenToPosStatesBits)]; + UInt32[] _distancesPrices = new UInt32[Base.kNumFullDistances << Base.kNumLenToPosStatesBits]; + UInt32[] _alignPrices = new UInt32[Base.kAlignTableSize]; + UInt32 _alignPriceCount; + + UInt32 _distTableSize = (kDefaultDictionaryLogSize * 2); + + int _posStateBits = 2; + UInt32 _posStateMask = (4 - 1); + int _numLiteralPosStateBits = 0; + int _numLiteralContextBits = 3; + + UInt32 _dictionarySize = (1 << kDefaultDictionaryLogSize); + UInt32 _dictionarySizePrev = 0xFFFFFFFF; + UInt32 _numFastBytesPrev = 0xFFFFFFFF; + + Int64 nowPos64; + bool _finished; + System.IO.Stream _inStream; + + EMatchFinderType _matchFinderType = EMatchFinderType.BT4; + bool _writeEndMark = false; + + bool _needReleaseMFStream; + + void Create() + { + if (_matchFinder == null) + { + LZ.BinTree bt = new LZ.BinTree(); + int numHashBytes = 4; + if (_matchFinderType == EMatchFinderType.BT2) + numHashBytes = 2; + bt.SetType(numHashBytes); + _matchFinder = bt; + } + _literalEncoder.Create(_numLiteralPosStateBits, _numLiteralContextBits); + + if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes) + return; + _matchFinder.Create(_dictionarySize, kNumOpts, _numFastBytes, Base.kMatchMaxLen + 1); + _dictionarySizePrev = _dictionarySize; + _numFastBytesPrev = _numFastBytes; + } + + public Encoder() + { + for (int i = 0; i < kNumOpts; i++) + _optimum[i] = new Optimal(); + for (int i = 0; i < Base.kNumLenToPosStates; i++) + _posSlotEncoder[i] = new RangeCoder.BitTreeEncoder(Base.kNumPosSlotBits); + } + + void SetWriteEndMarkerMode(bool writeEndMarker) + { + _writeEndMark = writeEndMarker; + } + + void Init() + { + BaseInit(); + _rangeEncoder.Init(); + + uint i; + for (i = 0; i < Base.kNumStates; i++) + { + for (uint j = 0; j <= _posStateMask; j++) + { + uint complexState = (i << Base.kNumPosStatesBitsMax) + j; + _isMatch[complexState].Init(); + _isRep0Long[complexState].Init(); + } + _isRep[i].Init(); + _isRepG0[i].Init(); + _isRepG1[i].Init(); + _isRepG2[i].Init(); + } + _literalEncoder.Init(); + for (i = 0; i < Base.kNumLenToPosStates; i++) + _posSlotEncoder[i].Init(); + for (i = 0; i < Base.kNumFullDistances - Base.kEndPosModelIndex; i++) + _posEncoders[i].Init(); + + _lenEncoder.Init((UInt32)1 << _posStateBits); + _repMatchLenEncoder.Init((UInt32)1 << _posStateBits); + + _posAlignEncoder.Init(); + + _longestMatchWasFound = false; + _optimumEndIndex = 0; + _optimumCurrentIndex = 0; + _additionalOffset = 0; + } + + void ReadMatchDistances(out UInt32 lenRes, out UInt32 numDistancePairs) + { + lenRes = 0; + numDistancePairs = _matchFinder.GetMatches(_matchDistances); + if (numDistancePairs > 0) + { + lenRes = _matchDistances[numDistancePairs - 2]; + if (lenRes == _numFastBytes) + lenRes += _matchFinder.GetMatchLen((int)lenRes - 1, _matchDistances[numDistancePairs - 1], + Base.kMatchMaxLen - lenRes); + } + _additionalOffset++; + } + + + void MovePos(UInt32 num) + { + if (num > 0) + { + _matchFinder.Skip(num); + _additionalOffset += num; + } + } + + UInt32 GetRepLen1Price(Base.State state, UInt32 posState) + { + return _isRepG0[state.Index].GetPrice0() + + _isRep0Long[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0(); + } + + UInt32 GetPureRepPrice(UInt32 repIndex, Base.State state, UInt32 posState) + { + UInt32 price; + if (repIndex == 0) + { + price = _isRepG0[state.Index].GetPrice0(); + price += _isRep0Long[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice1(); + } + else + { + price = _isRepG0[state.Index].GetPrice1(); + if (repIndex == 1) + price += _isRepG1[state.Index].GetPrice0(); + else + { + price += _isRepG1[state.Index].GetPrice1(); + price += _isRepG2[state.Index].GetPrice(repIndex - 2); + } + } + return price; + } + + UInt32 GetRepPrice(UInt32 repIndex, UInt32 len, Base.State state, UInt32 posState) + { + UInt32 price = _repMatchLenEncoder.GetPrice(len - Base.kMatchMinLen, posState); + return price + GetPureRepPrice(repIndex, state, posState); + } + + UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) + { + UInt32 price; + UInt32 lenToPosState = Base.GetLenToPosState(len); + if (pos < Base.kNumFullDistances) + price = _distancesPrices[(lenToPosState * Base.kNumFullDistances) + pos]; + else + price = _posSlotPrices[(lenToPosState << Base.kNumPosSlotBits) + GetPosSlot2(pos)] + + _alignPrices[pos & Base.kAlignMask]; + return price + _lenEncoder.GetPrice(len - Base.kMatchMinLen, posState); + } + + UInt32 Backward(out UInt32 backRes, UInt32 cur) + { + _optimumEndIndex = cur; + UInt32 posMem = _optimum[cur].PosPrev; + UInt32 backMem = _optimum[cur].BackPrev; + do + { + if (_optimum[cur].Prev1IsChar) + { + _optimum[posMem].MakeAsChar(); + _optimum[posMem].PosPrev = posMem - 1; + if (_optimum[cur].Prev2) + { + _optimum[posMem - 1].Prev1IsChar = false; + _optimum[posMem - 1].PosPrev = _optimum[cur].PosPrev2; + _optimum[posMem - 1].BackPrev = _optimum[cur].BackPrev2; + } + } + UInt32 posPrev = posMem; + UInt32 backCur = backMem; + + backMem = _optimum[posPrev].BackPrev; + posMem = _optimum[posPrev].PosPrev; + + _optimum[posPrev].BackPrev = backCur; + _optimum[posPrev].PosPrev = cur; + cur = posPrev; + } + while (cur > 0); + backRes = _optimum[0].BackPrev; + _optimumCurrentIndex = _optimum[0].PosPrev; + return _optimumCurrentIndex; + } + + UInt32[] reps = new UInt32[Base.kNumRepDistances]; + UInt32[] repLens = new UInt32[Base.kNumRepDistances]; + + + UInt32 GetOptimum(UInt32 position, out UInt32 backRes) + { + if (_optimumEndIndex != _optimumCurrentIndex) + { + UInt32 lenRes = _optimum[_optimumCurrentIndex].PosPrev - _optimumCurrentIndex; + backRes = _optimum[_optimumCurrentIndex].BackPrev; + _optimumCurrentIndex = _optimum[_optimumCurrentIndex].PosPrev; + return lenRes; + } + _optimumCurrentIndex = _optimumEndIndex = 0; + + UInt32 lenMain, numDistancePairs; + if (!_longestMatchWasFound) + { + ReadMatchDistances(out lenMain, out numDistancePairs); + } + else + { + lenMain = _longestMatchLength; + numDistancePairs = _numDistancePairs; + _longestMatchWasFound = false; + } + + UInt32 numAvailableBytes = _matchFinder.GetNumAvailableBytes() + 1; + if (numAvailableBytes < 2) + { + backRes = 0xFFFFFFFF; + return 1; + } + if (numAvailableBytes > Base.kMatchMaxLen) + numAvailableBytes = Base.kMatchMaxLen; + + UInt32 repMaxIndex = 0; + UInt32 i; + for (i = 0; i < Base.kNumRepDistances; i++) + { + reps[i] = _repDistances[i]; + repLens[i] = _matchFinder.GetMatchLen(0 - 1, reps[i], Base.kMatchMaxLen); + if (repLens[i] > repLens[repMaxIndex]) + repMaxIndex = i; + } + if (repLens[repMaxIndex] >= _numFastBytes) + { + backRes = repMaxIndex; + UInt32 lenRes = repLens[repMaxIndex]; + MovePos(lenRes - 1); + return lenRes; + } + + if (lenMain >= _numFastBytes) + { + backRes = _matchDistances[numDistancePairs - 1] + Base.kNumRepDistances; + MovePos(lenMain - 1); + return lenMain; + } + + Byte currentByte = _matchFinder.GetIndexByte(0 - 1); + Byte matchByte = _matchFinder.GetIndexByte((Int32)(0 - _repDistances[0] - 1 - 1)); + + if (lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2) + { + backRes = (UInt32)0xFFFFFFFF; + return 1; + } + + _optimum[0].State = _state; + + UInt32 posState = (position & _posStateMask); + + _optimum[1].Price = _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0() + + _literalEncoder.GetSubCoder(position, _previousByte).GetPrice(!_state.IsCharState(), matchByte, currentByte); + _optimum[1].MakeAsChar(); + + UInt32 matchPrice = _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice1(); + UInt32 repMatchPrice = matchPrice + _isRep[_state.Index].GetPrice1(); + + if (matchByte == currentByte) + { + UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(_state, posState); + if (shortRepPrice < _optimum[1].Price) + { + _optimum[1].Price = shortRepPrice; + _optimum[1].MakeAsShortRep(); + } + } + + UInt32 lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]); + + if(lenEnd < 2) + { + backRes = _optimum[1].BackPrev; + return 1; + } + + _optimum[1].PosPrev = 0; + + _optimum[0].Backs0 = reps[0]; + _optimum[0].Backs1 = reps[1]; + _optimum[0].Backs2 = reps[2]; + _optimum[0].Backs3 = reps[3]; + + UInt32 len = lenEnd; + do + _optimum[len--].Price = kIfinityPrice; + while (len >= 2); + + for (i = 0; i < Base.kNumRepDistances; i++) + { + UInt32 repLen = repLens[i]; + if (repLen < 2) + continue; + UInt32 price = repMatchPrice + GetPureRepPrice(i, _state, posState); + do + { + UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(repLen - 2, posState); + Optimal optimum = _optimum[repLen]; + if (curAndLenPrice < optimum.Price) + { + optimum.Price = curAndLenPrice; + optimum.PosPrev = 0; + optimum.BackPrev = i; + optimum.Prev1IsChar = false; + } + } + while (--repLen >= 2); + } + + UInt32 normalMatchPrice = matchPrice + _isRep[_state.Index].GetPrice0(); + + len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2); + if (len <= lenMain) + { + UInt32 offs = 0; + while (len > _matchDistances[offs]) + offs += 2; + for (; ; len++) + { + UInt32 distance = _matchDistances[offs + 1]; + UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState); + Optimal optimum = _optimum[len]; + if (curAndLenPrice < optimum.Price) + { + optimum.Price = curAndLenPrice; + optimum.PosPrev = 0; + optimum.BackPrev = distance + Base.kNumRepDistances; + optimum.Prev1IsChar = false; + } + if (len == _matchDistances[offs]) + { + offs += 2; + if (offs == numDistancePairs) + break; + } + } + } + + UInt32 cur = 0; + + while (true) + { + cur++; + if (cur == lenEnd) + return Backward(out backRes, cur); + UInt32 newLen; + ReadMatchDistances(out newLen, out numDistancePairs); + if (newLen >= _numFastBytes) + { + _numDistancePairs = numDistancePairs; + _longestMatchLength = newLen; + _longestMatchWasFound = true; + return Backward(out backRes, cur); + } + position++; + UInt32 posPrev = _optimum[cur].PosPrev; + Base.State state; + if (_optimum[cur].Prev1IsChar) + { + posPrev--; + if (_optimum[cur].Prev2) + { + state = _optimum[_optimum[cur].PosPrev2].State; + if (_optimum[cur].BackPrev2 < Base.kNumRepDistances) + state.UpdateRep(); + else + state.UpdateMatch(); + } + else + state = _optimum[posPrev].State; + state.UpdateChar(); + } + else + state = _optimum[posPrev].State; + if (posPrev == cur - 1) + { + if (_optimum[cur].IsShortRep()) + state.UpdateShortRep(); + else + state.UpdateChar(); + } + else + { + UInt32 pos; + if (_optimum[cur].Prev1IsChar && _optimum[cur].Prev2) + { + posPrev = _optimum[cur].PosPrev2; + pos = _optimum[cur].BackPrev2; + state.UpdateRep(); + } + else + { + pos = _optimum[cur].BackPrev; + if (pos < Base.kNumRepDistances) + state.UpdateRep(); + else + state.UpdateMatch(); + } + Optimal opt = _optimum[posPrev]; + if (pos < Base.kNumRepDistances) + { + if (pos == 0) + { + reps[0] = opt.Backs0; + reps[1] = opt.Backs1; + reps[2] = opt.Backs2; + reps[3] = opt.Backs3; + } + else if (pos == 1) + { + reps[0] = opt.Backs1; + reps[1] = opt.Backs0; + reps[2] = opt.Backs2; + reps[3] = opt.Backs3; + } + else if (pos == 2) + { + reps[0] = opt.Backs2; + reps[1] = opt.Backs0; + reps[2] = opt.Backs1; + reps[3] = opt.Backs3; + } + else + { + reps[0] = opt.Backs3; + reps[1] = opt.Backs0; + reps[2] = opt.Backs1; + reps[3] = opt.Backs2; + } + } + else + { + reps[0] = (pos - Base.kNumRepDistances); + reps[1] = opt.Backs0; + reps[2] = opt.Backs1; + reps[3] = opt.Backs2; + } + } + _optimum[cur].State = state; + _optimum[cur].Backs0 = reps[0]; + _optimum[cur].Backs1 = reps[1]; + _optimum[cur].Backs2 = reps[2]; + _optimum[cur].Backs3 = reps[3]; + UInt32 curPrice = _optimum[cur].Price; + + currentByte = _matchFinder.GetIndexByte(0 - 1); + matchByte = _matchFinder.GetIndexByte((Int32)(0 - reps[0] - 1 - 1)); + + posState = (position & _posStateMask); + + UInt32 curAnd1Price = curPrice + + _isMatch[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0() + + _literalEncoder.GetSubCoder(position, _matchFinder.GetIndexByte(0 - 2)). + GetPrice(!state.IsCharState(), matchByte, currentByte); + + Optimal nextOptimum = _optimum[cur + 1]; + + bool nextIsChar = false; + if (curAnd1Price < nextOptimum.Price) + { + nextOptimum.Price = curAnd1Price; + nextOptimum.PosPrev = cur; + nextOptimum.MakeAsChar(); + nextIsChar = true; + } + + matchPrice = curPrice + _isMatch[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice1(); + repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1(); + + if (matchByte == currentByte && + !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0)) + { + UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState); + if (shortRepPrice <= nextOptimum.Price) + { + nextOptimum.Price = shortRepPrice; + nextOptimum.PosPrev = cur; + nextOptimum.MakeAsShortRep(); + nextIsChar = true; + } + } + + UInt32 numAvailableBytesFull = _matchFinder.GetNumAvailableBytes() + 1; + numAvailableBytesFull = Math.Min(kNumOpts - 1 - cur, numAvailableBytesFull); + numAvailableBytes = numAvailableBytesFull; + + if (numAvailableBytes < 2) + continue; + if (numAvailableBytes > _numFastBytes) + numAvailableBytes = _numFastBytes; + if (!nextIsChar && matchByte != currentByte) + { + // try Literal + rep0 + UInt32 t = Math.Min(numAvailableBytesFull - 1, _numFastBytes); + UInt32 lenTest2 = _matchFinder.GetMatchLen(0, reps[0], t); + if (lenTest2 >= 2) + { + Base.State state2 = state; + state2.UpdateChar(); + UInt32 posStateNext = (position + 1) & _posStateMask; + UInt32 nextRepMatchPrice = curAnd1Price + + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1() + + _isRep[state2.Index].GetPrice1(); + { + UInt32 offset = cur + 1 + lenTest2; + while (lenEnd < offset) + _optimum[++lenEnd].Price = kIfinityPrice; + UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice( + 0, lenTest2, state2, posStateNext); + Optimal optimum = _optimum[offset]; + if (curAndLenPrice < optimum.Price) + { + optimum.Price = curAndLenPrice; + optimum.PosPrev = cur + 1; + optimum.BackPrev = 0; + optimum.Prev1IsChar = true; + optimum.Prev2 = false; + } + } + } + } + + UInt32 startLen = 2; // speed optimization + + for (UInt32 repIndex = 0; repIndex < Base.kNumRepDistances; repIndex++) + { + UInt32 lenTest = _matchFinder.GetMatchLen(0 - 1, reps[repIndex], numAvailableBytes); + if (lenTest < 2) + continue; + UInt32 lenTestTemp = lenTest; + do + { + while (lenEnd < cur + lenTest) + _optimum[++lenEnd].Price = kIfinityPrice; + UInt32 curAndLenPrice = repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState); + Optimal optimum = _optimum[cur + lenTest]; + if (curAndLenPrice < optimum.Price) + { + optimum.Price = curAndLenPrice; + optimum.PosPrev = cur; + optimum.BackPrev = repIndex; + optimum.Prev1IsChar = false; + } + } + while(--lenTest >= 2); + lenTest = lenTestTemp; + + if (repIndex == 0) + startLen = lenTest + 1; + + // if (_maxMode) + if (lenTest < numAvailableBytesFull) + { + UInt32 t = Math.Min(numAvailableBytesFull - 1 - lenTest, _numFastBytes); + UInt32 lenTest2 = _matchFinder.GetMatchLen((Int32)lenTest, reps[repIndex], t); + if (lenTest2 >= 2) + { + Base.State state2 = state; + state2.UpdateRep(); + UInt32 posStateNext = (position + lenTest) & _posStateMask; + UInt32 curAndLenCharPrice = + repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState) + + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice0() + + _literalEncoder.GetSubCoder(position + lenTest, + _matchFinder.GetIndexByte((Int32)lenTest - 1 - 1)).GetPrice(true, + _matchFinder.GetIndexByte((Int32)((Int32)lenTest - 1 - (Int32)(reps[repIndex] + 1))), + _matchFinder.GetIndexByte((Int32)lenTest - 1)); + state2.UpdateChar(); + posStateNext = (position + lenTest + 1) & _posStateMask; + UInt32 nextMatchPrice = curAndLenCharPrice + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1(); + UInt32 nextRepMatchPrice = nextMatchPrice + _isRep[state2.Index].GetPrice1(); + + // for(; lenTest2 >= 2; lenTest2--) + { + UInt32 offset = lenTest + 1 + lenTest2; + while(lenEnd < cur + offset) + _optimum[++lenEnd].Price = kIfinityPrice; + UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext); + Optimal optimum = _optimum[cur + offset]; + if (curAndLenPrice < optimum.Price) + { + optimum.Price = curAndLenPrice; + optimum.PosPrev = cur + lenTest + 1; + optimum.BackPrev = 0; + optimum.Prev1IsChar = true; + optimum.Prev2 = true; + optimum.PosPrev2 = cur; + optimum.BackPrev2 = repIndex; + } + } + } + } + } + + if (newLen > numAvailableBytes) + { + newLen = numAvailableBytes; + for (numDistancePairs = 0; newLen > _matchDistances[numDistancePairs]; numDistancePairs += 2) ; + _matchDistances[numDistancePairs] = newLen; + numDistancePairs += 2; + } + if (newLen >= startLen) + { + normalMatchPrice = matchPrice + _isRep[state.Index].GetPrice0(); + while (lenEnd < cur + newLen) + _optimum[++lenEnd].Price = kIfinityPrice; + + UInt32 offs = 0; + while (startLen > _matchDistances[offs]) + offs += 2; + + for (UInt32 lenTest = startLen; ; lenTest++) + { + UInt32 curBack = _matchDistances[offs + 1]; + UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(curBack, lenTest, posState); + Optimal optimum = _optimum[cur + lenTest]; + if (curAndLenPrice < optimum.Price) + { + optimum.Price = curAndLenPrice; + optimum.PosPrev = cur; + optimum.BackPrev = curBack + Base.kNumRepDistances; + optimum.Prev1IsChar = false; + } + + if (lenTest == _matchDistances[offs]) + { + if (lenTest < numAvailableBytesFull) + { + UInt32 t = Math.Min(numAvailableBytesFull - 1 - lenTest, _numFastBytes); + UInt32 lenTest2 = _matchFinder.GetMatchLen((Int32)lenTest, curBack, t); + if (lenTest2 >= 2) + { + Base.State state2 = state; + state2.UpdateMatch(); + UInt32 posStateNext = (position + lenTest) & _posStateMask; + UInt32 curAndLenCharPrice = curAndLenPrice + + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice0() + + _literalEncoder.GetSubCoder(position + lenTest, + _matchFinder.GetIndexByte((Int32)lenTest - 1 - 1)). + GetPrice(true, + _matchFinder.GetIndexByte((Int32)lenTest - (Int32)(curBack + 1) - 1), + _matchFinder.GetIndexByte((Int32)lenTest - 1)); + state2.UpdateChar(); + posStateNext = (position + lenTest + 1) & _posStateMask; + UInt32 nextMatchPrice = curAndLenCharPrice + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1(); + UInt32 nextRepMatchPrice = nextMatchPrice + _isRep[state2.Index].GetPrice1(); + + UInt32 offset = lenTest + 1 + lenTest2; + while (lenEnd < cur + offset) + _optimum[++lenEnd].Price = kIfinityPrice; + curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext); + optimum = _optimum[cur + offset]; + if (curAndLenPrice < optimum.Price) + { + optimum.Price = curAndLenPrice; + optimum.PosPrev = cur + lenTest + 1; + optimum.BackPrev = 0; + optimum.Prev1IsChar = true; + optimum.Prev2 = true; + optimum.PosPrev2 = cur; + optimum.BackPrev2 = curBack + Base.kNumRepDistances; + } + } + } + offs += 2; + if (offs == numDistancePairs) + break; + } + } + } + } + } + + bool ChangePair(UInt32 smallDist, UInt32 bigDist) + { + const int kDif = 7; + return (smallDist < ((UInt32)(1) << (32 - kDif)) && bigDist >= (smallDist << kDif)); + } + + void WriteEndMarker(UInt32 posState) + { + if (!_writeEndMark) + return; + + _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].Encode(_rangeEncoder, 1); + _isRep[_state.Index].Encode(_rangeEncoder, 0); + _state.UpdateMatch(); + UInt32 len = Base.kMatchMinLen; + _lenEncoder.Encode(_rangeEncoder, len - Base.kMatchMinLen, posState); + UInt32 posSlot = (1 << Base.kNumPosSlotBits) - 1; + UInt32 lenToPosState = Base.GetLenToPosState(len); + _posSlotEncoder[lenToPosState].Encode(_rangeEncoder, posSlot); + int footerBits = 30; + UInt32 posReduced = (((UInt32)1) << footerBits) - 1; + _rangeEncoder.EncodeDirectBits(posReduced >> Base.kNumAlignBits, footerBits - Base.kNumAlignBits); + _posAlignEncoder.ReverseEncode(_rangeEncoder, posReduced & Base.kAlignMask); + } + + void Flush(UInt32 nowPos) + { + ReleaseMFStream(); + WriteEndMarker(nowPos & _posStateMask); + _rangeEncoder.FlushData(); + _rangeEncoder.FlushStream(); + } + + public void CodeOneBlock(out Int64 inSize, out Int64 outSize, out bool finished) + { + inSize = 0; + outSize = 0; + finished = true; + + if (_inStream != null) + { + _matchFinder.SetStream(_inStream); + _matchFinder.Init(); + _needReleaseMFStream = true; + _inStream = null; + if (_trainSize > 0) + _matchFinder.Skip(_trainSize); + } + + if (_finished) + return; + _finished = true; + + + Int64 progressPosValuePrev = nowPos64; + if (nowPos64 == 0) + { + if (_matchFinder.GetNumAvailableBytes() == 0) + { + Flush((UInt32)nowPos64); + return; + } + UInt32 len, numDistancePairs; // it's not used + ReadMatchDistances(out len, out numDistancePairs); + UInt32 posState = (UInt32)(nowPos64) & _posStateMask; + _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].Encode(_rangeEncoder, 0); + _state.UpdateChar(); + Byte curByte = _matchFinder.GetIndexByte((Int32)(0 - _additionalOffset)); + _literalEncoder.GetSubCoder((UInt32)(nowPos64), _previousByte).Encode(_rangeEncoder, curByte); + _previousByte = curByte; + _additionalOffset--; + nowPos64++; + } + if (_matchFinder.GetNumAvailableBytes() == 0) + { + Flush((UInt32)nowPos64); + return; + } + while (true) + { + UInt32 pos; + UInt32 len = GetOptimum((UInt32)nowPos64, out pos); + + UInt32 posState = ((UInt32)nowPos64) & _posStateMask; + UInt32 complexState = (_state.Index << Base.kNumPosStatesBitsMax) + posState; + if (len == 1 && pos == 0xFFFFFFFF) + { + _isMatch[complexState].Encode(_rangeEncoder, 0); + Byte curByte = _matchFinder.GetIndexByte((Int32)(0 - _additionalOffset)); + LiteralEncoder.Encoder2 subCoder = _literalEncoder.GetSubCoder((UInt32)nowPos64, _previousByte); + if (!_state.IsCharState()) + { + Byte matchByte = _matchFinder.GetIndexByte((Int32)(0 - _repDistances[0] - 1 - _additionalOffset)); + subCoder.EncodeMatched(_rangeEncoder, matchByte, curByte); + } + else + subCoder.Encode(_rangeEncoder, curByte); + _previousByte = curByte; + _state.UpdateChar(); + } + else + { + _isMatch[complexState].Encode(_rangeEncoder, 1); + if (pos < Base.kNumRepDistances) + { + _isRep[_state.Index].Encode(_rangeEncoder, 1); + if (pos == 0) + { + _isRepG0[_state.Index].Encode(_rangeEncoder, 0); + if (len == 1) + _isRep0Long[complexState].Encode(_rangeEncoder, 0); + else + _isRep0Long[complexState].Encode(_rangeEncoder, 1); + } + else + { + _isRepG0[_state.Index].Encode(_rangeEncoder, 1); + if (pos == 1) + _isRepG1[_state.Index].Encode(_rangeEncoder, 0); + else + { + _isRepG1[_state.Index].Encode(_rangeEncoder, 1); + _isRepG2[_state.Index].Encode(_rangeEncoder, pos - 2); + } + } + if (len == 1) + _state.UpdateShortRep(); + else + { + _repMatchLenEncoder.Encode(_rangeEncoder, len - Base.kMatchMinLen, posState); + _state.UpdateRep(); + } + UInt32 distance = _repDistances[pos]; + if (pos != 0) + { + for (UInt32 i = pos; i >= 1; i--) + _repDistances[i] = _repDistances[i - 1]; + _repDistances[0] = distance; + } + } + else + { + _isRep[_state.Index].Encode(_rangeEncoder, 0); + _state.UpdateMatch(); + _lenEncoder.Encode(_rangeEncoder, len - Base.kMatchMinLen, posState); + pos -= Base.kNumRepDistances; + UInt32 posSlot = GetPosSlot(pos); + UInt32 lenToPosState = Base.GetLenToPosState(len); + _posSlotEncoder[lenToPosState].Encode(_rangeEncoder, posSlot); + + if (posSlot >= Base.kStartPosModelIndex) + { + int footerBits = (int)((posSlot >> 1) - 1); + UInt32 baseVal = ((2 | (posSlot & 1)) << footerBits); + UInt32 posReduced = pos - baseVal; + + if (posSlot < Base.kEndPosModelIndex) + RangeCoder.BitTreeEncoder.ReverseEncode(_posEncoders, + baseVal - posSlot - 1, _rangeEncoder, footerBits, posReduced); + else + { + _rangeEncoder.EncodeDirectBits(posReduced >> Base.kNumAlignBits, footerBits - Base.kNumAlignBits); + _posAlignEncoder.ReverseEncode(_rangeEncoder, posReduced & Base.kAlignMask); + _alignPriceCount++; + } + } + UInt32 distance = pos; + for (UInt32 i = Base.kNumRepDistances - 1; i >= 1; i--) + _repDistances[i] = _repDistances[i - 1]; + _repDistances[0] = distance; + _matchPriceCount++; + } + _previousByte = _matchFinder.GetIndexByte((Int32)(len - 1 - _additionalOffset)); + } + _additionalOffset -= len; + nowPos64 += len; + if (_additionalOffset == 0) + { + // if (!_fastMode) + if (_matchPriceCount >= (1 << 7)) + FillDistancesPrices(); + if (_alignPriceCount >= Base.kAlignTableSize) + FillAlignPrices(); + inSize = nowPos64; + outSize = _rangeEncoder.GetProcessedSizeAdd(); + if (_matchFinder.GetNumAvailableBytes() == 0) + { + Flush((UInt32)nowPos64); + return; + } + + if (nowPos64 - progressPosValuePrev >= (1 << 12)) + { + _finished = false; + finished = false; + return; + } + } + } + } + + void ReleaseMFStream() + { + if (_matchFinder != null && _needReleaseMFStream) + { + _matchFinder.ReleaseStream(); + _needReleaseMFStream = false; + } + } + + void SetOutStream(System.IO.Stream outStream) { _rangeEncoder.SetStream(outStream); } + void ReleaseOutStream() { _rangeEncoder.ReleaseStream(); } + + void ReleaseStreams() + { + ReleaseMFStream(); + ReleaseOutStream(); + } + + void SetStreams(System.IO.Stream inStream, System.IO.Stream outStream, + Int64 inSize, Int64 outSize) + { + _inStream = inStream; + _finished = false; + Create(); + SetOutStream(outStream); + Init(); + + // if (!_fastMode) + { + FillDistancesPrices(); + FillAlignPrices(); + } + + _lenEncoder.SetTableSize(_numFastBytes + 1 - Base.kMatchMinLen); + _lenEncoder.UpdateTables((UInt32)1 << _posStateBits); + _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - Base.kMatchMinLen); + _repMatchLenEncoder.UpdateTables((UInt32)1 << _posStateBits); + + nowPos64 = 0; + } + + + public void Code(System.IO.Stream inStream, System.IO.Stream outStream, + Int64 inSize, Int64 outSize, ICodeProgress progress) + { + _needReleaseMFStream = false; + try + { + SetStreams(inStream, outStream, inSize, outSize); + while (true) + { + Int64 processedInSize; + Int64 processedOutSize; + bool finished; + CodeOneBlock(out processedInSize, out processedOutSize, out finished); + if (finished) + return; + if (progress != null) + { + progress.SetProgress(processedInSize, processedOutSize); + } + } + } + finally + { + ReleaseStreams(); + } + } + + const int kPropSize = 5; + Byte[] properties = new Byte[kPropSize]; + + public void WriteCoderProperties(System.IO.Stream outStream) + { + properties[0] = (Byte)((_posStateBits * 5 + _numLiteralPosStateBits) * 9 + _numLiteralContextBits); + for (int i = 0; i < 4; i++) + properties[1 + i] = (Byte)((_dictionarySize >> (8 * i)) & 0xFF); + outStream.Write(properties, 0, kPropSize); + } + + UInt32[] tempPrices = new UInt32[Base.kNumFullDistances]; + UInt32 _matchPriceCount; + + void FillDistancesPrices() + { + for (UInt32 i = Base.kStartPosModelIndex; i < Base.kNumFullDistances; i++) + { + UInt32 posSlot = GetPosSlot(i); + int footerBits = (int)((posSlot >> 1) - 1); + UInt32 baseVal = ((2 | (posSlot & 1)) << footerBits); + tempPrices[i] = BitTreeEncoder.ReverseGetPrice(_posEncoders, + baseVal - posSlot - 1, footerBits, i - baseVal); + } + + for (UInt32 lenToPosState = 0; lenToPosState < Base.kNumLenToPosStates; lenToPosState++) + { + UInt32 posSlot; + RangeCoder.BitTreeEncoder encoder = _posSlotEncoder[lenToPosState]; + + UInt32 st = (lenToPosState << Base.kNumPosSlotBits); + for (posSlot = 0; posSlot < _distTableSize; posSlot++) + _posSlotPrices[st + posSlot] = encoder.GetPrice(posSlot); + for (posSlot = Base.kEndPosModelIndex; posSlot < _distTableSize; posSlot++) + _posSlotPrices[st + posSlot] += ((((posSlot >> 1) - 1) - Base.kNumAlignBits) << RangeCoder.BitEncoder.kNumBitPriceShiftBits); + + UInt32 st2 = lenToPosState * Base.kNumFullDistances; + UInt32 i; + for (i = 0; i < Base.kStartPosModelIndex; i++) + _distancesPrices[st2 + i] = _posSlotPrices[st + i]; + for (; i < Base.kNumFullDistances; i++) + _distancesPrices[st2 + i] = _posSlotPrices[st + GetPosSlot(i)] + tempPrices[i]; + } + _matchPriceCount = 0; + } + + void FillAlignPrices() + { + for (UInt32 i = 0; i < Base.kAlignTableSize; i++) + _alignPrices[i] = _posAlignEncoder.ReverseGetPrice(i); + _alignPriceCount = 0; + } + + + static string[] kMatchFinderIDs = + { + "BT2", + "BT4", + }; + + static int FindMatchFinder(string s) + { + for (int m = 0; m < kMatchFinderIDs.Length; m++) + if (s == kMatchFinderIDs[m]) + return m; + return -1; + } + + public void SetCoderProperties(CoderPropID[] propIDs, object[] properties) + { + for (UInt32 i = 0; i < properties.Length; i++) + { + object prop = properties[i]; + switch (propIDs[i]) + { + case CoderPropID.NumFastBytes: + { + if (!(prop is Int32)) + throw new InvalidParamException(); + Int32 numFastBytes = (Int32)prop; + if (numFastBytes < 5 || numFastBytes > Base.kMatchMaxLen) + throw new InvalidParamException(); + _numFastBytes = (UInt32)numFastBytes; + break; + } + case CoderPropID.Algorithm: + { + /* + if (!(prop is Int32)) + throw new InvalidParamException(); + Int32 maximize = (Int32)prop; + _fastMode = (maximize == 0); + _maxMode = (maximize >= 2); + */ + break; + } + case CoderPropID.MatchFinder: + { + if (!(prop is String)) + throw new InvalidParamException(); + EMatchFinderType matchFinderIndexPrev = _matchFinderType; + int m = FindMatchFinder(((string)prop).ToUpper()); + if (m < 0) + throw new InvalidParamException(); + _matchFinderType = (EMatchFinderType)m; + if (_matchFinder != null && matchFinderIndexPrev != _matchFinderType) + { + _dictionarySizePrev = 0xFFFFFFFF; + _matchFinder = null; + } + break; + } + case CoderPropID.DictionarySize: + { + const int kDicLogSizeMaxCompress = 30; + if (!(prop is Int32)) + throw new InvalidParamException(); ; + Int32 dictionarySize = (Int32)prop; + if (dictionarySize < (UInt32)(1 << Base.kDicLogSizeMin) || + dictionarySize > (UInt32)(1 << kDicLogSizeMaxCompress)) + throw new InvalidParamException(); + _dictionarySize = (UInt32)dictionarySize; + int dicLogSize; + for (dicLogSize = 0; dicLogSize < (UInt32)kDicLogSizeMaxCompress; dicLogSize++) + if (dictionarySize <= ((UInt32)(1) << dicLogSize)) + break; + _distTableSize = (UInt32)dicLogSize * 2; + break; + } + case CoderPropID.PosStateBits: + { + if (!(prop is Int32)) + throw new InvalidParamException(); + Int32 v = (Int32)prop; + if (v < 0 || v > (UInt32)Base.kNumPosStatesBitsEncodingMax) + throw new InvalidParamException(); + _posStateBits = (int)v; + _posStateMask = (((UInt32)1) << (int)_posStateBits) - 1; + break; + } + case CoderPropID.LitPosBits: + { + if (!(prop is Int32)) + throw new InvalidParamException(); + Int32 v = (Int32)prop; + if (v < 0 || v > (UInt32)Base.kNumLitPosStatesBitsEncodingMax) + throw new InvalidParamException(); + _numLiteralPosStateBits = (int)v; + break; + } + case CoderPropID.LitContextBits: + { + if (!(prop is Int32)) + throw new InvalidParamException(); + Int32 v = (Int32)prop; + if (v < 0 || v > (UInt32)Base.kNumLitContextBitsMax) + throw new InvalidParamException(); ; + _numLiteralContextBits = (int)v; + break; + } + case CoderPropID.EndMarker: + { + if (!(prop is Boolean)) + throw new InvalidParamException(); + SetWriteEndMarkerMode((Boolean)prop); + break; + } + default: + throw new InvalidParamException(); + } + } + } + + uint _trainSize = 0; + public void SetTrainSize(uint trainSize) + { + _trainSize = trainSize; + } + + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoder.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoder.cs new file mode 100644 index 0000000000..d9c2e30ce0 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoder.cs @@ -0,0 +1,237 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +namespace SevenZip.Compression.RangeCoder +{ + class Encoder + { + public const uint kTopValue = (1 << 24); + + System.IO.Stream Stream; + + public UInt64 Low; + public uint Range; + uint _cacheSize; + byte _cache; + + long StartPosition; + + public void SetStream(System.IO.Stream stream) + { + Stream = stream; + } + + public void ReleaseStream() + { + Stream = null; + } + + public void Init() + { + StartPosition = Stream.Position; + + Low = 0; + Range = 0xFFFFFFFF; + _cacheSize = 1; + _cache = 0; + } + + public void FlushData() + { + for (int i = 0; i < 5; i++) + ShiftLow(); + } + + public void FlushStream() + { + Stream.Flush(); + } + + public void CloseStream() + { + Stream.Dispose(); + } + + public void Encode(uint start, uint size, uint total) + { + Low += start * (Range /= total); + Range *= size; + while (Range < kTopValue) + { + Range <<= 8; + ShiftLow(); + } + } + + public void ShiftLow() + { + if ((uint)Low < (uint)0xFF000000 || (uint)(Low >> 32) == 1) + { + byte temp = _cache; + do + { + Stream.WriteByte((byte)(temp + (Low >> 32))); + temp = 0xFF; + } + while (--_cacheSize != 0); + _cache = (byte)(((uint)Low) >> 24); + } + _cacheSize++; + Low = ((uint)Low) << 8; + } + + public void EncodeDirectBits(uint v, int numTotalBits) + { + for (int i = numTotalBits - 1; i >= 0; i--) + { + Range >>= 1; + if (((v >> i) & 1) == 1) + Low += Range; + if (Range < kTopValue) + { + Range <<= 8; + ShiftLow(); + } + } + } + + public void EncodeBit(uint size0, int numTotalBits, uint symbol) + { + uint newBound = (Range >> numTotalBits) * size0; + if (symbol == 0) + Range = newBound; + else + { + Low += newBound; + Range -= newBound; + } + while (Range < kTopValue) + { + Range <<= 8; + ShiftLow(); + } + } + + public long GetProcessedSizeAdd() + { + return _cacheSize + + Stream.Position - StartPosition + 4; + // (long)Stream.GetProcessedSize(); + } + } + + class Decoder + { + public const uint kTopValue = (1 << 24); + public uint Range; + public uint Code; + // public Buffer.InBuffer Stream = new Buffer.InBuffer(1 << 16); + public System.IO.Stream Stream; + + public void Init(System.IO.Stream stream) + { + // Stream.Init(stream); + Stream = stream; + + Code = 0; + Range = 0xFFFFFFFF; + for (int i = 0; i < 5; i++) + Code = (Code << 8) | (byte)Stream.ReadByte(); + } + + public void ReleaseStream() + { + // Stream.ReleaseStream(); + Stream = null; + } + + public void CloseStream() + { + Stream.Dispose(); + } + + public void Normalize() + { + while (Range < kTopValue) + { + Code = (Code << 8) | (byte)Stream.ReadByte(); + Range <<= 8; + } + } + + public void Normalize2() + { + if (Range < kTopValue) + { + Code = (Code << 8) | (byte)Stream.ReadByte(); + Range <<= 8; + } + } + + public uint GetThreshold(uint total) + { + return Code / (Range /= total); + } + + public void Decode(uint start, uint size, uint total) + { + Code -= start * Range; + Range *= size; + Normalize(); + } + + public uint DecodeDirectBits(int numTotalBits) + { + uint range = Range; + uint code = Code; + uint result = 0; + for (int i = numTotalBits; i > 0; i--) + { + range >>= 1; + /* + result <<= 1; + if (code >= range) + { + code -= range; + result |= 1; + } + */ + uint t = (code - range) >> 31; + code -= range & (t - 1); + result = (result << 1) | (1 - t); + + if (range < kTopValue) + { + code = (code << 8) | (byte)Stream.ReadByte(); + range <<= 8; + } + } + Range = range; + Code = code; + return result; + } + + public uint DecodeBit(uint size0, int numTotalBits) + { + uint newBound = (Range >> numTotalBits) * size0; + uint symbol; + if (Code < newBound) + { + symbol = 0; + Range = newBound; + } + else + { + symbol = 1; + Code -= newBound; + Range -= newBound; + } + Normalize(); + return symbol; + } + + // ulong GetProcessedSize() {return Stream.GetProcessedSize(); } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBit.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBit.cs new file mode 100644 index 0000000000..46d27ed0f6 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBit.cs @@ -0,0 +1,120 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +namespace SevenZip.Compression.RangeCoder +{ + struct BitEncoder + { + public const int kNumBitModelTotalBits = 11; + public const uint kBitModelTotal = (1 << kNumBitModelTotalBits); + const int kNumMoveBits = 5; + const int kNumMoveReducingBits = 2; + public const int kNumBitPriceShiftBits = 6; + + uint Prob; + + public void Init() { Prob = kBitModelTotal >> 1; } + + public void UpdateModel(uint symbol) + { + if (symbol == 0) + Prob += (kBitModelTotal - Prob) >> kNumMoveBits; + else + Prob -= (Prob) >> kNumMoveBits; + } + + public void Encode(Encoder encoder, uint symbol) + { + // encoder.EncodeBit(Prob, kNumBitModelTotalBits, symbol); + // UpdateModel(symbol); + uint newBound = (encoder.Range >> kNumBitModelTotalBits) * Prob; + if (symbol == 0) + { + encoder.Range = newBound; + Prob += (kBitModelTotal - Prob) >> kNumMoveBits; + } + else + { + encoder.Low += newBound; + encoder.Range -= newBound; + Prob -= (Prob) >> kNumMoveBits; + } + if (encoder.Range < Encoder.kTopValue) + { + encoder.Range <<= 8; + encoder.ShiftLow(); + } + } + + private static UInt32[] ProbPrices = new UInt32[kBitModelTotal >> kNumMoveReducingBits]; + + static BitEncoder() + { + const int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits); + for (int i = kNumBits - 1; i >= 0; i--) + { + UInt32 start = (UInt32)1 << (kNumBits - i - 1); + UInt32 end = (UInt32)1 << (kNumBits - i); + for (UInt32 j = start; j < end; j++) + ProbPrices[j] = ((UInt32)i << kNumBitPriceShiftBits) + + (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1)); + } + } + + public uint GetPrice(uint symbol) + { + return ProbPrices[(((Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits]; + } + public uint GetPrice0() { return ProbPrices[Prob >> kNumMoveReducingBits]; } + public uint GetPrice1() { return ProbPrices[(kBitModelTotal - Prob) >> kNumMoveReducingBits]; } + } + + struct BitDecoder + { + public const int kNumBitModelTotalBits = 11; + public const uint kBitModelTotal = (1 << kNumBitModelTotalBits); + const int kNumMoveBits = 5; + + uint Prob; + + public void UpdateModel(int numMoveBits, uint symbol) + { + if (symbol == 0) + Prob += (kBitModelTotal - Prob) >> numMoveBits; + else + Prob -= (Prob) >> numMoveBits; + } + + public void Init() { Prob = kBitModelTotal >> 1; } + + public uint Decode(RangeCoder.Decoder rangeDecoder) + { + uint newBound = (uint)(rangeDecoder.Range >> kNumBitModelTotalBits) * (uint)Prob; + if (rangeDecoder.Code < newBound) + { + rangeDecoder.Range = newBound; + Prob += (kBitModelTotal - Prob) >> kNumMoveBits; + if (rangeDecoder.Range < Decoder.kTopValue) + { + rangeDecoder.Code = (rangeDecoder.Code << 8) | (byte)rangeDecoder.Stream.ReadByte(); + rangeDecoder.Range <<= 8; + } + return 0; + } + else + { + rangeDecoder.Range -= newBound; + rangeDecoder.Code -= newBound; + Prob -= (Prob) >> kNumMoveBits; + if (rangeDecoder.Range < Decoder.kTopValue) + { + rangeDecoder.Code = (rangeDecoder.Code << 8) | (byte)rangeDecoder.Stream.ReadByte(); + rangeDecoder.Range <<= 8; + } + return 1; + } + } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs new file mode 100644 index 0000000000..f7985c47ba --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs @@ -0,0 +1,160 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +namespace SevenZip.Compression.RangeCoder +{ + struct BitTreeEncoder + { + BitEncoder[] Models; + int NumBitLevels; + + public BitTreeEncoder(int numBitLevels) + { + NumBitLevels = numBitLevels; + Models = new BitEncoder[1 << numBitLevels]; + } + + public void Init() + { + for (uint i = 1; i < (1 << NumBitLevels); i++) + Models[i].Init(); + } + + public void Encode(Encoder rangeEncoder, UInt32 symbol) + { + UInt32 m = 1; + for (int bitIndex = NumBitLevels; bitIndex > 0; ) + { + bitIndex--; + UInt32 bit = (symbol >> bitIndex) & 1; + Models[m].Encode(rangeEncoder, bit); + m = (m << 1) | bit; + } + } + + public void ReverseEncode(Encoder rangeEncoder, UInt32 symbol) + { + UInt32 m = 1; + for (UInt32 i = 0; i < NumBitLevels; i++) + { + UInt32 bit = symbol & 1; + Models[m].Encode(rangeEncoder, bit); + m = (m << 1) | bit; + symbol >>= 1; + } + } + + public UInt32 GetPrice(UInt32 symbol) + { + UInt32 price = 0; + UInt32 m = 1; + for (int bitIndex = NumBitLevels; bitIndex > 0; ) + { + bitIndex--; + UInt32 bit = (symbol >> bitIndex) & 1; + price += Models[m].GetPrice(bit); + m = (m << 1) + bit; + } + return price; + } + + public UInt32 ReverseGetPrice(UInt32 symbol) + { + UInt32 price = 0; + UInt32 m = 1; + for (int i = NumBitLevels; i > 0; i--) + { + UInt32 bit = symbol & 1; + symbol >>= 1; + price += Models[m].GetPrice(bit); + m = (m << 1) | bit; + } + return price; + } + + public static UInt32 ReverseGetPrice(BitEncoder[] Models, UInt32 startIndex, + int NumBitLevels, UInt32 symbol) + { + UInt32 price = 0; + UInt32 m = 1; + for (int i = NumBitLevels; i > 0; i--) + { + UInt32 bit = symbol & 1; + symbol >>= 1; + price += Models[startIndex + m].GetPrice(bit); + m = (m << 1) | bit; + } + return price; + } + + public static void ReverseEncode(BitEncoder[] Models, UInt32 startIndex, + Encoder rangeEncoder, int NumBitLevels, UInt32 symbol) + { + UInt32 m = 1; + for (int i = 0; i < NumBitLevels; i++) + { + UInt32 bit = symbol & 1; + Models[startIndex + m].Encode(rangeEncoder, bit); + m = (m << 1) | bit; + symbol >>= 1; + } + } + } + + struct BitTreeDecoder + { + BitDecoder[] Models; + int NumBitLevels; + + public BitTreeDecoder(int numBitLevels) + { + NumBitLevels = numBitLevels; + Models = new BitDecoder[1 << numBitLevels]; + } + + public void Init() + { + for (uint i = 1; i < (1 << NumBitLevels); i++) + Models[i].Init(); + } + + public uint Decode(RangeCoder.Decoder rangeDecoder) + { + uint m = 1; + for (int bitIndex = NumBitLevels; bitIndex > 0; bitIndex--) + m = (m << 1) + Models[m].Decode(rangeDecoder); + return m - ((uint)1 << NumBitLevels); + } + + public uint ReverseDecode(RangeCoder.Decoder rangeDecoder) + { + uint m = 1; + uint symbol = 0; + for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++) + { + uint bit = Models[m].Decode(rangeDecoder); + m <<= 1; + m += bit; + symbol |= (bit << bitIndex); + } + return symbol; + } + + public static uint ReverseDecode(BitDecoder[] Models, UInt32 startIndex, + RangeCoder.Decoder rangeDecoder, int NumBitLevels) + { + uint m = 1; + uint symbol = 0; + for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++) + { + uint bit = Models[startIndex + m].Decode(rangeDecoder); + m <<= 1; + m += bit; + symbol |= (bit << bitIndex); + } + return symbol; + } + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/ICoder.cs b/src/Microsoft.DotNet.Archive/LZMA/ICoder.cs new file mode 100644 index 0000000000..992f6823fb --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/ICoder.cs @@ -0,0 +1,160 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +// ICoder.h + +using System; + +namespace SevenZip +{ + /// + /// The exception that is thrown when an error in input stream occurs during decoding. + /// + class DataErrorException : Exception + { + public DataErrorException(): base("Data Error") { } + } + + /// + /// The exception that is thrown when the value of an argument is outside the allowable range. + /// + class InvalidParamException : Exception + { + public InvalidParamException(): base("Invalid Parameter") { } + } + + public interface ICodeProgress + { + /// + /// Callback progress. + /// + /// + /// input size. -1 if unknown. + /// + /// + /// output size. -1 if unknown. + /// + void SetProgress(Int64 inSize, Int64 outSize); + }; + + public interface ICoder + { + /// + /// Codes streams. + /// + /// + /// input Stream. + /// + /// + /// output Stream. + /// + /// + /// input Size. -1 if unknown. + /// + /// + /// output Size. -1 if unknown. + /// + /// + /// callback progress reference. + /// + /// + /// if input stream is not valid + /// + void Code(System.IO.Stream inStream, System.IO.Stream outStream, + Int64 inSize, Int64 outSize, ICodeProgress progress); + }; + + /* + public interface ICoder2 + { + void Code(ISequentialInStream []inStreams, + const UInt64 []inSizes, + ISequentialOutStream []outStreams, + UInt64 []outSizes, + ICodeProgress progress); + }; + */ + + /// + /// Provides the fields that represent properties idenitifiers for compressing. + /// + public enum CoderPropID + { + /// + /// Specifies default property. + /// + DefaultProp = 0, + /// + /// Specifies size of dictionary. + /// + DictionarySize, + /// + /// Specifies size of memory for PPM*. + /// + UsedMemorySize, + /// + /// Specifies order for PPM methods. + /// + Order, + /// + /// Specifies Block Size. + /// + BlockSize, + /// + /// Specifies number of postion state bits for LZMA (0 <= x <= 4). + /// + PosStateBits, + /// + /// Specifies number of literal context bits for LZMA (0 <= x <= 8). + /// + LitContextBits, + /// + /// Specifies number of literal position bits for LZMA (0 <= x <= 4). + /// + LitPosBits, + /// + /// Specifies number of fast bytes for LZ*. + /// + NumFastBytes, + /// + /// Specifies match finder. LZMA: "BT2", "BT4" or "BT4B". + /// + MatchFinder, + /// + /// Specifies the number of match finder cyckes. + /// + MatchFinderCycles, + /// + /// Specifies number of passes. + /// + NumPasses, + /// + /// Specifies number of algorithm. + /// + Algorithm, + /// + /// Specifies the number of threads. + /// + NumThreads, + /// + /// Specifies mode with end marker. + /// + EndMarker + }; + + + public interface ISetCoderProperties + { + void SetCoderProperties(CoderPropID[] propIDs, object[] properties); + }; + + public interface IWriteCoderProperties + { + void WriteCoderProperties(System.IO.Stream outStream); + } + + public interface ISetDecoderProperties + { + void SetDecoderProperties(byte[] properties); + } +} diff --git a/src/Microsoft.DotNet.Archive/LZMA/README.md b/src/Microsoft.DotNet.Archive/LZMA/README.md new file mode 100644 index 0000000000..74e2758529 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/LZMA/README.md @@ -0,0 +1,10 @@ +## LZMA SDK +This source came from the C# implementation of LZMA from the LZMA SDK, version 16.02, from http://www.7-zip.org/sdk.html. + +## License +LZMA SDK is placed in the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original LZMA SDK code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. + +## Thanks! +Thanks goes to Igor Pavlov for making this available. diff --git a/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj b/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj new file mode 100644 index 0000000000..bb2c678962 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj @@ -0,0 +1,14 @@ + + + + + + netstandard1.3 + false + + + + + + + diff --git a/src/Microsoft.DotNet.Archive/ProgressReport.cs b/src/Microsoft.DotNet.Archive/ProgressReport.cs new file mode 100644 index 0000000000..6eb9555633 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/ProgressReport.cs @@ -0,0 +1,29 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +namespace Microsoft.DotNet.Archive +{ + public struct ProgressReport + { + public ProgressReport(string phase, long ticks, long total) + { + Phase = phase; + Ticks = ticks; + Total = total; + } + public string Phase { get; } + public long Ticks { get; } + public long Total { get; } + } + + public static class ProgressReportExtensions + { + public static void Report(this IProgress progress, string phase, long ticks, long total) + { + progress.Report(new ProgressReport(phase, ticks, total)); + } + } + +} diff --git a/src/Microsoft.DotNet.Archive/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.Archive/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..110018e7fd --- /dev/null +++ b/src/Microsoft.DotNet.Archive/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; + +[assembly: AssemblyMetadataAttribute("Serviceable", "True")] diff --git a/src/Microsoft.DotNet.Archive/ThreadLocalZipArchive.cs b/src/Microsoft.DotNet.Archive/ThreadLocalZipArchive.cs new file mode 100644 index 0000000000..7f61207cb5 --- /dev/null +++ b/src/Microsoft.DotNet.Archive/ThreadLocalZipArchive.cs @@ -0,0 +1,59 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.IO; +using System.IO.Compression; +using System.Threading; + +namespace Microsoft.DotNet.Archive +{ + /// + /// Wraps ThreadLocal and exposes Dispose semantics that dispose all archives + /// + internal class ThreadLocalZipArchive : IDisposable + { + private ThreadLocal _archive; + private bool _disposed = false; + + public ThreadLocalZipArchive(string archivePath, ZipArchive local = null) + { + _archive = new ThreadLocal(() => + new ZipArchive(File.Open(archivePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete), ZipArchiveMode.Read), + trackAllValues:true); + + if (local != null) + { + // reuse provided one for current thread + _archive.Value = local; + } + } + + public ZipArchive Archive { get { return _archive.Value; } } + + public void Dispose() + { + if (!_disposed) + { + if (_archive != null) + { + // dispose all archives + if (_archive.Values != null) + { + foreach (var value in _archive.Values) + { + if (value != null) + { + value.Dispose(); + } + } + } + + // dispose ThreadLocal + _archive.Dispose(); + _archive = null; + } + } + } + } +} diff --git a/src/dotnet-archive/CommandLine/CommandArgument.cs b/src/dotnet-archive/CommandLine/CommandArgument.cs new file mode 100644 index 0000000000..045609d79f --- /dev/null +++ b/src/dotnet-archive/CommandLine/CommandArgument.cs @@ -0,0 +1,29 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.DotNet.Cli.CommandLine +{ + internal class CommandArgument + { + public CommandArgument() + { + Values = new List(); + } + + public string Name { get; set; } + public string Description { get; set; } + public List Values { get; private set; } + public bool MultipleValues { get; set; } + public string Value + { + get + { + return Values.FirstOrDefault(); + } + } + } +} diff --git a/src/dotnet-archive/CommandLine/CommandLineApplication.cs b/src/dotnet-archive/CommandLine/CommandLineApplication.cs new file mode 100644 index 0000000000..64b6b3d17c --- /dev/null +++ b/src/dotnet-archive/CommandLine/CommandLineApplication.cs @@ -0,0 +1,693 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.DotNet.Cli.CommandLine +{ + internal class CommandLineApplication + { + private enum ParseOptionResult + { + Succeeded, + ShowHelp, + ShowVersion, + UnexpectedArgs, + } + + // Indicates whether the parser should throw an exception when it runs into an unexpected argument. + // If this field is set to false, the parser will stop parsing when it sees an unexpected argument, and all + // remaining arguments, including the first unexpected argument, will be stored in RemainingArguments property. + private readonly bool _throwOnUnexpectedArg; + + public CommandLineApplication(bool throwOnUnexpectedArg = true) + { + _throwOnUnexpectedArg = throwOnUnexpectedArg; + Options = new List(); + Arguments = new List(); + Commands = new List(); + RemainingArguments = new List(); + Invoke = () => 0; + } + + public CommandLineApplication Parent { get; set; } + public string Name { get; set; } + public string FullName { get; set; } + public string Syntax { get; set; } + public string Description { get; set; } + public List Options { get; private set; } + public CommandOption OptionHelp { get; private set; } + public CommandOption OptionVersion { get; private set; } + public List Arguments { get; private set; } + public List RemainingArguments { get; private set; } + public bool IsShowingInformation { get; protected set; } // Is showing help or version? + public Func Invoke { get; set; } + public Func LongVersionGetter { get; set; } + public Func ShortVersionGetter { get; set; } + public List Commands { get; private set; } + public bool HandleResponseFiles { get; set; } + public bool AllowArgumentSeparator { get; set; } + public bool HandleRemainingArguments { get; set; } + public string ArgumentSeparatorHelpText { get; set; } + + public CommandLineApplication AddCommand(string name, bool throwOnUnexpectedArg = true) + { + return AddCommand(name, _ => { }, throwOnUnexpectedArg); + } + + public CommandLineApplication AddCommand(string name, Action configuration, + bool throwOnUnexpectedArg = true) + { + var command = new CommandLineApplication(throwOnUnexpectedArg) { Name = name }; + return AddCommand(command, configuration, throwOnUnexpectedArg); + } + + public CommandLineApplication AddCommand(CommandLineApplication command, bool throwOnUnexpectedArg = true) + { + return AddCommand(command, _ => { }, throwOnUnexpectedArg); + } + + public CommandLineApplication AddCommand( + CommandLineApplication command, + Action configuration, + bool throwOnUnexpectedArg = true) + { + if (command == null || configuration == null) + { + throw new NullReferenceException(); + } + + command.Parent = this; + Commands.Add(command); + configuration(command); + return command; + } + + public CommandOption Option(string template, string description, CommandOptionType optionType) + { + return Option(template, description, optionType, _ => { }); + } + + public CommandOption Option(string template, string description, CommandOptionType optionType, Action configuration) + { + var option = new CommandOption(template, optionType) { Description = description }; + Options.Add(option); + configuration(option); + return option; + } + + public CommandArgument Argument(string name, string description, bool multipleValues = false) + { + return Argument(name, description, _ => { }, multipleValues); + } + + public CommandArgument Argument(string name, string description, Action configuration, bool multipleValues = false) + { + var lastArg = Arguments.LastOrDefault(); + if (lastArg != null && lastArg.MultipleValues) + { + var message = string.Format(LocalizableStrings.LastArgumentMultiValueError, + lastArg.Name); + throw new InvalidOperationException(message); + } + + var argument = new CommandArgument { Name = name, Description = description, MultipleValues = multipleValues }; + Arguments.Add(argument); + configuration(argument); + return argument; + } + + public void OnExecute(Func invoke) + { + Invoke = invoke; + } + + public void OnExecute(Func> invoke) + { + Invoke = () => invoke().Result; + } + + public int Execute(params string[] args) + { + CommandLineApplication command = this; + CommandArgumentEnumerator arguments = null; + + if (HandleResponseFiles) + { + args = ExpandResponseFiles(args).ToArray(); + } + + for (var index = 0; index < args.Length; index++) + { + var arg = args[index]; + + bool isLongOption = arg.StartsWith("--"); + if (arg == "-?" || arg == "/?") + { + command.ShowHelp(); + return 0; + } + else if (isLongOption || arg.StartsWith("-")) + { + CommandOption option; + + var result = ParseOption(isLongOption, command, args, ref index, out option); + + + if (result == ParseOptionResult.ShowHelp) + { + command.ShowHelp(); + return 0; + } + else if (result == ParseOptionResult.ShowVersion) + { + command.ShowVersion(); + return 0; + } + else if (result == ParseOptionResult.UnexpectedArgs) + { + break; + } + } + else + { + var subcommand = ParseSubCommand(arg, command); + if (subcommand != null) + { + command = subcommand; + } + else + { + if (arguments == null || arguments.CommandName != command.Name) + { + arguments = new CommandArgumentEnumerator(command.Arguments.GetEnumerator(), command.Name); + } + + if (arguments.MoveNext()) + { + arguments.Current.Values.Add(arg); + } + else + { + HandleUnexpectedArg(command, args, index, argTypeName: "command or argument"); + break; + } + } + } + } + + if (Commands.Count > 0 && command == this) + { + throw new CommandParsingException( + command, + "Required command missing", + isRequiredSubCommandMissing: true); + } + + return command.Invoke(); + } + + private ParseOptionResult ParseOption( + bool isLongOption, + CommandLineApplication command, + string[] args, + ref int index, + out CommandOption option) + { + option = null; + ParseOptionResult result = ParseOptionResult.Succeeded; + var arg = args[index]; + + int optionPrefixLength = isLongOption ? 2 : 1; + string[] optionComponents = arg.Substring(optionPrefixLength).Split(new[] { ':', '=' }, 2); + string optionName = optionComponents[0]; + + if (isLongOption) + { + option = command.Options.SingleOrDefault( + opt => string.Equals(opt.LongName, optionName, StringComparison.Ordinal)); + } + else + { + option = command.Options.SingleOrDefault( + opt => string.Equals(opt.ShortName, optionName, StringComparison.Ordinal)); + + if (option == null) + { + option = command.Options.SingleOrDefault( + opt => string.Equals(opt.SymbolName, optionName, StringComparison.Ordinal)); + } + } + + if (option == null) + { + if (isLongOption && string.IsNullOrEmpty(optionName) && + !command._throwOnUnexpectedArg && AllowArgumentSeparator) + { + // a stand-alone "--" is the argument separator, so skip it and + // handle the rest of the args as unexpected args + index++; + } + + HandleUnexpectedArg(command, args, index, argTypeName: "option"); + result = ParseOptionResult.UnexpectedArgs; + } + else if (command.OptionHelp == option) + { + result = ParseOptionResult.ShowHelp; + } + else if (command.OptionVersion == option) + { + result = ParseOptionResult.ShowVersion; + } + else + { + if (optionComponents.Length == 2) + { + if (!option.TryParse(optionComponents[1])) + { + command.ShowHint(); + throw new CommandParsingException(command, + String.Format(LocalizableStrings.UnexpectedValueForOptionError, optionComponents[1], optionName)); + } + } + else + { + if (option.OptionType == CommandOptionType.NoValue || + option.OptionType == CommandOptionType.BoolValue) + { + // No value is needed for this option + option.TryParse(null); + } + else + { + index++; + + if (index < args.Length) + { + arg = args[index]; + if (!option.TryParse(arg)) + { + command.ShowHint(); + throw new CommandParsingException( + command, + String.Format(LocalizableStrings.UnexpectedValueForOptionError, arg, optionName)); + } + } + else + { + command.ShowHint(); + throw new CommandParsingException( + command, + String.Format(LocalizableStrings.OptionRequiresSingleValueWhichIsMissing, arg, optionName)); + } + } + } + } + + return result; + } + + private CommandLineApplication ParseSubCommand(string arg, CommandLineApplication command) + { + foreach (var subcommand in command.Commands) + { + if (string.Equals(subcommand.Name, arg, StringComparison.OrdinalIgnoreCase)) + { + return subcommand; + } + } + + return null; + } + + // Helper method that adds a help option + public CommandOption HelpOption(string template) + { + // Help option is special because we stop parsing once we see it + // So we store it separately for further use + OptionHelp = Option(template, LocalizableStrings.ShowHelpInfo, CommandOptionType.NoValue); + + return OptionHelp; + } + + public CommandOption VersionOption(string template, + string shortFormVersion, + string longFormVersion = null) + { + if (longFormVersion == null) + { + return VersionOption(template, () => shortFormVersion); + } + else + { + return VersionOption(template, () => shortFormVersion, () => longFormVersion); + } + } + + // Helper method that adds a version option + public CommandOption VersionOption(string template, + Func shortFormVersionGetter, + Func longFormVersionGetter = null) + { + // Version option is special because we stop parsing once we see it + // So we store it separately for further use + OptionVersion = Option(template, LocalizableStrings.ShowVersionInfo, CommandOptionType.NoValue); + ShortVersionGetter = shortFormVersionGetter; + LongVersionGetter = longFormVersionGetter ?? shortFormVersionGetter; + + return OptionVersion; + } + + // Show short hint that reminds users to use help option + public void ShowHint() + { + if (OptionHelp != null) + { + Console.WriteLine(string.Format(LocalizableStrings.ShowHintInfo, OptionHelp.LongName)); + } + } + + // Show full help + public void ShowHelp(string commandName = null) + { + var headerBuilder = new StringBuilder(LocalizableStrings.UsageHeader); + var usagePrefixLength = headerBuilder.Length; + for (var cmd = this; cmd != null; cmd = cmd.Parent) + { + cmd.IsShowingInformation = true; + if (cmd != this && cmd.Arguments.Any()) + { + var args = string.Join(" ", cmd.Arguments.Select(arg => arg.Name)); + headerBuilder.Insert(usagePrefixLength, string.Format(" {0} {1}", cmd.Name, args)); + } + else + { + headerBuilder.Insert(usagePrefixLength, string.Format(" {0}", cmd.Name)); + } + } + + CommandLineApplication target; + + if (commandName == null || string.Equals(Name, commandName, StringComparison.OrdinalIgnoreCase)) + { + target = this; + } + else + { + target = Commands.SingleOrDefault(cmd => string.Equals(cmd.Name, commandName, StringComparison.OrdinalIgnoreCase)); + + if (target != null) + { + headerBuilder.AppendFormat(" {0}", commandName); + } + else + { + // The command name is invalid so don't try to show help for something that doesn't exist + target = this; + } + + } + + var optionsBuilder = new StringBuilder(); + var commandsBuilder = new StringBuilder(); + var argumentsBuilder = new StringBuilder(); + var argumentSeparatorBuilder = new StringBuilder(); + + int maxArgLen = 0; + for (var cmd = target; cmd != null; cmd = cmd.Parent) + { + if (cmd.Arguments.Any()) + { + if (cmd == target) + { + headerBuilder.Append(LocalizableStrings.UsageArgumentsToken); + } + + if (argumentsBuilder.Length == 0) + { + argumentsBuilder.AppendLine(); + argumentsBuilder.AppendLine(LocalizableStrings.UsageArgumentsHeader); + } + + maxArgLen = Math.Max(maxArgLen, MaxArgumentLength(cmd.Arguments)); + } + } + + for (var cmd = target; cmd != null; cmd = cmd.Parent) + { + if (cmd.Arguments.Any()) + { + foreach (var arg in cmd.Arguments) + { + argumentsBuilder.AppendFormat( + " {0}{1}", + arg.Name.PadRight(maxArgLen + 2), + arg.Description); + argumentsBuilder.AppendLine(); + } + } + } + + if (target.Options.Any()) + { + headerBuilder.Append(LocalizableStrings.UsageOptionsToken); + + optionsBuilder.AppendLine(); + optionsBuilder.AppendLine(LocalizableStrings.UsageOptionsHeader); + var maxOptLen = MaxOptionTemplateLength(target.Options); + var outputFormat = string.Format(" {{0, -{0}}}{{1}}", maxOptLen + 2); + foreach (var opt in target.Options) + { + optionsBuilder.AppendFormat(outputFormat, opt.Template, opt.Description); + optionsBuilder.AppendLine(); + } + } + + if (target.Commands.Any()) + { + headerBuilder.Append(LocalizableStrings.UsageCommandToken); + + commandsBuilder.AppendLine(); + commandsBuilder.AppendLine(LocalizableStrings.UsageCommandsHeader); + var maxCmdLen = MaxCommandLength(target.Commands); + var outputFormat = string.Format(" {{0, -{0}}}{{1}}", maxCmdLen + 2); + foreach (var cmd in target.Commands.OrderBy(c => c.Name)) + { + commandsBuilder.AppendFormat(outputFormat, cmd.Name, cmd.Description); + commandsBuilder.AppendLine(); + } + + if (OptionHelp != null) + { + commandsBuilder.AppendLine(); + commandsBuilder.AppendFormat(LocalizableStrings.UsageCommandsDetailHelp, Name); + commandsBuilder.AppendLine(); + } + } + + if (target.AllowArgumentSeparator || target.HandleRemainingArguments) + { + if (target.AllowArgumentSeparator) + { + headerBuilder.Append(LocalizableStrings.UsageCommandAdditionalArgs); + } + else + { + headerBuilder.Append(LocalizableStrings.UsageCommandArgs); + } + + if (!string.IsNullOrEmpty(target.ArgumentSeparatorHelpText)) + { + argumentSeparatorBuilder.AppendLine(); + argumentSeparatorBuilder.AppendLine(LocalizableStrings.UsageCommandsAdditionalArgsHeader); + argumentSeparatorBuilder.AppendLine(String.Format(" {0}", target.ArgumentSeparatorHelpText)); + argumentSeparatorBuilder.AppendLine(); + } + } + + headerBuilder.AppendLine(); + + var nameAndVersion = new StringBuilder(); + nameAndVersion.AppendLine(GetFullNameAndVersion()); + nameAndVersion.AppendLine(); + + Console.Write("{0}{1}{2}{3}{4}{5}", nameAndVersion, headerBuilder, argumentsBuilder, optionsBuilder, commandsBuilder, argumentSeparatorBuilder); + } + + public void ShowVersion() + { + for (var cmd = this; cmd != null; cmd = cmd.Parent) + { + cmd.IsShowingInformation = true; + } + + Console.WriteLine(FullName); + Console.WriteLine(LongVersionGetter()); + } + + public string GetFullNameAndVersion() + { + return ShortVersionGetter == null ? FullName : string.Format("{0} {1}", FullName, ShortVersionGetter()); + } + + public void ShowRootCommandFullNameAndVersion() + { + var rootCmd = this; + while (rootCmd.Parent != null) + { + rootCmd = rootCmd.Parent; + } + + Console.WriteLine(rootCmd.GetFullNameAndVersion()); + Console.WriteLine(); + } + + private int MaxOptionTemplateLength(IEnumerable options) + { + var maxLen = 0; + foreach (var opt in options) + { + maxLen = opt.Template.Length > maxLen ? opt.Template.Length : maxLen; + } + return maxLen; + } + + private int MaxCommandLength(IEnumerable commands) + { + var maxLen = 0; + foreach (var cmd in commands) + { + maxLen = cmd.Name.Length > maxLen ? cmd.Name.Length : maxLen; + } + return maxLen; + } + + private int MaxArgumentLength(IEnumerable arguments) + { + var maxLen = 0; + foreach (var arg in arguments) + { + maxLen = arg.Name.Length > maxLen ? arg.Name.Length : maxLen; + } + return maxLen; + } + + private void HandleUnexpectedArg(CommandLineApplication command, string[] args, int index, string argTypeName) + { + if (command._throwOnUnexpectedArg) + { + command.ShowHint(); + throw new CommandParsingException(command, String.Format(LocalizableStrings.UnexpectedArgumentError, argTypeName, args[index])); + } + else + { + // All remaining arguments are stored for further use + command.RemainingArguments.AddRange(new ArraySegment(args, index, args.Length - index)); + } + } + + private IEnumerable ExpandResponseFiles(IEnumerable args) + { + foreach (var arg in args) + { + if (!arg.StartsWith("@", StringComparison.Ordinal)) + { + yield return arg; + } + else + { + var fileName = arg.Substring(1); + + var responseFileArguments = ParseResponseFile(fileName); + + // ParseResponseFile can suppress expanding this response file by + // returning null. In that case, we'll treat the response + // file token as a regular argument. + + if (responseFileArguments == null) + { + yield return arg; + } + else + { + foreach (var responseFileArgument in responseFileArguments) + yield return responseFileArgument.Trim(); + } + } + } + } + + private IEnumerable ParseResponseFile(string fileName) + { + if (!HandleResponseFiles) + return null; + + if (!File.Exists(fileName)) + { + throw new InvalidOperationException(String.Format(LocalizableStrings.ResponseFileNotFoundError, fileName)); + } + + return File.ReadLines(fileName); + } + + private class CommandArgumentEnumerator : IEnumerator + { + private readonly IEnumerator _enumerator; + + public CommandArgumentEnumerator( + IEnumerator enumerator, + string commandName) + { + CommandName = commandName; + _enumerator = enumerator; + } + + public string CommandName { get; } + + public CommandArgument Current + { + get + { + return _enumerator.Current; + } + } + + object IEnumerator.Current + { + get + { + return Current; + } + } + + public void Dispose() + { + _enumerator.Dispose(); + } + + public bool MoveNext() + { + if (Current == null || !Current.MultipleValues) + { + return _enumerator.MoveNext(); + } + + // If current argument allows multiple values, we don't move forward and + // all later values will be added to current CommandArgument.Values + return true; + } + + public void Reset() + { + _enumerator.Reset(); + } + } + } +} diff --git a/src/dotnet-archive/CommandLine/CommandOption.cs b/src/dotnet-archive/CommandLine/CommandOption.cs new file mode 100644 index 0000000000..caed0bd779 --- /dev/null +++ b/src/dotnet-archive/CommandLine/CommandOption.cs @@ -0,0 +1,135 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.DotNet.Cli.CommandLine +{ + internal class CommandOption + { + public CommandOption(string template, CommandOptionType optionType) + { + Template = template; + OptionType = optionType; + Values = new List(); + + foreach (var part in Template.Split(new[] { ' ', '|' }, StringSplitOptions.RemoveEmptyEntries)) + { + if (part.StartsWith("--")) + { + LongName = part.Substring(2); + } + else if (part.StartsWith("-")) + { + var optName = part.Substring(1); + + // If there is only one char and it is not an English letter, it is a symbol option (e.g. "-?") + if (optName.Length == 1 && !IsEnglishLetter(optName[0])) + { + SymbolName = optName; + } + else + { + ShortName = optName; + } + } + else if (part.StartsWith("<") && part.EndsWith(">")) + { + ValueName = part.Substring(1, part.Length - 2); + } + else if (optionType == CommandOptionType.MultipleValue && part.StartsWith("<") && part.EndsWith(">...")) + { + ValueName = part.Substring(1, part.Length - 5); + } + else + { + throw new ArgumentException(String.Format(LocalizableStrings.InvalidTemplateError, nameof(template))); + } + } + + if (string.IsNullOrEmpty(LongName) && string.IsNullOrEmpty(ShortName) && string.IsNullOrEmpty(SymbolName)) + { + throw new ArgumentException(LocalizableStrings.InvalidTemplateError, nameof(template)); + } + } + + public string Template { get; set; } + public string ShortName { get; set; } + public string LongName { get; set; } + public string SymbolName { get; set; } + public string ValueName { get; set; } + public string Description { get; set; } + public List Values { get; private set; } + public bool? BoolValue { get; private set; } + public CommandOptionType OptionType { get; private set; } + + public bool TryParse(string value) + { + switch (OptionType) + { + case CommandOptionType.MultipleValue: + Values.Add(value); + break; + case CommandOptionType.SingleValue: + if (Values.Any()) + { + return false; + } + Values.Add(value); + break; + case CommandOptionType.BoolValue: + if (Values.Any()) + { + return false; + } + + if (value == null) + { + // add null to indicate that the option was present, but had no value + Values.Add(null); + BoolValue = true; + } + else + { + bool boolValue; + if (!bool.TryParse(value, out boolValue)) + { + return false; + } + + Values.Add(value); + BoolValue = boolValue; + } + break; + case CommandOptionType.NoValue: + if (value != null) + { + return false; + } + // Add a value to indicate that this option was specified + Values.Add("on"); + break; + default: + break; + } + return true; + } + + public bool HasValue() + { + return Values.Any(); + } + + public string Value() + { + return HasValue() ? Values[0] : null; + } + + private bool IsEnglishLetter(char c) + { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); + } + } +} diff --git a/src/dotnet-archive/CommandLine/CommandOptionType.cs b/src/dotnet-archive/CommandLine/CommandOptionType.cs new file mode 100644 index 0000000000..6cee7406b7 --- /dev/null +++ b/src/dotnet-archive/CommandLine/CommandOptionType.cs @@ -0,0 +1,14 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + + +namespace Microsoft.DotNet.Cli.CommandLine +{ + internal enum CommandOptionType + { + MultipleValue, + SingleValue, + BoolValue, + NoValue + } +} diff --git a/src/dotnet-archive/CommandLine/CommandParsingException.cs b/src/dotnet-archive/CommandLine/CommandParsingException.cs new file mode 100644 index 0000000000..82c675f4bb --- /dev/null +++ b/src/dotnet-archive/CommandLine/CommandParsingException.cs @@ -0,0 +1,45 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using Microsoft.DotNet.Tools; + +namespace Microsoft.DotNet.Cli.CommandLine +{ + internal class CommandParsingException : Exception + { + private readonly bool _isRequiredSubCommandMissing; + + public CommandParsingException( + string message, + string helpText = null) : base(message) + { + HelpText = helpText ?? ""; + Data.Add("CLI_User_Displayed_Exception", true); + } + + public CommandParsingException( + CommandLineApplication command, + string message, + bool isRequiredSubCommandMissing = false) + : this(message) + { + Command = command; + _isRequiredSubCommandMissing = isRequiredSubCommandMissing; + } + + public CommandLineApplication Command { get; } + + public string HelpText { get; } = ""; + + public override string Message + { + get + { + return _isRequiredSubCommandMissing + ? CommonLocalizableStrings.RequiredCommandNotPassed + : base.Message; + } + } + } +} \ No newline at end of file diff --git a/src/dotnet-archive/CommandLine/HelpMessageStrings.cs b/src/dotnet-archive/CommandLine/HelpMessageStrings.cs new file mode 100644 index 0000000000..09551d2e66 --- /dev/null +++ b/src/dotnet-archive/CommandLine/HelpMessageStrings.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.DotNet.Cli.CommandLine +{ + internal class HelpMessageStrings + { + internal const string MSBuildAdditionalArgsHelpText = LocalizableStrings.MSBuildAdditionalArgsHelpText; + } +} diff --git a/src/dotnet-archive/CommandLine/LocalizableStrings.cs b/src/dotnet-archive/CommandLine/LocalizableStrings.cs new file mode 100644 index 0000000000..ff01edf1be --- /dev/null +++ b/src/dotnet-archive/CommandLine/LocalizableStrings.cs @@ -0,0 +1,50 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.DotNet.Cli.CommandLine +{ + internal class LocalizableStrings + { + public const string LastArgumentMultiValueError = "The last argument '{0}' accepts multiple values. No more argument can be added."; + + public const string OptionRequiresSingleValueWhichIsMissing = "Required value for option '{0}' was not provided."; + + public const string UnexpectedValueForOptionError = "Unexpected value '{0}' for option '{1}'"; + + public const string UnexpectedArgumentError = "Unrecognized {0} '{1}'"; + + public const string ResponseFileNotFoundError = "Response file '{0}' doesn't exist."; + + public const string ShowHelpInfo = "Show help information"; + + public const string ShowVersionInfo = "Show version information"; + + public const string ShowHintInfo = "Specify --{0} for a list of available options and commands."; + + public const string UsageHeader = "Usage:"; + + public const string UsageArgumentsToken = " [arguments]"; + + public const string UsageArgumentsHeader = "Arguments:"; + + public const string UsageOptionsToken = " [options]"; + + public const string UsageOptionsHeader = "Options:"; + + public const string UsageCommandToken = " [command]"; + + public const string UsageCommandsHeader = "Commands:"; + + public const string UsageCommandsDetailHelp = "Use \"{0} [command] --help\" for more information about a command."; + + public const string UsageCommandArgs = " [args]"; + + public const string UsageCommandAdditionalArgs = " [[--] ...]]"; + + public const string UsageCommandsAdditionalArgsHeader = "Additional Arguments:"; + + public const string InvalidTemplateError = "Invalid template pattern '{0}'"; + + public const string MSBuildAdditionalArgsHelpText = "Any extra options that should be passed to MSBuild. See 'dotnet msbuild -h' for available options."; + } +} diff --git a/src/dotnet-archive/CommonLocalizableStrings.cs b/src/dotnet-archive/CommonLocalizableStrings.cs new file mode 100644 index 0000000000..d19b462d55 --- /dev/null +++ b/src/dotnet-archive/CommonLocalizableStrings.cs @@ -0,0 +1,189 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.DotNet.Tools +{ + internal class CommonLocalizableStrings + { + public const string UnsupportedProjectType = "Unsupported project type. Please check with your sdk provider."; + public const string ProjectAlreadyHasAreference = "Project already has a reference to `{0}`."; + public const string ProjectReferenceCouldNotBeFound = "Project reference `{0}` could not be found."; + public const string ProjectReferenceRemoved = "Project reference `{0}` removed."; + + // Project related + public const string Project = "Project"; + public const string ProjectFile = "Project file"; + public const string Reference = "Reference"; + public const string ProjectReference = "Project reference"; + public const string ProjectReferenceOneOrMore = "Project reference(s)"; + public const string PackageReference = "Package reference"; + public const string P2P = "Project to Project"; + public const string P2PReference = "Project to Project reference"; + public const string Package = "Package"; + public const string Solution = "Solution"; + public const string SolutionFile = "Solution file"; + public const string Executable = "Executable"; + public const string Library = "Library"; + public const string Program = "Program"; + public const string Application = "Application"; + public const string ReferenceAddedToTheProject = "Reference `{0}` added to the project."; + + // Verbs + public const string Add = "Add"; + public const string Remove = "Remove"; + public const string Delete = "Delete"; + public const string Update = "Update"; + public const string New = "New"; + public const string List = "List"; + public const string Load = "Load"; + public const string Save = "Save"; + public const string Find = "Find"; + + // Other + public const string Error = "Error"; + public const string Warning = "Warning"; + + public const string File = "File"; + public const string Directory = "Directory"; + + public const string Type = "Type"; + public const string Value = "Value"; + public const string Group = "Group"; + + // General sentences"; + public const string XAddedToY = "{0} added to {1}."; + public const string XRemovedFromY = "{0} removed from {1}."; + public const string XDeletedFromY = "{0} deleted from {1}."; + public const string XSuccessfullyUpdated = "{0} successfully updated."; + + // General errors + /// Invalid + public const string XIsInvalid = "{0} is invalid."; + public const string XYFoundButInvalid = "{0} `{1}` found but is invalid."; + public const string XFoundButInvalid = "`{0}` found but is invalid."; + public const string OperationInvalid = "Operation is invalid."; + public const string OperationXInvalid = "Operation {0} is invalid."; + + /// Not Found + public const string XNotFound = "{0} not found."; + public const string XOrYNotFound = "{0} or {1} not found."; + public const string XOrYNotFoundInZ = "{0} or {1} not found in `{2}`."; + public const string FileNotFound = "File `{0}` not found."; + + /// Does not exist + public const string XDoesNotExist = "{0} does not exist."; + public const string XYDoesNotExist = "{0} `{1}` does not exist."; + + /// Duplicate + public const string MoreThanOneXFound = "More than one {0} found."; + public const string XAlreadyContainsY = "{0} already contains {1}."; + public const string XAlreadyContainsYZ = "{0} already contains {1} `{2}`."; + public const string XAlreadyHasY = "{0} already has {1}."; + public const string XAlreadyHasYZ = "{0} already has {1} `{2}`."; + + /// Other + public const string XWasNotExpected = "{0} was not expected."; + public const string XNotProvided = "{0} not provided."; + public const string SpecifyAtLeastOne = "Please specify at least one {0}."; + public const string CouldNotConnectWithTheServer = "Could not connect with the server."; + + // Command Line Parsing + public const string RequiredArgumentIsInvalid = "Required argument {0} is invalid."; + public const string OptionIsInvalid = "Option {0} is invalid."; + public const string ArgumentIsInvalid = "Argument {0} is invalid."; + public const string RequiredArgumentNotPassed = "Required argument {0} was not provided."; + public const string RequiredCommandNotPassed = "Required command was not provided."; + + // dotnet + /// Project + public const string CouldNotFindAnyProjectInDirectory = "Could not find any project in `{0}`."; + public const string CouldNotFindProjectOrDirectory = "Could not find project or directory `{0}`."; + public const string MoreThanOneProjectInDirectory = "Found more than one project in `{0}`. Please specify which one to use."; + public const string FoundInvalidProject = "Found a project `{0}` but it is invalid."; + public const string InvalidProject = "Invalid project `{0}`."; + + /// Solution + public const string CouldNotFindSolutionIn = "Specified solution file {0} does not exist, or there is no solution file in the directory."; + public const string CouldNotFindSolutionOrDirectory = "Could not find solution or directory `{0}`."; + public const string MoreThanOneSolutionInDirectory = "Found more than one solution file in {0}. Please specify which one to use."; + public const string InvalidSolutionFormatString = "Invalid solution `{0}`. {1}"; // {0} is the solution path, {1} is already localized details on the failure + public const string SolutionDoesNotExist = "Specified solution file {0} does not exist, or there is no solution file in the directory."; + + /// add p2p + public const string ReferenceDoesNotExist = "Reference {0} does not exist."; + public const string ReferenceIsInvalid = "Reference `{0}` is invalid."; + public const string SpecifyAtLeastOneReferenceToAdd = "You must specify at least one reference to add."; + public const string ProjectAlreadyHasAReference = "Project {0} already has a reference `{1}`."; + + /// add package + public const string PackageReferenceDoesNotExist = "Package reference `{0}` does not exist."; + public const string PackageReferenceIsInvalid = "Package reference `{0}` is invalid."; + public const string SpecifyAtLeastOnePackageReferenceToAdd = "You must specify at least one package to add."; + public const string PackageReferenceAddedToTheProject = "Package reference `{0}` added to the project."; + public const string ProjectAlreadyHasAPackageReference = "Project {0} already has a reference `{1}`."; + public const string PleaseSpecifyVersion = "Please specify a version of the package."; + + /// add sln + public const string ProjectDoesNotExist = "Project `{0}` does not exist."; + public const string ProjectIsInvalid = "Project `{0}` is invalid."; + public const string SpecifyAtLeastOneProjectToAdd = "You must specify at least one project to add."; + public const string ProjectAddedToTheSolution = "Project `{0}` added to the solution."; + public const string SolutionAlreadyContainsProject = "Solution {0} already contains project {1}."; + + /// del p2p + public const string ReferenceNotFoundInTheProject = "Specified reference {0} does not exist in project {1}."; + public const string ReferenceRemoved = "Reference `{0}` deleted from the project."; + public const string SpecifyAtLeastOneReferenceToRemove = "You must specify at least one reference to remove."; + public const string ReferenceDeleted = "Reference `{0}` deleted."; + + /// del pkg + public const string PackageReferenceNotFoundInTheProject = "Package reference `{0}` could not be found in the project."; + public const string PackageReferenceRemoved = "Reference `{0}` deleted from the project."; + public const string SpecifyAtLeastOnePackageReferenceToRemove = "You must specify at least one package reference to remove."; + public const string PackageReferenceDeleted = "Package reference `{0}` deleted."; + + /// del sln + public const string ProjectNotFoundInTheSolution = "Project `{0}` could not be found in the solution."; + public const string ProjectRemoved = "Project `{0}` removed from solution."; + public const string SpecifyAtLeastOneProjectToRemove = "You must specify at least one project to remove."; + public const string ProjectDeleted = "Project `{0}` deleted from solution."; + + /// list + public const string NoReferencesFound = "There are no {0} references in project {1}. ;; {0} is the type of the item being requested (project, package, p2p) and {1} is the object operated on (a project file or a solution file). "; + public const string NoProjectsFound = "No projects found in the solution."; + + /// arguments + public const string ArgumentsProjectOrSolutionDescription = "The project or solution to operation on. If a file is not specified, the current directory is searched."; + + /// sln + public const string ArgumentsProjectDescription = "The project file to operate on. If a file is not specified, the command will search the current directory for one."; + public const string ArgumentsSolutionDescription = "Solution file to operate on. If not specified, the command will search the current directory for one."; + public const string CmdSlnFile = "SLN_FILE"; + public const string CmdProjectFile = "PROJECT"; + + /// commands + public const string CmdFramework = "FRAMEWORK"; + + /// update pkg + public const string PleaseSpecifyNewVersion = "Please specify new version of the package."; + public const string PleaseSpecifyWhichPackageToUpdate = "Please specify which package to update."; + public const string NothingToUpdate = "Nothing to update."; + public const string EverythingUpToDate = "Everything is already up-to-date."; + public const string PackageVersionUpdatedTo = "Version of package `{0}` updated to `{1}`."; + public const string PackageVersionUpdated = "Version of package `{0}` updated."; + public const string CouldNotUpdateTheVersion = "Could not update the version of the package `{0}`."; + + /// new + public const string TemplateCreatedSuccessfully = "The template {0} created successfully. Please run \"dotnet restore\" to get started!"; + public const string TemplateInstalledSuccesfully = "The template {0} installed successfully. You can use \"dotnet new {0}\" to get started with the new template."; + public const string TemplateCreateError = "Template {0} could not be created. Error returned was: {1}."; + public const string TemplateInstallError = "Template {0} could not be installed. Error returned was: {1}."; + public const string SpecifiedNameExists = "Specified name {0} already exists. Please specify a different name."; + public const string SpecifiedAliasExists = "Specified alias {0} already exists. Please specify a different alias."; + public const string MandatoryParameterMissing = "Mandatory parameter {0} missing for template {1}. "; + + public const string ProjectNotCompatibleWithFrameworks = "Project `{0}` cannot be added due to incompatible targeted frameworks between the two projects. Please review the project you are trying to add and verify that is compatible with the following targets:"; + public const string ProjectDoesNotTargetFramework = "Project `{0}` does not target framework `{1}`."; + public const string ProjectCouldNotBeEvaluated = "Project `{0}` could not be evaluated. Evaluation failed with following error:\n{1}"; + } +} diff --git a/src/dotnet-archive/Program.cs b/src/dotnet-archive/Program.cs new file mode 100644 index 0000000000..3376bf47ef --- /dev/null +++ b/src/dotnet-archive/Program.cs @@ -0,0 +1,96 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.DotNet.Cli.CommandLine; +//using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.Archive; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; + +namespace Microsoft.DotNet.Tools.Archive +{ + + public partial class ArchiveCommand + { + public static int Main(string[] args) + { + //DebugHelper.HandleDebugSwitch(ref args); + + var app = new CommandLineApplication(); + app.Name = "archive"; + app.FullName = ".NET archiver"; + app.Description = "Archives and expands sets of files"; + app.HelpOption("-h|--help"); + + var extract = app.Option("-x|--extract ", "Directory to extract to", CommandOptionType.SingleValue); + var archiveFile = app.Option("-a|--archive ", "Archive to operate on", CommandOptionType.SingleValue); + var externals = app.Option("--external ...", "External files and directories to consider for extraction", CommandOptionType.MultipleValue); + var sources = app.Argument("...", "Files & directory to include in the archive", multipleValues:true); + + app.OnExecute(() => { + + if (extract.HasValue() && sources.Values.Any()) + { + Console.WriteLine("Extract '-x' can only be specified when no '' are specified to add to the archive."); + return 1; + } + else if (!extract.HasValue() && !sources.Values.Any()) + { + Console.WriteLine("Either extract '-x' or '' must be specified."); + return 1; + } + + if (!archiveFile.HasValue()) + { + Console.WriteLine("Archive '-a' must be specified."); + return 1; + } + + var progress = new ConsoleProgressReport(); + + var archive = new IndexedArchive(); + foreach (var external in externals.Values) + { + if (Directory.Exists(external)) + { + archive.AddExternalDirectory(external); + } + else + { + archive.AddExternalFile(external); + } + } + + if (sources.Values.Any()) + { + foreach(var source in sources.Values) + { + if (Directory.Exists(source)) + { + archive.AddDirectory(source, progress); + } + else + { + archive.AddFile(source, Path.GetFileName(source)); + } + } + + archive.Save(archiveFile.Value(), progress); + } + else // sources not specified, extract must have been specified + { + archive.Extract(archiveFile.Value(), extract.Value(), progress); + + } + + return 0; + }); + + return app.Execute(args); + } + } +} diff --git a/src/dotnet-archive/dotnet-archive.csproj b/src/dotnet-archive/dotnet-archive.csproj new file mode 100644 index 0000000000..67a2ef1a9b --- /dev/null +++ b/src/dotnet-archive/dotnet-archive.csproj @@ -0,0 +1,15 @@ + + + + + + netcoreapp2.0 + Exe + false + + + + + + + From 8a413396809b1a36e97a9c612f27dc6c02bdab7c Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 27 Apr 2017 10:26:57 -0700 Subject: [PATCH 086/361] Long path woes --- build/Build.RuntimeStore.nuspec | 2 +- build/repo.targets | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/Build.RuntimeStore.nuspec b/build/Build.RuntimeStore.nuspec index 089762039d..eb398b1b69 100644 --- a/build/Build.RuntimeStore.nuspec +++ b/build/Build.RuntimeStore.nuspec @@ -1,7 +1,7 @@ - Build.RuntimeStore + Build.RS $version$ Microsoft Runtime Package Store for ASP.NET Core, for internal builds diff --git a/build/repo.targets b/build/repo.targets index 09a0f36d7d..1a7f5513ce 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -53,7 +53,7 @@ linux osx - $(ArtifactsDir)Build.RuntimeStore.$(OutputZipSufix)-$(VersionSuffix).zip + $(ArtifactsDir)Build.RS.$(OutputZipSufix)-$(VersionSuffix).zip @@ -96,7 +96,7 @@ - + From 4039af267d61323d65b943639e41f3be119146c5 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 09:47:38 -0700 Subject: [PATCH 087/361] fix drop share reference --- build/repo.targets | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 1a7f5513ce..0450a4682b 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -136,21 +136,20 @@ + - $(COHERENCE_SIGNED_DROP_ROOT) - \\aspnetci\Drops\Coherence-Signed\dev - $(TIMESTAMP_FREE_VERSION) final $(VersionPrefix)-$(VersionSuffix)-$(NoTimestampSuffix) $(VersionPrefix)-$(VersionSuffix)-$(BuildNumber) - $(CoherenceSignedRoot)\$(BuildNumber)\Signed\Packages-NoTimeStamp - $(CoherenceSignedRoot)\$(BuildNumber)\Signed\Packages + $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages-NoTimeStamp + $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages @@ -164,11 +163,10 @@ $(PublishShare)\fallbackArchives - - From aeba0c9026acc186a5f7212d76c1a01ef51d3d0e Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 11:27:20 -0700 Subject: [PATCH 088/361] derped the publish source --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 0450a4682b..9040518748 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -162,7 +162,7 @@ $(PublishShare)\fallbackArchives - + From c56d76693e5bfb357076ba47ecc8e196f5965b7c Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 27 Apr 2017 11:31:19 -0700 Subject: [PATCH 089/361] Rename file --- build/{Build.RuntimeStore.nuspec => Build.RS.nuspec} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename build/{Build.RuntimeStore.nuspec => Build.RS.nuspec} (100%) diff --git a/build/Build.RuntimeStore.nuspec b/build/Build.RS.nuspec similarity index 100% rename from build/Build.RuntimeStore.nuspec rename to build/Build.RS.nuspec From 795b4d36e73a9995c17edba35021aaa1eeee6aa8 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 26 Apr 2017 11:48:58 -0700 Subject: [PATCH 090/361] AddUserSecrets is optional --- src/Microsoft.AspNetCore/WebHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 594eb6a0c5..aea490fb7f 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName)); if (appAssembly != null) { - config.AddUserSecrets(appAssembly); + config.AddUserSecrets(appAssembly, optional: true); } } From 6c6950b40cc8268b37ff92644fe89fa951691e19 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 12:51:19 -0700 Subject: [PATCH 091/361] ensure we overwrite the ZIP when we rearchive it --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 9040518748..b6724f2a55 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -183,6 +183,6 @@ - + From 6e1baad8b7c8b4ee1f28d94b2c1c1bc7274165f1 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 13:37:44 -0700 Subject: [PATCH 092/361] remove build number from lzma archive (#77) --- build/repo.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index b6724f2a55..df6944c41a 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -155,14 +155,14 @@ - - + + $(PublishShare)\fallbackArchives - + From 0d3730749d86427fce342843f8936813d1b8e709 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 27 Apr 2017 13:57:32 -0700 Subject: [PATCH 093/361] Remove build number from runtime store zip name --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index df6944c41a..50d976be53 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -53,7 +53,7 @@ linux osx - $(ArtifactsDir)Build.RS.$(OutputZipSufix)-$(VersionSuffix).zip + $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip From dd7e8303718c36fcb4ae6bd22b0e8d6f5b50d53e Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 14:38:55 -0700 Subject: [PATCH 094/361] don't build the whole repo when making the fallback archive --- build/repo.targets | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 50d976be53..ac13314b1c 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -9,7 +9,7 @@ $(RepositoryRoot)src\Archive.AspNetCore.All\ $(FallbackArchiveDir)Archive.AspNetCore.All.csproj - $(RepositoryRoot)src\dotnet-archive\dotnet-archive.csproj + $(RepositoryRoot)src\dotnet-archive\dotnet-archive.csproj $(RepositoryRoot)src\dotnet-archive\bin\$(Configuration)\netcoreapp2.0\dotnet-archive.dll $(MetaPackagePath)bin\work\ @@ -28,10 +28,6 @@ $(CompileDependsOn); BuildPackageCache - - $(CompileDependsOn); - BuildFallbackArchive - @@ -152,6 +148,10 @@ $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages + + + + From 8ca486b2ad186f2792c188b52552a5488659cf0d Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 14:38:55 -0700 Subject: [PATCH 095/361] don't build the whole repo when making the fallback archive --- build/repo.targets | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 50d976be53..ac13314b1c 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -9,7 +9,7 @@ $(RepositoryRoot)src\Archive.AspNetCore.All\ $(FallbackArchiveDir)Archive.AspNetCore.All.csproj - $(RepositoryRoot)src\dotnet-archive\dotnet-archive.csproj + $(RepositoryRoot)src\dotnet-archive\dotnet-archive.csproj $(RepositoryRoot)src\dotnet-archive\bin\$(Configuration)\netcoreapp2.0\dotnet-archive.dll $(MetaPackagePath)bin\work\ @@ -28,10 +28,6 @@ $(CompileDependsOn); BuildPackageCache - - $(CompileDependsOn); - BuildFallbackArchive - @@ -152,6 +148,10 @@ $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages + + + + From db314595510f181bbc5ee16b5efed3e6516d5e3d Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 15:06:13 -0700 Subject: [PATCH 096/361] fix timestamps --- build/common.props | 9 +++------ build/repo.targets | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/build/common.props b/build/common.props index fcf40a899f..464cf34bdb 100644 --- a/build/common.props +++ b/build/common.props @@ -11,14 +11,11 @@ true true $(VersionSuffix) - - - $(VersionSuffix) - $(VersionSuffix)-$(BuildNumber) + $(VersionSuffix)-$(BuildNumber) - 2.0.0-$(BuildVersionSuffix) - 1.0.0-$(BuildVersionSuffix) + 2.0.0-$(VersionSuffix) + 1.0.0-$(VersionSuffix) diff --git a/build/repo.targets b/build/repo.targets index ac13314b1c..9888724625 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -141,8 +141,8 @@ $(TIMESTAMP_FREE_VERSION) final - $(VersionPrefix)-$(VersionSuffix)-$(NoTimestampSuffix) - $(VersionPrefix)-$(VersionSuffix)-$(BuildNumber) + $(VersionPrefix)-$(OriginalVersionSuffix)-$(NoTimestampSuffix) + $(VersionPrefix)-$(OriginalVersionSuffix)-$(BuildNumber) $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages-NoTimeStamp $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages From e225d23771ba5a06d062df4f74efee34a365b2f4 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 15:19:44 -0700 Subject: [PATCH 097/361] hack to unblock the build, also a good fix --- build/common.props | 2 +- src/dotnet-archive/dotnet-archive.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/common.props b/build/common.props index 464cf34bdb..30512a04d6 100644 --- a/build/common.props +++ b/build/common.props @@ -11,7 +11,7 @@ true true $(VersionSuffix) - $(VersionSuffix)-$(BuildNumber) + $(VersionSuffix)-$(BuildNumber) 2.0.0-$(VersionSuffix) diff --git a/src/dotnet-archive/dotnet-archive.csproj b/src/dotnet-archive/dotnet-archive.csproj index 67a2ef1a9b..1cecf05c95 100644 --- a/src/dotnet-archive/dotnet-archive.csproj +++ b/src/dotnet-archive/dotnet-archive.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + netcoreapp1.1 Exe false From ac508e9ef3771672b792d62da9358112043b30aa Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 15:30:21 -0700 Subject: [PATCH 098/361] just package the archive separately --- build/repo.targets | 17 +++++------------ src/dotnet-archive/dotnet-archive.csproj | 3 ++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 9888724625..1747f9d4de 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -9,8 +9,6 @@ $(RepositoryRoot)src\Archive.AspNetCore.All\ $(FallbackArchiveDir)Archive.AspNetCore.All.csproj - $(RepositoryRoot)src\dotnet-archive\dotnet-archive.csproj - $(RepositoryRoot)src\dotnet-archive\bin\$(Configuration)\netcoreapp2.0\dotnet-archive.dll $(MetaPackagePath)bin\work\ $(MetaPackagePath)bin\packageCache\ @@ -100,6 +98,8 @@ + + @@ -121,13 +121,10 @@ SourceName="Dependencies" SourceUri="$(PackageSource)" /> - - - - + @@ -148,15 +145,11 @@ $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages - - - - - - + + diff --git a/src/dotnet-archive/dotnet-archive.csproj b/src/dotnet-archive/dotnet-archive.csproj index 1cecf05c95..5ea7e8fb45 100644 --- a/src/dotnet-archive/dotnet-archive.csproj +++ b/src/dotnet-archive/dotnet-archive.csproj @@ -3,9 +3,10 @@ - netcoreapp1.1 + netcoreapp2.0 Exe false + win7-x64 From 09bf1affbd2417cb8e06ac6b7ba7abee9fe9e434 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 15:34:39 -0700 Subject: [PATCH 099/361] derped again --- build/repo.targets | 1 - 1 file changed, 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 1747f9d4de..c19ee3a5bb 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -122,7 +122,6 @@ SourceUri="$(PackageSource)" /> - From 77d9b16ad22df36be822b6ebd851871c4b560801 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 15:38:05 -0700 Subject: [PATCH 100/361] restore restoring of the archive project --- build/repo.targets | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index c19ee3a5bb..d7ec150d6b 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -121,9 +121,12 @@ SourceName="Dependencies" SourceUri="$(PackageSource)" /> + + + - + From 8e597c5f80a8799fc0a0be197372a0f97cf4869a Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 15:56:49 -0700 Subject: [PATCH 101/361] derped the file name --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index d7ec150d6b..f7c618d778 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -157,7 +157,7 @@ $(PublishShare)\fallbackArchives - + From 70716bdff56cf2481cc50666d2a5c4183260b60a Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 27 Apr 2017 16:05:52 -0700 Subject: [PATCH 102/361] use actual set of packages (#78) --- NuGet.config | 1 + src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/NuGet.config b/NuGet.config index fa4304af9c..8d4d39ddcc 100644 --- a/NuGet.config +++ b/NuGet.config @@ -3,6 +3,7 @@ + diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj index 5d1de6a2bb..81a3815a0e 100644 --- a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj +++ b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj @@ -4,28 +4,22 @@ netcoreapp2.0 $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; false + netcoreapp2.0 - - - - - From 8102d6a038863ad2fc34d8c14bfb9aa535d26446 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Tue, 25 Apr 2017 15:07:10 -0700 Subject: [PATCH 103/361] Add configuration to logging in WebHost --- src/Microsoft.AspNetCore/WebHost.cs | 3 +- .../WebHostFunctionalTests.cs | 41 +++++++++++++++++++ .../CreateDefaultBuilderApp/Program.cs | 28 +------------ 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index aea490fb7f..51b5a6e160 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -175,8 +175,9 @@ namespace Microsoft.AspNetCore config.AddCommandLine(args); } }) - .ConfigureLogging(logging => + .ConfigureLogging((hostingContext, logging) => { + logging.UseConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); logging.AddDebug(); }) diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index 99485cab7d..43be04f16e 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -200,6 +200,47 @@ namespace Microsoft.AspNetCore.Tests } } + [Fact] + public void LoggingConfigurationSectionPassedToLoggerByDefault() + { + try + { + File.WriteAllText("appsettings.json", @" +{ + ""Logging"": { + ""LogLevel"": { + ""Default"": ""Warning"" + } + } +} +"); + using (var webHost = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) + { + var factory = (ILoggerFactory)webHost.Services.GetService(typeof(ILoggerFactory)); + var logger = factory.CreateLogger("Test"); + + logger.Log(LogLevel.Information, 0, "Message", null, (s, e) => + { + Assert.True(false); + return string.Empty; + }); + + var logWritten = false; + logger.Log(LogLevel.Warning, 0, "Message", null, (s, e) => + { + logWritten = true; + return string.Empty; + }); + + Assert.True(logWritten); + } + } + finally + { + File.Delete("appsettings.json"); + } + } + private async Task ExecuteStartOrStartWithTest(Func> getResponse, string applicationName) { await ExecuteTestApp(applicationName, async (deploymentResult, logger) => diff --git a/test/TestSites/CreateDefaultBuilderApp/Program.cs b/test/TestSites/CreateDefaultBuilderApp/Program.cs index f14aec8f93..eb7eeaaa03 100644 --- a/test/TestSites/CreateDefaultBuilderApp/Program.cs +++ b/test/TestSites/CreateDefaultBuilderApp/Program.cs @@ -24,7 +24,6 @@ namespace CreateDefaultBuilderApp string responseMessage = string.Empty; WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) - .UseLoggerFactory(new TestLoggerFactory()) .ConfigureServices((context, services) => { responseMessage = GetResponseMessage(context, services); @@ -77,34 +76,11 @@ namespace CreateDefaultBuilderApp return $"Command line arguments not loaded into Configuration."; } - var testLoggerFactory = (TestLoggerFactory)context.LoggerFactory; - - // Verify AddConsole called - if (!testLoggerFactory.Providers.Any(provider => provider is ConsoleLoggerProvider)) - { - return $"Console logger not added to ILoggerFactory."; - } - - // Verify AddDebug called - if (!testLoggerFactory.Providers.Any(provider => provider is DebugLoggerProvider)) - { - return $"Debug logger not added to ILoggerFactory."; - } - + // TODO: Verify AddConsole called + // TODO: Verify AddDebug called // TODO: Verify UseIISIntegration called return context.HostingEnvironment.ApplicationName; } - - private class TestLoggerFactory : ILoggerFactory - { - public IList Providers { get; } = new List(); - - public void AddProvider(ILoggerProvider provider) => Providers.Add(provider); - - public ILogger CreateLogger(string categoryName) => NullLogger.Instance; - - public void Dispose() { } - } } } \ No newline at end of file From 485cf19ab6364fd415a6cb2a903b64da335ab68d Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 27 Apr 2017 18:14:14 -0700 Subject: [PATCH 104/361] Hack a no timestamp version of the runtime store and deps file --- build/repo.targets | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index f7c618d778..b67441362e 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -15,6 +15,8 @@ $(MetaPackagePath)bin\deps\ $(RepositoryRoot)artifacts\ $(ArtifactsDir)zip\ + $(ArtifactsZipDir)ts\ + $(ArtifactsZipDir)nt\ $(ArtifactsDir)temp\ $(RepositoryRoot)tools\ $(RepositoryRoot).deps\build\ @@ -47,7 +49,8 @@ linux osx - $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip + $(ArtifactsDir)Build.RS.$(OutputZipSufix)-$(VersionSuffix).zip + $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip @@ -74,26 +77,44 @@ manifest.%(RIDs.Identity).xml - + <_PackageCacheFiles Include="$(PackageCacheOutputPath)**\*" Exclude="$(PackageCacheOutputPath)**\artifact.xml" /> + + $([System.String]::new('%(RecursiveDir)').Replace('-$(BuildNumber)', '-final')) + - - + + + + - + - + + + + + + + + + + + + + + From 97bf16f852993091da2f59ae6000ffe5f20b3d09 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 27 Apr 2017 18:14:14 -0700 Subject: [PATCH 105/361] Hack a no timestamp version of the runtime store and deps file --- build/repo.targets | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index f7c618d778..d8293547eb 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -15,6 +15,8 @@ $(MetaPackagePath)bin\deps\ $(RepositoryRoot)artifacts\ $(ArtifactsDir)zip\ + $(ArtifactsZipDir)ts\ + $(ArtifactsZipDir)nt\ $(ArtifactsDir)temp\ $(RepositoryRoot)tools\ $(RepositoryRoot).deps\build\ @@ -47,7 +49,8 @@ linux osx - $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip + $(ArtifactsDir)Build.RS.$(OutputZipSufix)-$(VersionSuffix).zip + $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip @@ -74,26 +77,45 @@ manifest.%(RIDs.Identity).xml - + <_PackageCacheFiles Include="$(PackageCacheOutputPath)**\*" Exclude="$(PackageCacheOutputPath)**\artifact.xml" /> + + $([System.String]::new('%(RecursiveDir)').Replace('-$(BuildNumber)', '-final')) + - - + + + + - + - + + + + + + + + + + + + + + + From 0a04ef78b2371d90ccf72c37f33a1de3f6191b95 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 27 Apr 2017 19:18:33 -0700 Subject: [PATCH 106/361] Build one zip per configuration --- build/repo.targets | 42 ++++++------------- ...ublishWithAspNetCoreTargetManifest.targets | 2 +- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index d8293547eb..63f7794ca8 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -24,13 +24,9 @@ $(PrepareDependsOn); UpdateNuGetConfig - - $(CompileDependsOn); - BuildPackageCache - - + - win + win$(PACKAGE_CACHE_PLATFORM) linux osx + win-$(PACKAGE_CACHE_PLATFORM) + linux-$(PACKAGE_CACHE_PLATFORM) + osx-$(PACKAGE_CACHE_PLATFORM) $(ArtifactsDir)Build.RS.$(OutputZipSufix)-$(VersionSuffix).zip $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip - - - x64 - - - x86 - - - x64 - - - x64 - - - - - + + - - manifest.%(RIDs.Identity).xml + + manifest.$(RID).xml <_PackageCacheFiles Include="$(PackageCacheOutputPath)**\*" Exclude="$(PackageCacheOutputPath)**\artifact.xml" /> @@ -102,12 +86,12 @@ - - + + - - + + diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets index 530ff2649c..3922807fbf 100644 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -4,7 +4,7 @@ - $(TargetManifestFiles);$(MSBuildThisFileDirectory)manifest.win7-x64.xml;$(MSBuildThisFileDirectory)manifest.win7-x86.xml;$(MSBuildThisFileDirectory)manifest.osx.10.12-x64.xml;$(MSBuildThisFileDirectory)manifest.linux-x64.xml + $(TargetManifestFiles);$(MSBuildThisFileDirectory)manifest.win-x64.xml;$(MSBuildThisFileDirectory)manifest.win-x86.xml;$(MSBuildThisFileDirectory)manifest.osx-x64.xml;$(MSBuildThisFileDirectory)manifest.linux-x64.xml From 18acd972df486d094d60272412fb3399e8f70de4 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 26 Apr 2017 20:03:48 -0700 Subject: [PATCH 108/361] Add more packages --- build/common.props | 13 +++++++++++++ .../Microsoft.AspNetCore.All.csproj | 1 + 2 files changed, 14 insertions(+) diff --git a/build/common.props b/build/common.props index b8f34e09fe..39985e45f5 100644 --- a/build/common.props +++ b/build/common.props @@ -118,6 +118,7 @@ + @@ -135,6 +136,7 @@ + @@ -167,6 +169,17 @@ + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 9607a4186a..bfc4256bf3 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -12,6 +12,7 @@ + From 7cb458673f757ac0365c96f1f0308b7240a86982 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sat, 29 Apr 2017 16:28:52 -0700 Subject: [PATCH 109/361] Include tar.gz files in Build.RS nupkg --- build/Build.RS.nuspec | 1 + 1 file changed, 1 insertion(+) diff --git a/build/Build.RS.nuspec b/build/Build.RS.nuspec index eb398b1b69..fee5984b47 100644 --- a/build/Build.RS.nuspec +++ b/build/Build.RS.nuspec @@ -8,5 +8,6 @@ + From 08ec9a7e4964a859ccd89219ef3026080d7441ec Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 1 May 2017 12:24:07 -0700 Subject: [PATCH 110/361] Use RuntimeFrameworkVersion instead for directory name (#82) --- .travis.yml | 22 +++++++++ MetaPackages.sln | 9 +++- appveyor.yml | 14 ++++++ build/common.props | 6 +++ build/dependencies.props | 1 + build/repo.targets | 11 +++-- .../Microsoft.AspNetCore.RuntimeStore.csproj | 10 ---- ....AspNetCore.HostingStartup.Template.csproj | 22 +++++++++ .../Program.cs | 7 +++ tools/TrimDeps/Program.cs | 48 +++++++++++++++++++ tools/TrimDeps/TrimDeps.csproj | 15 ++++++ 11 files changed, 151 insertions(+), 14 deletions(-) create mode 100644 .travis.yml create mode 100644 appveyor.yml create mode 100644 tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj create mode 100644 tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs create mode 100644 tools/TrimDeps/Program.cs create mode 100644 tools/TrimDeps/TrimDeps.csproj diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..2a46104677 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: csharp +sudo: false +dist: trusty +env: + global: + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 +mono: none +os: + - linux + - osx +osx_image: xcode8.2 +branches: + only: + - master + - release + - dev + - /^(.*\/)?ci-.*$/ +before_install: + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /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 /usr/local/lib/; fi +script: + - ./build.sh diff --git a/MetaPackages.sln b/MetaPackages.sln index 95ab066bb5..19e46291d0 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26424.2 +VisualStudioVersion = 15.0.26412.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-archive", "src\dotne EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Archive", "src\Microsoft.DotNet.Archive\Microsoft.DotNet.Archive.csproj", "{302400A0-98BB-4C04-88D4-C32DC2D4B945}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\TrimDeps.csproj", "{67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -99,6 +101,10 @@ Global {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Debug|Any CPU.Build.0 = Debug|Any CPU {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Release|Any CPU.ActiveCfg = Release|Any CPU {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Release|Any CPU.Build.0 = Release|Any CPU + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -118,5 +124,6 @@ Global {9BBA7A0A-109A-4AC8-B6EF-A52EA7CF1D90} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} {AE4216BF-D471-471B-82F3-6B6D004F7D17} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {302400A0-98BB-4C04-88D4-C32DC2D4B945} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000..1041615c68 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,14 @@ +init: + - git config --global core.autocrlf true +branches: + only: + - master + - release + - dev + - /^(.*\/)?ci-.*$/ +build_script: + - ps: .\build.ps1 +clone_depth: 1 +test: off +deploy: off +os: Visual Studio 2017 diff --git a/build/common.props b/build/common.props index 6718ac85dd..23cc402e92 100644 --- a/build/common.props +++ b/build/common.props @@ -185,8 +185,14 @@ + + + + + + diff --git a/build/dependencies.props b/build/dependencies.props index c2c1448f9a..440a49b3d6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,6 +5,7 @@ 1.0.0-* 4.3.0 2.0.0-* + 10.0.1 15.0.0 2.2.0 diff --git a/build/repo.targets b/build/repo.targets index 9511356ec3..54067bb6c8 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -6,6 +6,9 @@ $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ $(MetaPackagePath)Microsoft.AspNetCore.RuntimeStore.csproj + $(RepositoryRoot)tools\Microsoft.AspNetCore.HostingStartup.Template\ + $(HostingStartupTemplatePath)Microsoft.AspNetCore.HostingStartup.Template.csproj + $(RepositoryRoot)src\Archive.AspNetCore.All\ $(FallbackArchiveDir)Archive.AspNetCore.All.csproj @@ -14,9 +17,9 @@ $(MetaPackagePath)bin\work\ $(MetaPackagePath)bin\packageCache\ - $(MetaPackagePath)bin\deps\ $(RepositoryRoot)artifacts\ $(ArtifactsDir)zip\ + $(ArtifactsDir)deps\ $(ArtifactsZipDir)ts\ $(ArtifactsZipDir)nt\ $(ArtifactsDir)temp\ @@ -36,7 +39,7 @@ Condition="Exists('$(DependencyBuildDirectory)')" /> - + @@ -57,7 +60,9 @@ - + + + diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 0fbcd07cd7..3cce763f2b 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -9,14 +9,4 @@ - - - - - $([System.String]::Copy('%(Filename)').Replace('.deps','')) - - - - - diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj new file mode 100644 index 0000000000..c3e6a50687 --- /dev/null +++ b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj @@ -0,0 +1,22 @@ + + + + + + + netcoreapp2.0 + Exe + + + + + + + + + $(DepsOutputPath)\$(HostingStartupPackageName)\shared\Microsoft.NETCore.App\$(RuntimeFrameworkVersion)\$(HostingStartupPackageName).deps.json + + + + + diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs b/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs new file mode 100644 index 0000000000..8cd3c0026c --- /dev/null +++ b/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs @@ -0,0 +1,7 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class Program +{ + public static void Main() { } +} \ No newline at end of file diff --git a/tools/TrimDeps/Program.cs b/tools/TrimDeps/Program.cs new file mode 100644 index 0000000000..639c620f52 --- /dev/null +++ b/tools/TrimDeps/Program.cs @@ -0,0 +1,48 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.IO; +using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +public class Program +{ + public static void Main(string[] args) + { + ChangeEntryPointLibraryName(args[0]); + } + + private static void ChangeEntryPointLibraryName(string depsFile) + { + JToken deps; + using (var file = File.OpenText(depsFile)) + using (JsonTextReader reader = new JsonTextReader(file)) + { + deps = JObject.ReadFrom(reader); + } + + string version = null; + foreach (JProperty target in deps["targets"]) + { + var targetLibrary = target.Value.Children().FirstOrDefault(); + if (targetLibrary == null) + { + continue; + } + + targetLibrary.Remove(); + } + if (version != null) + { + var library = deps["libraries"].Children().First(); + library.Remove(); + + using (var file = File.CreateText(depsFile)) + using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) + { + deps.WriteTo(writer); + } + } + } +} \ No newline at end of file diff --git a/tools/TrimDeps/TrimDeps.csproj b/tools/TrimDeps/TrimDeps.csproj new file mode 100644 index 0000000000..2c7bcd5e41 --- /dev/null +++ b/tools/TrimDeps/TrimDeps.csproj @@ -0,0 +1,15 @@ + + + + + + + netcoreapp2.0 + Exe + + + + + + + From 659c008ea8f1310ed091dd327e9572736c39222a Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Mon, 1 May 2017 13:11:15 -0700 Subject: [PATCH 111/361] fix LZMA archive directory structure (#88) --- .../IndexedArchive.cs | 21 +++++++++++-------- src/dotnet-archive/Program.cs | 9 ++++---- src/dotnet-archive/dotnet-archive.csproj | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.DotNet.Archive/IndexedArchive.cs b/src/Microsoft.DotNet.Archive/IndexedArchive.cs index bb4c9bbd14..e94912ea5b 100644 --- a/src/Microsoft.DotNet.Archive/IndexedArchive.cs +++ b/src/Microsoft.DotNet.Archive/IndexedArchive.cs @@ -18,7 +18,8 @@ namespace Microsoft.DotNet.Archive { public DestinationFileInfo(string destinationPath, string hash) { - DestinationPath = destinationPath; + // Normalize the path + DestinationPath = destinationPath.Replace(Path.DirectorySeparatorChar, '/'); Hash = hash; } @@ -30,11 +31,13 @@ namespace Microsoft.DotNet.Archive { public ArchiveSource(string sourceArchive, string sourceFile, string archivePath, string hash, long size) { - SourceArchive = sourceArchive; - SourceFile = sourceFile; - ArchivePath = archivePath; Hash = hash; Size = size; + + // Normalize the paths + SourceArchive = sourceArchive?.Replace(Path.DirectorySeparatorChar, '/'); + SourceFile = sourceFile.Replace(Path.DirectorySeparatorChar, '/'); + ArchivePath = archivePath.Replace(Path.DirectorySeparatorChar, '/'); } public string SourceArchive { get; set; } @@ -85,7 +88,7 @@ namespace Microsoft.DotNet.Archive public IndexedArchive() { } - + private static Stream CreateTemporaryStream() { string temp = Path.GetTempPath(); @@ -246,7 +249,7 @@ namespace Microsoft.DotNet.Archive using (var archiveStream = File.Create(DestinationPath)) using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create)) { - foreach(var zipSource in entries) + foreach (var zipSource in entries) { var entry = archive.CreateEntry(zipSource.Item1, CompressionLevel.Optimal); using (var entryStream = entry.Open()) @@ -400,9 +403,9 @@ namespace Microsoft.DotNet.Archive CheckDisposed(); using (var fs = File.OpenRead(externalFile)) { - string hash = GetHash(fs); + string hash = GetHash(fs); // $ prefix indicates that the file is not in the archive and path is relative to an external directory - _archiveFiles[hash] = new ArchiveSource(null, null, "$" + hash , hash, fs.Length); + _archiveFiles[hash] = new ArchiveSource(null, null, "$" + hash, hash, fs.Length); _externalFiles[hash] = externalFile; } } @@ -441,7 +444,7 @@ namespace Microsoft.DotNet.Archive using (var sourceArchive = new ZipArchive(File.OpenRead(sourceZipFile), ZipArchiveMode.Read)) { - foreach(var entry in sourceArchive.Entries) + foreach (var entry in sourceArchive.Entries) { string hash = null; long size = entry.Length; diff --git a/src/dotnet-archive/Program.cs b/src/dotnet-archive/Program.cs index 3376bf47ef..c73f5f41af 100644 --- a/src/dotnet-archive/Program.cs +++ b/src/dotnet-archive/Program.cs @@ -29,9 +29,10 @@ namespace Microsoft.DotNet.Tools.Archive var extract = app.Option("-x|--extract ", "Directory to extract to", CommandOptionType.SingleValue); var archiveFile = app.Option("-a|--archive ", "Archive to operate on", CommandOptionType.SingleValue); var externals = app.Option("--external ...", "External files and directories to consider for extraction", CommandOptionType.MultipleValue); - var sources = app.Argument("...", "Files & directory to include in the archive", multipleValues:true); + var sources = app.Argument("...", "Files & directory to include in the archive", multipleValues: true); - app.OnExecute(() => { + app.OnExecute(() => + { if (extract.HasValue() && sources.Values.Any()) { @@ -67,7 +68,7 @@ namespace Microsoft.DotNet.Tools.Archive if (sources.Values.Any()) { - foreach(var source in sources.Values) + foreach (var source in sources.Values) { if (Directory.Exists(source)) { @@ -91,6 +92,6 @@ namespace Microsoft.DotNet.Tools.Archive }); return app.Execute(args); - } + } } } diff --git a/src/dotnet-archive/dotnet-archive.csproj b/src/dotnet-archive/dotnet-archive.csproj index 5ea7e8fb45..3d41a55f58 100644 --- a/src/dotnet-archive/dotnet-archive.csproj +++ b/src/dotnet-archive/dotnet-archive.csproj @@ -6,7 +6,7 @@ netcoreapp2.0 Exe false - win7-x64 + win7-x64;linux-x64 From a5a9b6adab93ad7ff394d3b52ff062e9f1034a21 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 1 May 2017 12:24:07 -0700 Subject: [PATCH 112/361] Use RuntimeFrameworkVersion instead for directory name (#82) --- .travis.yml | 22 +++++++++ MetaPackages.sln | 9 +++- appveyor.yml | 14 ++++++ build/common.props | 6 +++ build/dependencies.props | 1 + build/repo.targets | 11 +++-- .../Microsoft.AspNetCore.RuntimeStore.csproj | 10 ---- ....AspNetCore.HostingStartup.Template.csproj | 22 +++++++++ .../Program.cs | 7 +++ tools/TrimDeps/Program.cs | 48 +++++++++++++++++++ tools/TrimDeps/TrimDeps.csproj | 15 ++++++ 11 files changed, 151 insertions(+), 14 deletions(-) create mode 100644 .travis.yml create mode 100644 appveyor.yml create mode 100644 tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj create mode 100644 tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs create mode 100644 tools/TrimDeps/Program.cs create mode 100644 tools/TrimDeps/TrimDeps.csproj diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..2a46104677 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: csharp +sudo: false +dist: trusty +env: + global: + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 +mono: none +os: + - linux + - osx +osx_image: xcode8.2 +branches: + only: + - master + - release + - dev + - /^(.*\/)?ci-.*$/ +before_install: + - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /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 /usr/local/lib/; fi +script: + - ./build.sh diff --git a/MetaPackages.sln b/MetaPackages.sln index 95ab066bb5..19e46291d0 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26424.2 +VisualStudioVersion = 15.0.26412.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-archive", "src\dotne EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Archive", "src\Microsoft.DotNet.Archive\Microsoft.DotNet.Archive.csproj", "{302400A0-98BB-4C04-88D4-C32DC2D4B945}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\TrimDeps.csproj", "{67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -99,6 +101,10 @@ Global {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Debug|Any CPU.Build.0 = Debug|Any CPU {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Release|Any CPU.ActiveCfg = Release|Any CPU {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Release|Any CPU.Build.0 = Release|Any CPU + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -118,5 +124,6 @@ Global {9BBA7A0A-109A-4AC8-B6EF-A52EA7CF1D90} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} {AE4216BF-D471-471B-82F3-6B6D004F7D17} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {302400A0-98BB-4C04-88D4-C32DC2D4B945} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection EndGlobal diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000..1041615c68 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,14 @@ +init: + - git config --global core.autocrlf true +branches: + only: + - master + - release + - dev + - /^(.*\/)?ci-.*$/ +build_script: + - ps: .\build.ps1 +clone_depth: 1 +test: off +deploy: off +os: Visual Studio 2017 diff --git a/build/common.props b/build/common.props index 6718ac85dd..23cc402e92 100644 --- a/build/common.props +++ b/build/common.props @@ -185,8 +185,14 @@ + + + + + + diff --git a/build/dependencies.props b/build/dependencies.props index ee92e50823..caea34a061 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,6 +5,7 @@ 1.0.0-* 4.3.0 2.0.0-* + 10.0.1 15.0.0 2.2.0 diff --git a/build/repo.targets b/build/repo.targets index 0f7c8cf384..bf1dd5f259 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -6,15 +6,18 @@ $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ $(MetaPackagePath)Microsoft.AspNetCore.RuntimeStore.csproj + $(RepositoryRoot)tools\Microsoft.AspNetCore.HostingStartup.Template\ + $(HostingStartupTemplatePath)Microsoft.AspNetCore.HostingStartup.Template.csproj + $(RepositoryRoot)src\Archive.AspNetCore.All\ $(FallbackArchiveDir)Archive.AspNetCore.All.csproj $(MetaPackagePath)bin\work\ $(MetaPackagePath)bin\packageCache\ - $(MetaPackagePath)bin\deps\ $(RepositoryRoot)artifacts\ $(ArtifactsDir)zip\ + $(ArtifactsDir)deps\ $(ArtifactsZipDir)ts\ $(ArtifactsZipDir)nt\ $(ArtifactsDir)temp\ @@ -34,7 +37,7 @@ Condition="Exists('$(DependencyBuildDirectory)')" /> - + @@ -55,7 +58,9 @@ - + + + diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 0fbcd07cd7..3cce763f2b 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -9,14 +9,4 @@ - - - - - $([System.String]::Copy('%(Filename)').Replace('.deps','')) - - - - - diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj new file mode 100644 index 0000000000..c3e6a50687 --- /dev/null +++ b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj @@ -0,0 +1,22 @@ + + + + + + + netcoreapp2.0 + Exe + + + + + + + + + $(DepsOutputPath)\$(HostingStartupPackageName)\shared\Microsoft.NETCore.App\$(RuntimeFrameworkVersion)\$(HostingStartupPackageName).deps.json + + + + + diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs b/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs new file mode 100644 index 0000000000..8cd3c0026c --- /dev/null +++ b/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs @@ -0,0 +1,7 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class Program +{ + public static void Main() { } +} \ No newline at end of file diff --git a/tools/TrimDeps/Program.cs b/tools/TrimDeps/Program.cs new file mode 100644 index 0000000000..639c620f52 --- /dev/null +++ b/tools/TrimDeps/Program.cs @@ -0,0 +1,48 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.IO; +using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +public class Program +{ + public static void Main(string[] args) + { + ChangeEntryPointLibraryName(args[0]); + } + + private static void ChangeEntryPointLibraryName(string depsFile) + { + JToken deps; + using (var file = File.OpenText(depsFile)) + using (JsonTextReader reader = new JsonTextReader(file)) + { + deps = JObject.ReadFrom(reader); + } + + string version = null; + foreach (JProperty target in deps["targets"]) + { + var targetLibrary = target.Value.Children().FirstOrDefault(); + if (targetLibrary == null) + { + continue; + } + + targetLibrary.Remove(); + } + if (version != null) + { + var library = deps["libraries"].Children().First(); + library.Remove(); + + using (var file = File.CreateText(depsFile)) + using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) + { + deps.WriteTo(writer); + } + } + } +} \ No newline at end of file diff --git a/tools/TrimDeps/TrimDeps.csproj b/tools/TrimDeps/TrimDeps.csproj new file mode 100644 index 0000000000..2c7bcd5e41 --- /dev/null +++ b/tools/TrimDeps/TrimDeps.csproj @@ -0,0 +1,15 @@ + + + + + + + netcoreapp2.0 + Exe + + + + + + + From 605aeddc227a1503e8e78031755d081a5ce0958f Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Mon, 1 May 2017 18:05:11 -0700 Subject: [PATCH 113/361] Support more certificate loading scenarios (#69). --- MetaPackages.sln | 6 - build/dependencies.props | 1 + samples/AppSettings/appsettings.json | 2 +- .../CertificateFileLoader.cs | 15 + src/Microsoft.AspNetCore/CertificateLoader.cs | 190 ++-- .../CertificateStoreLoader.cs | 56 + .../ICertificateFileLoader.cs | 12 + .../ICertificateStoreLoader.cs | 12 + .../KestrelServerOptionsSetup.cs | 65 +- .../Microsoft.AspNetCore.csproj | 2 +- .../Properties/AssemblyInfo.cs | 7 + .../CertificateLoaderTests.cs | 999 ++++++++++++++++++ ...icrosoft.AspNetCore.FunctionalTests.csproj | 3 +- .../TestArtifacts/Certificate.pfx | Bin 0 -> 2461 bytes .../WebHostFunctionalTests.cs | 6 +- test/TestArtifacts/testCert.pfx | Bin 2483 -> 0 bytes 16 files changed, 1241 insertions(+), 135 deletions(-) create mode 100644 src/Microsoft.AspNetCore/CertificateFileLoader.cs create mode 100644 src/Microsoft.AspNetCore/CertificateStoreLoader.cs create mode 100644 src/Microsoft.AspNetCore/ICertificateFileLoader.cs create mode 100644 src/Microsoft.AspNetCore/ICertificateStoreLoader.cs create mode 100644 src/Microsoft.AspNetCore/Properties/AssemblyInfo.cs create mode 100644 test/Microsoft.AspNetCore.FunctionalTests/CertificateLoaderTests.cs create mode 100644 test/Microsoft.AspNetCore.FunctionalTests/TestArtifacts/Certificate.pfx delete mode 100644 test/TestArtifacts/testCert.pfx diff --git a/MetaPackages.sln b/MetaPackages.sln index 19e46291d0..cfcc774203 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -40,11 +40,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRequestDelegateUrlApp" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateDefaultBuilderApp", "test\TestSites\CreateDefaultBuilderApp\CreateDefaultBuilderApp.csproj", "{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestArtifacts", "TestArtifacts", "{9BBA7A0A-109A-4AC8-B6EF-A52EA7CF1D90}" - ProjectSection(SolutionItems) = preProject - test\TestArtifacts\testCert.pfx = test\TestArtifacts\testCert.pfx - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-archive", "src\dotnet-archive\dotnet-archive.csproj", "{AE4216BF-D471-471B-82F3-6B6D004F7D17}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Archive", "src\Microsoft.DotNet.Archive\Microsoft.DotNet.Archive.csproj", "{302400A0-98BB-4C04-88D4-C32DC2D4B945}" @@ -121,7 +116,6 @@ Global {3A85FA52-F601-422E-A42E-9F187DB28492} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {401C741B-6C7C-4E08-9F09-C3D43D22C0DE} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} - {9BBA7A0A-109A-4AC8-B6EF-A52EA7CF1D90} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} {AE4216BF-D471-471B-82F3-6B6D004F7D17} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {302400A0-98BB-4C04-88D4-C32DC2D4B945} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} diff --git a/build/dependencies.props b/build/dependencies.props index caea34a061..e532f8a25d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,6 +5,7 @@ 1.0.0-* 4.3.0 2.0.0-* + 4.7.1 10.0.1 15.0.0 2.2.0 diff --git a/samples/AppSettings/appsettings.json b/samples/AppSettings/appsettings.json index da7253554d..fac810ec12 100644 --- a/samples/AppSettings/appsettings.json +++ b/samples/AppSettings/appsettings.json @@ -28,7 +28,7 @@ "Source": "File", "Path": "testCert.pfx", // TODO: remove when dotnet user-secrets is working again - "Password": "testPassword", + "Password": "testPassword" } }, // Add testCert.pfx to the current user's certificate store to enable this scenario. diff --git a/src/Microsoft.AspNetCore/CertificateFileLoader.cs b/src/Microsoft.AspNetCore/CertificateFileLoader.cs new file mode 100644 index 0000000000..1c0b6e5759 --- /dev/null +++ b/src/Microsoft.AspNetCore/CertificateFileLoader.cs @@ -0,0 +1,15 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Security.Cryptography.X509Certificates; + +namespace Microsoft.AspNetCore +{ + internal class CertificateFileLoader : ICertificateFileLoader + { + public X509Certificate2 Load(string path, string password, X509KeyStorageFlags flags) + { + return new X509Certificate2(path, password, flags); + } + } +} diff --git a/src/Microsoft.AspNetCore/CertificateLoader.cs b/src/Microsoft.AspNetCore/CertificateLoader.cs index 95339040a1..be006b4941 100644 --- a/src/Microsoft.AspNetCore/CertificateLoader.cs +++ b/src/Microsoft.AspNetCore/CertificateLoader.cs @@ -12,49 +12,125 @@ namespace Microsoft.AspNetCore /// /// A helper class to load certificates from files and certificate stores based on data. /// - public static class CertificateLoader + public class CertificateLoader { + private readonly IConfiguration _certificatesConfiguration; + private readonly ICertificateFileLoader _certificateFileLoader; + private readonly ICertificateStoreLoader _certificateStoreLoader; + /// - /// Loads one or more certificates from a single source. + /// Creates a new instance of . /// - /// An with information about a certificate source. - /// The certificate password, in case it's being loaded from a file. - /// The loaded certificates. - public static X509Certificate2 Load(IConfiguration certificateConfiguration, string password) + public CertificateLoader() + : this(null) { - var sourceKind = certificateConfiguration.GetValue("Source"); + } + + /// + /// Creates a new instance of that can load certificate references from configuration. + /// + /// An with information about certificates. + public CertificateLoader(IConfiguration certificatesConfiguration) + : this(certificatesConfiguration, new CertificateFileLoader(), new CertificateStoreLoader()) + { + _certificatesConfiguration = certificatesConfiguration; + } + + internal CertificateLoader(IConfiguration certificatesConfiguration, ICertificateFileLoader certificateFileLoader, ICertificateStoreLoader certificateStoreLoader) + { + _certificatesConfiguration = certificatesConfiguration; + _certificateFileLoader = certificateFileLoader; + _certificateStoreLoader = certificateStoreLoader; + } + + /// + /// Loads one or more certificates based on the information found in a configuration section. + /// + /// A configuration section containing either a string value referencing certificates + /// by name, or one or more inline certificate specifications. + /// + /// One or more loaded certificates. + public IEnumerable Load(IConfigurationSection certificateConfiguration) + { + var certificateNames = certificateConfiguration.Value; + var certificates = new List(); + + if (certificateNames != null) + { + foreach (var certificateName in certificateNames.Split(';')) + { + var certificate = LoadSingle(certificateName); + if (certificate != null) + { + certificates.Add(certificate); + } + } + } + else + { + if (certificateConfiguration["Source"] != null) + { + var certificate = LoadSingle(certificateConfiguration); + if (certificate != null) + { + certificates.Add(certificate); + } + } + else + { + certificates.AddRange(LoadMultiple(certificateConfiguration)); + } + } + + return certificates; + } + + /// + /// Loads a certificate by name. + /// + /// The certificate name. + /// The loaded certificate + /// This method only works if the instance was constructed with + /// a reference to an instance containing named certificates. + /// + private X509Certificate2 LoadSingle(string certificateName) + { + var certificateConfiguration = _certificatesConfiguration?.GetSection(certificateName); + + if (!certificateConfiguration.Exists()) + { + throw new InvalidOperationException($"No certificate named {certificateName} found in configuration"); + } + + return LoadSingle(certificateConfiguration); + } + + private X509Certificate2 LoadSingle(IConfigurationSection certificateConfiguration) + { + var sourceKind = certificateConfiguration["Source"]; CertificateSource certificateSource; switch (sourceKind.ToLowerInvariant()) { case "file": - certificateSource = new CertificateFileSource(password); + certificateSource = new CertificateFileSource(_certificateFileLoader); break; case "store": - certificateSource = new CertificateStoreSource(); + certificateSource = new CertificateStoreSource(_certificateStoreLoader); break; default: throw new InvalidOperationException($"Invalid certificate source kind: {sourceKind}"); } certificateConfiguration.Bind(certificateSource); + return certificateSource.Load(); } - /// - /// Loads all certificates specified in an . - /// - /// The root . - /// - /// A dictionary mapping certificate names to loaded certificates. - /// - public static Dictionary LoadAll(IConfiguration configurationRoot) - { - return configurationRoot.GetSection("Certificates").GetChildren() - .ToDictionary( - certificateSource => certificateSource.Key, - certificateSource => Load(certificateSource, certificateSource["Password"])); - } + private IEnumerable LoadMultiple(IConfigurationSection certificatesConfiguration) + => certificatesConfiguration.GetChildren() + .Select(LoadSingle) + .Where(c => c != null); private abstract class CertificateSource { @@ -65,22 +141,24 @@ namespace Microsoft.AspNetCore private class CertificateFileSource : CertificateSource { - private readonly string _password; + private ICertificateFileLoader _certificateFileLoader; - public CertificateFileSource(string password) + public CertificateFileSource(ICertificateFileLoader certificateFileLoader) { - _password = password; + _certificateFileLoader = certificateFileLoader; } public string Path { get; set; } + public string Password { get; set; } + public override X509Certificate2 Load() { var certificate = TryLoad(X509KeyStorageFlags.DefaultKeySet, out var error) ?? TryLoad(X509KeyStorageFlags.UserKeySet, out error) - #if NETCOREAPP2_0 +#if NETCOREAPP2_0 ?? TryLoad(X509KeyStorageFlags.EphemeralKeySet, out error) - #endif +#endif ; if (error != null) @@ -95,7 +173,7 @@ namespace Microsoft.AspNetCore { try { - var loadedCertificate = new X509Certificate2(Path, _password, flags); + var loadedCertificate = _certificateFileLoader.Load(Path, Password, flags); exception = null; return loadedCertificate; } @@ -109,6 +187,13 @@ namespace Microsoft.AspNetCore private class CertificateStoreSource : CertificateSource { + private readonly ICertificateStoreLoader _certificateStoreLoader; + + public CertificateStoreSource(ICertificateStoreLoader certificateStoreLoader) + { + _certificateStoreLoader = certificateStoreLoader; + } + public string Subject { get; set; } public string StoreName { get; set; } public string StoreLocation { get; set; } @@ -121,52 +206,7 @@ namespace Microsoft.AspNetCore throw new InvalidOperationException($"Invalid store location: {StoreLocation}"); } - using (var store = new X509Store(StoreName, storeLocation)) - { - X509Certificate2Collection storeCertificates = null; - X509Certificate2Collection foundCertificates = null; - X509Certificate2 foundCertificate = null; - - try - { - store.Open(OpenFlags.ReadOnly); - storeCertificates = store.Certificates; - foundCertificates = storeCertificates.Find(X509FindType.FindBySubjectDistinguishedName, Subject, validOnly: !AllowInvalid); - foundCertificate = foundCertificates - .OfType() - .OrderByDescending(certificate => certificate.NotAfter) - .FirstOrDefault(); - - if (foundCertificate == null) - { - throw new InvalidOperationException($"No certificate found for {Subject} in store {StoreName} in {StoreLocation}"); - } - - return foundCertificate; - } - finally - { - if (foundCertificate != null) - { - storeCertificates.Remove(foundCertificate); - foundCertificates.Remove(foundCertificate); - } - - DisposeCertificates(storeCertificates); - DisposeCertificates(foundCertificates); - } - } - } - - private void DisposeCertificates(X509Certificate2Collection certificates) - { - if (certificates != null) - { - foreach (var certificate in certificates) - { - certificate.Dispose(); - } - } + return _certificateStoreLoader.Load(Subject, StoreName, storeLocation, !AllowInvalid); } } } diff --git a/src/Microsoft.AspNetCore/CertificateStoreLoader.cs b/src/Microsoft.AspNetCore/CertificateStoreLoader.cs new file mode 100644 index 0000000000..27158d4da3 --- /dev/null +++ b/src/Microsoft.AspNetCore/CertificateStoreLoader.cs @@ -0,0 +1,56 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq; +using System.Security.Cryptography.X509Certificates; + +namespace Microsoft.AspNetCore +{ + internal class CertificateStoreLoader : ICertificateStoreLoader + { + public X509Certificate2 Load(string subject, string storeName, StoreLocation storeLocation, bool validOnly) + { + using (var store = new X509Store(storeName, storeLocation)) + { + X509Certificate2Collection storeCertificates = null; + X509Certificate2Collection foundCertificates = null; + X509Certificate2 foundCertificate = null; + + try + { + store.Open(OpenFlags.ReadOnly); + storeCertificates = store.Certificates; + foundCertificates = storeCertificates.Find(X509FindType.FindBySubjectDistinguishedName, subject, validOnly); + foundCertificate = foundCertificates + .OfType() + .OrderByDescending(certificate => certificate.NotAfter) + .FirstOrDefault(); + + return foundCertificate; + } + finally + { + if (foundCertificate != null) + { + storeCertificates.Remove(foundCertificate); + foundCertificates.Remove(foundCertificate); + } + + DisposeCertificates(storeCertificates); + DisposeCertificates(foundCertificates); + } + } + } + + private void DisposeCertificates(X509Certificate2Collection certificates) + { + if (certificates != null) + { + foreach (var certificate in certificates) + { + certificate.Dispose(); + } + } + } + } +} diff --git a/src/Microsoft.AspNetCore/ICertificateFileLoader.cs b/src/Microsoft.AspNetCore/ICertificateFileLoader.cs new file mode 100644 index 0000000000..4c394bbd02 --- /dev/null +++ b/src/Microsoft.AspNetCore/ICertificateFileLoader.cs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Security.Cryptography.X509Certificates; + +namespace Microsoft.AspNetCore +{ + internal interface ICertificateFileLoader + { + X509Certificate2 Load(string path, string password, X509KeyStorageFlags flags); + } +} diff --git a/src/Microsoft.AspNetCore/ICertificateStoreLoader.cs b/src/Microsoft.AspNetCore/ICertificateStoreLoader.cs new file mode 100644 index 0000000000..f128bbd675 --- /dev/null +++ b/src/Microsoft.AspNetCore/ICertificateStoreLoader.cs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Security.Cryptography.X509Certificates; + +namespace Microsoft.AspNetCore +{ + internal interface ICertificateStoreLoader + { + X509Certificate2 Load(string subject, string storeName, StoreLocation storeLocation, bool validOnly); + } +} diff --git a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs index 888ece3903..d2ec6f8a4a 100644 --- a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs +++ b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs @@ -2,39 +2,24 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using System.Net; -using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Core; -using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore { - /// - /// Binds Kestrel configuration. - /// - public class KestrelServerOptionsSetup : IConfigureOptions + internal class KestrelServerOptionsSetup : IConfigureOptions { private readonly IConfiguration _configurationRoot; - /// - /// Creates a new instance of . - /// - /// The root . public KestrelServerOptionsSetup(IConfiguration configurationRoot) { _configurationRoot = configurationRoot; } - /// - /// Configures a instance. - /// - /// The to configure. public void Configure(KestrelServerOptions options) { BindConfiguration(options); @@ -42,60 +27,46 @@ namespace Microsoft.AspNetCore private void BindConfiguration(KestrelServerOptions options) { - var certificates = CertificateLoader.LoadAll(_configurationRoot); - var endPoints = _configurationRoot.GetSection("Kestrel:EndPoints"); + var certificateLoader = new CertificateLoader(_configurationRoot.GetSection("Certificates")); - foreach (var endPoint in endPoints.GetChildren()) + foreach (var endPoint in _configurationRoot.GetSection("Kestrel:EndPoints").GetChildren()) { - BindEndPoint(options, endPoint, certificates); + BindEndPoint(options, endPoint, certificateLoader); } } private void BindEndPoint( KestrelServerOptions options, IConfigurationSection endPoint, - Dictionary certificates) + CertificateLoader certificateLoader) { - var addressValue = endPoint.GetValue("Address"); - var portValue = endPoint.GetValue("Port"); + var configAddress = endPoint.GetValue("Address"); + var configPort = endPoint.GetValue("Port"); - IPAddress address; - if (!IPAddress.TryParse(addressValue, out address)) + if (!IPAddress.TryParse(configAddress, out var address)) { - throw new InvalidOperationException($"Invalid IP address: {addressValue}"); + throw new InvalidOperationException($"Invalid IP address in configuration: {configAddress}"); } - int port; - if (!int.TryParse(portValue, out port)) + if (!int.TryParse(configPort, out var port)) { - throw new InvalidOperationException($"Invalid port: {portValue}"); + throw new InvalidOperationException($"Invalid port in configuration: {configPort}"); } options.Listen(address, port, listenOptions => { - var certificateName = endPoint.GetValue("Certificate"); + var certificateConfig = endPoint.GetSection("Certificate"); - X509Certificate2 endPointCertificate = null; - if (certificateName != null) + if (certificateConfig.Exists()) { - if (!certificates.TryGetValue(certificateName, out endPointCertificate)) + var certificate = certificateLoader.Load(certificateConfig).FirstOrDefault(); + + if (certificate == null) { - throw new InvalidOperationException($"No certificate named {certificateName} found in configuration"); + throw new InvalidOperationException($"Unable to load certificate for endpoint '{endPoint.Key}'"); } - } - else - { - var certificate = endPoint.GetSection("Certificate"); - if (certificate.GetChildren().Any()) - { - endPointCertificate = CertificateLoader.Load(certificate, certificate["Password"]); - } - } - - if (endPointCertificate != null) - { - listenOptions.UseHttps(endPointCertificate); + listenOptions.UseHttps(certificate); } }); } diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 5350bf93a3..5841f9dc24 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,7 +3,7 @@ - netstandard1.3 + netstandard1.3;netcoreapp2.0 aspnetcore Microsoft.AspNetCore true diff --git a/src/Microsoft.AspNetCore/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..a3a00f9d5c --- /dev/null +++ b/src/Microsoft.AspNetCore/Properties/AssemblyInfo.cs @@ -0,0 +1,7 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.FunctionalTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.FunctionalTests/CertificateLoaderTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/CertificateLoaderTests.cs new file mode 100644 index 0000000000..7cf3787a56 --- /dev/null +++ b/test/Microsoft.AspNetCore.FunctionalTests/CertificateLoaderTests.cs @@ -0,0 +1,999 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using Microsoft.Extensions.Configuration; +using Xunit; +using Moq; + +namespace Microsoft.AspNetCore.FunctionalTests +{ + public class CertificateLoaderTests + { + [Fact] + public void Loads_SingleCertificateName_File() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["TestConfig:Certificate"] = "Certificate1" + }) + .Build(); + + var certificate = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + Mock.Of()); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(1, loadedCertificates.Count()); + Assert.Same(certificate, loadedCertificates.ElementAt(0)); + certificateFileLoader.VerifyAll(); + } + + [Fact] + public void Throws_SingleCertificateName_File_KeyNotFound() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["TestConfig:Certificate"] = "Certificate2" + }) + .Build(); + + var certificate = new X509Certificate2(); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + Mock.Of(), + Mock.Of()); + + var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); + Assert.Equal("No certificate named Certificate2 found in configuration", exception.Message); + } + + [Fact] + public void Throws_SingleCertificateName_File_FileNotFound() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["TestConfig:Certificate"] = "Certificate1" + }) + .Build(); + + var exception = new Exception(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Callback(() => throw exception); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + Mock.Of()); + + Assert.Same(exception, Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")))); + } + + [Fact] + public void Loads_SingleCertificateName_Store() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "Store", + ["Certificates:Certificate1:Subject"] = "localhost", + ["Certificates:Certificate1:StoreName"] = "My", + ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificate"] = "Certificate1" + }) + .Build(); + + var certificate = new X509Certificate2(); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(certificate); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + Mock.Of(), + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(1, loadedCertificates.Count()); + Assert.Same(certificate, loadedCertificates.ElementAt(0)); + certificateStoreLoader.VerifyAll(); + } + + [Fact] + public void Throws_SingleCertificateName_Store_KeyNotFound() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "Store", + ["Certificates:Certificate1:Subject"] = "localhost", + ["Certificates:Certificate1:StoreName"] = "My", + ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificate"] = "Certificate2" + }) + .Build(); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + Mock.Of(), + Mock.Of()); + + var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); + Assert.Equal("No certificate named Certificate2 found in configuration", exception.Message); + } + + [Fact] + public void ReturnsNull_SingleCertificateName_Store_NotFoundInStore() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "Store", + ["Certificates:Certificate1:Subject"] = "localhost", + ["Certificates:Certificate1:StoreName"] = "My", + ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificate"] = "Certificate1" + }) + .Build(); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(null); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + Mock.Of(), + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(0, loadedCertificates.Count()); + certificateStoreLoader.VerifyAll(); + } + + [Fact] + public void Loads_MultipleCertificateNames_File() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["Certificates:Certificate2:Source"] = "File", + ["Certificates:Certificate2:Path"] = "Certificate2.pfx", + ["Certificates:Certificate2:Password"] = "Password2", + ["TestConfig:Certificate"] = "Certificate1;Certificate2" + }) + .Build(); + + var certificate1 = new X509Certificate2(); + var certificate2 = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate1); + certificateFileLoader + .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) + .Returns(certificate2); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + Mock.Of()); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(2, loadedCertificates.Count()); + Assert.Same(certificate1, loadedCertificates.ElementAt(0)); + Assert.Same(certificate2, loadedCertificates.ElementAt(1)); + certificateFileLoader.VerifyAll(); + } + + [Theory] + [InlineData("Certificate1;NotFound")] + [InlineData("Certificate1;Certificate2;NotFound")] + [InlineData("NotFound;Certificate1")] + [InlineData("NotFound;Certificate1;Certificate2")] + [InlineData("Certificate1;NotFound;Certificate2")] + public void Throws_MultipleCertificateNames_File_KeyNotFound(string certificateNames) + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["Certificates:Certificate2:Source"] = "File", + ["Certificates:Certificate2:Path"] = "Certificate2.pfx", + ["Certificates:Certificate2:Password"] = "Password2", + ["TestConfig:Certificate"] = certificateNames + }) + .Build(); + + var certificate1 = new X509Certificate2(); + var certificate2 = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate1); + certificateFileLoader + .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) + .Returns(certificate2); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + Mock.Of()); + + var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); + Assert.Equal("No certificate named NotFound found in configuration", exception.Message); + } + + [Theory] + [InlineData("Certificate1;Certificate2")] + [InlineData("Certificate2;Certificate1")] + public void Throws_MultipleCertificateNames_File_FileNotFound(string certificateNames) + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["Certificates:Certificate2:Source"] = "File", + ["Certificates:Certificate2:Path"] = "Certificate2.pfx", + ["Certificates:Certificate2:Password"] = "Password2", + ["TestConfig:Certificate"] = certificateNames + }) + .Build(); + + var certificate1 = new X509Certificate2(); + var exception = new Exception(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate1); + certificateFileLoader + .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) + .Throws(exception); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + Mock.Of()); + + Assert.Same(exception, Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")))); + } + + [Fact] + public void Loads_MultipleCertificateNames_Store() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "Store", + ["Certificates:Certificate1:Subject"] = "localhost", + ["Certificates:Certificate1:StoreName"] = "My", + ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["Certificates:Certificate2:Source"] = "Store", + ["Certificates:Certificate2:Subject"] = "example.com", + ["Certificates:Certificate2:StoreName"] = "Root", + ["Certificates:Certificate2:StoreLocation"] = "LocalMachine", + ["TestConfig:Certificate"] = "Certificate1;Certificate2" + }) + .Build(); + + var certificate1 = new X509Certificate2(); + var certificate2 = new X509Certificate2(); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(certificate1); + certificateStoreLoader + .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) + .Returns(certificate2); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + Mock.Of(), + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(2, loadedCertificates.Count()); + Assert.Same(certificate1, loadedCertificates.ElementAt(0)); + Assert.Same(certificate2, loadedCertificates.ElementAt(1)); + certificateStoreLoader.VerifyAll(); + } + + [Theory] + [InlineData("Certificate1;NotFound")] + [InlineData("Certificate1;Certificate2;NotFound")] + [InlineData("NotFound;Certificate1")] + [InlineData("NotFound;Certificate1;Certificate2")] + [InlineData("Certificate1;NotFound;Certificate2")] + public void Throws_MultipleCertificateNames_Store_KeyNotFound(string certificateNames) + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "Store", + ["Certificates:Certificate1:Subject"] = "localhost", + ["Certificates:Certificate1:StoreName"] = "My", + ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["Certificates:Certificate2:Source"] = "Store", + ["Certificates:Certificate2:Subject"] = "example.com", + ["Certificates:Certificate2:StoreName"] = "Root", + ["Certificates:Certificate2:StoreLocation"] = "LocalMachine", + ["TestConfig:Certificate"] = certificateNames + }) + .Build(); + + var certificate1 = new X509Certificate2(); + var certificate2 = new X509Certificate2(); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(certificate1); + certificateStoreLoader + .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) + .Returns(certificate2); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + Mock.Of(), + certificateStoreLoader.Object); + + var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); + Assert.Equal("No certificate named NotFound found in configuration", exception.Message); + } + + [Theory] + [InlineData("Certificate1;Certificate2", 1)] + [InlineData("Certificate2;Certificate1", 1)] + [InlineData("Certificate1;Certificate2;Certificate3", 1)] + [InlineData("Certificate2;Certificate3", 0)] + [InlineData("Certificate2;Certificate3;Certificate1", 1)] + public void ReturnsNull_MultipleCertificateNames_Store_NotFoundInStore(string certificateNames, int expectedFoundCertificates) + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "Store", + ["Certificates:Certificate1:Subject"] = "localhost", + ["Certificates:Certificate1:StoreName"] = "My", + ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["Certificates:Certificate2:Source"] = "Store", + ["Certificates:Certificate2:Subject"] = "example.com", + ["Certificates:Certificate2:StoreName"] = "Root", + ["Certificates:Certificate2:StoreLocation"] = "LocalMachine", + ["Certificates:Certificate3:Source"] = "Store", + ["Certificates:Certificate3:Subject"] = "notfound.com", + ["Certificates:Certificate3:StoreName"] = "Root", + ["Certificates:Certificate3:StoreLocation"] = "LocalMachine", + ["TestConfig:Certificate"] = certificateNames + }) + .Build(); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(new X509Certificate2()); + certificateStoreLoader + .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) + .Returns(null); + certificateStoreLoader + .Setup(loader => loader.Load("notfound.com", "Root", StoreLocation.LocalMachine, It.IsAny())) + .Returns(null); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + Mock.Of(), + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(expectedFoundCertificates, loadedCertificates.Count()); + } + + [Fact] + public void Loads_MultipleCertificateNames_FileAndStore() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["Certificates:Certificate2:Source"] = "Store", + ["Certificates:Certificate2:Subject"] = "localhost", + ["Certificates:Certificate2:StoreName"] = "My", + ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificate"] = "Certificate1;Certificate2" + }) + .Build(); + + var fileCertificate = new X509Certificate2(); + var storeCertificate = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(fileCertificate); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(storeCertificate); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(2, loadedCertificates.Count()); + Assert.Same(fileCertificate, loadedCertificates.ElementAt(0)); + Assert.Same(storeCertificate, loadedCertificates.ElementAt(1)); + certificateFileLoader.VerifyAll(); + certificateStoreLoader.VerifyAll(); + } + + [Theory] + [InlineData("Certificate1;Certificate2;NotFound")] + [InlineData("Certificate1;NotFound;Certificate2")] + [InlineData("NotFound;Certificate1;Certificate2")] + public void Throws_MultipleCertificateNames_FileAndStore_KeyNotFound(string certificateNames) + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["Certificates:Certificate2:Source"] = "Store", + ["Certificates:Certificate2:Subject"] = "localhost", + ["Certificates:Certificate2:StoreName"] = "My", + ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificate"] = certificateNames + }) + .Build(); + + var fileCertificate = new X509Certificate2(); + var storeCertificate = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(fileCertificate); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(storeCertificate); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + certificateStoreLoader.Object); + + var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); + Assert.Equal("No certificate named NotFound found in configuration", exception.Message); + } + + [Theory] + [InlineData("Certificate1;Certificate2")] + [InlineData("Certificate2;Certificate1")] + public void Throws_MultipleCertificateNames_FileAndStore_FileNotFound(string certificateNames) + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["Certificates:Certificate2:Source"] = "Store", + ["Certificates:Certificate2:Subject"] = "localhost", + ["Certificates:Certificate2:StoreName"] = "My", + ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificate"] = certificateNames + }) + .Build(); + + var exception = new Exception(); + var storeCertificate = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Throws(exception); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(storeCertificate); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + certificateStoreLoader.Object); + + Assert.Same(exception, Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")))); + } + + [Theory] + [InlineData("Certificate1;Certificate2")] + [InlineData("Certificate2;Certificate1")] + public void ReturnsNull_MultipleCertificateNames_FileAndStore_NotFoundInStore(string certificateNames) + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["Certificates:Certificate1:Source"] = "File", + ["Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["Certificates:Certificate1:Password"] = "Password1", + ["Certificates:Certificate2:Source"] = "Store", + ["Certificates:Certificate2:Subject"] = "localhost", + ["Certificates:Certificate2:StoreName"] = "My", + ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificate"] = "Certificate1;Certificate2" + }) + .Build(); + + var certificate = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(null); + + var certificateLoader = new CertificateLoader( + configuration.GetSection("Certificates"), + certificateFileLoader.Object, + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(1, loadedCertificates.Count()); + Assert.Same(certificate, loadedCertificates.ElementAt(0)); + certificateFileLoader.VerifyAll(); + certificateStoreLoader.VerifyAll(); + } + + [Fact] + public void Loads_SingleCertificateInline_File() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificate:Source"] = "File", + ["TestConfig:Certificate:Path"] = "Certificate1.pfx", + ["TestConfig:Certificate:Password"] = "Password1" + }) + .Build(); + + var certificate = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate); + + var certificateLoader = new CertificateLoader( + null, + certificateFileLoader.Object, + Mock.Of()); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(1, loadedCertificates.Count()); + Assert.Same(certificate, loadedCertificates.ElementAt(0)); + certificateFileLoader.VerifyAll(); + } + + [Fact] + public void Throws_SingleCertificateInline_FileNotFound() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificate:Source"] = "File", + ["TestConfig:Certificate:Path"] = "Certificate1.pfx", + ["TestConfig:Certificate:Password"] = "Password1" + }) + .Build(); + + var exception = new Exception(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Throws(exception); + + var certificateLoader = new CertificateLoader( + null, + certificateFileLoader.Object, + Mock.Of()); + + Assert.Same(exception, Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")))); + certificateFileLoader.VerifyAll(); + } + + [Fact] + public void Loads_SingleCertificateInline_Store() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificate:Source"] = "Store", + ["TestConfig:Certificate:Subject"] = "localhost", + ["TestConfig:Certificate:StoreName"] = "My", + ["TestConfig:Certificate:StoreLocation"] = "CurrentUser", + }) + .Build(); + + var certificate = new X509Certificate2(); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(certificate); + + var certificateLoader = new CertificateLoader( + null, + Mock.Of(), + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(1, loadedCertificates.Count()); + Assert.Same(certificate, loadedCertificates.ElementAt(0)); + certificateStoreLoader.VerifyAll(); + } + + [Fact] + public void ReturnsNull_SingleCertificateInline_Store_NotFoundInStore() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificate:Source"] = "Store", + ["TestConfig:Certificate:Subject"] = "localhost", + ["TestConfig:Certificate:StoreName"] = "My", + ["TestConfig:Certificate:StoreLocation"] = "CurrentUser", + }) + .Build(); + + var certificateStoreLoader = new Mock(); + + var certificateLoader = new CertificateLoader( + null, + Mock.Of(), + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); + Assert.Equal(0, loadedCertificates.Count()); + certificateStoreLoader.Verify(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())); + } + + [Fact] + public void Loads_MultipleCertificatesInline_File() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificates:Certificate1:Source"] = "File", + ["TestConfig:Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["TestConfig:Certificates:Certificate1:Password"] = "Password1", + ["TestConfig:Certificates:Certificate2:Source"] = "File", + ["TestConfig:Certificates:Certificate2:Path"] = "Certificate2.pfx", + ["TestConfig:Certificates:Certificate2:Password"] = "Password2", + }) + .Build(); + + var certificate1 = new X509Certificate2(); + var certificate2 = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate1); + certificateFileLoader + .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) + .Returns(certificate2); + + var certificateLoader = new CertificateLoader( + null, + certificateFileLoader.Object, + Mock.Of()); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); + Assert.Equal(2, loadedCertificates.Count()); + Assert.Same(certificate1, loadedCertificates.ElementAt(0)); + Assert.Same(certificate2, loadedCertificates.ElementAt(1)); + certificateFileLoader.VerifyAll(); + } + + [Fact] + public void Throws_MultipleCertificatesInline_File_FileNotFound() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificates:Certificate1:Source"] = "File", + ["TestConfig:Certificates:Certificate1:Path"] = "Certificate1.pfx", + ["TestConfig:Certificates:Certificate1:Password"] = "Password1", + ["TestConfig:Certificates:Certificate2:Source"] = "File", + ["TestConfig:Certificates:Certificate2:Path"] = "Certificate2.pfx", + ["TestConfig:Certificates:Certificate2:Password"] = "Password2", + }) + .Build(); + + var certificate1 = new X509Certificate2(); + var exception = new Exception(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate1); + certificateFileLoader + .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) + .Throws(exception); + + var certificateLoader = new CertificateLoader( + null, + certificateFileLoader.Object, + Mock.Of()); + + Assert.Same(exception, Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")))); + } + + [Fact] + public void Loads_MultipleCertificatesInline_Store() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificates:Certificate1:Source"] = "Store", + ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", + ["TestConfig:Certificates:Certificate1:StoreName"] = "My", + ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificates:Certificate2:Source"] = "Store", + ["TestConfig:Certificates:Certificate2:Subject"] = "example.com", + ["TestConfig:Certificates:Certificate2:StoreName"] = "Root", + ["TestConfig:Certificates:Certificate2:StoreLocation"] = "LocalMachine" + }) + .Build(); + + var certificate1 = new X509Certificate2(); + var certificate2 = new X509Certificate2(); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(certificate1); + certificateStoreLoader + .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) + .Returns(certificate2); + + var certificateLoader = new CertificateLoader( + null, + Mock.Of(), + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); + Assert.Equal(2, loadedCertificates.Count()); + Assert.Same(certificate1, loadedCertificates.ElementAt(0)); + Assert.Same(certificate2, loadedCertificates.ElementAt(1)); + certificateStoreLoader.VerifyAll(); + } + + [Fact] + public void ReturnsNull_MultipleCertificatesInline_Store_NotFoundInStore() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificates:Certificate1:Source"] = "Store", + ["TestConfig:Certificates:Certificate1:Subject"] = "notfound.com", + ["TestConfig:Certificates:Certificate1:StoreName"] = "Root", + ["TestConfig:Certificates:Certificate1:StoreLocation"] = "LocalMachine", + ["TestConfig:Certificates:Certificate2:Source"] = "Store", + ["TestConfig:Certificates:Certificate2:Subject"] = "localhost", + ["TestConfig:Certificates:Certificate2:StoreName"] = "My", + ["TestConfig:Certificates:Certificate2:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificates:Certificate3:Source"] = "Store", + ["TestConfig:Certificates:Certificate3:Subject"] = "example.com", + ["TestConfig:Certificates:Certificate3:StoreName"] = "Root", + ["TestConfig:Certificates:Certificate3:StoreLocation"] = "LocalMachine" + }) + .Build(); + + var certificate = new X509Certificate2(); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(certificate); + + var certificateLoader = new CertificateLoader( + null, + Mock.Of(), + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); + Assert.Equal(1, loadedCertificates.Count()); + Assert.Same(certificate, loadedCertificates.ElementAt(0)); + certificateStoreLoader.Verify(loader => loader.Load("notfound.com", "Root", StoreLocation.LocalMachine, It.IsAny())); + certificateStoreLoader.Verify(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())); + certificateStoreLoader.Verify(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())); + } + + [Fact] + public void Loads_MultipleCertificatesInline_FileAndStore() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificates:Certificate1:Source"] = "Store", + ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", + ["TestConfig:Certificates:Certificate1:StoreName"] = "My", + ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificates:Certificate2:Source"] = "File", + ["TestConfig:Certificates:Certificate2:Path"] = "Certificate1.pfx", + ["TestConfig:Certificates:Certificate2:Password"] = "Password1", + ["TestConfig:Certificates:Certificate3:Source"] = "Store", + ["TestConfig:Certificates:Certificate3:Subject"] = "example.com", + ["TestConfig:Certificates:Certificate3:StoreName"] = "Root", + ["TestConfig:Certificates:Certificate3:StoreLocation"] = "LocalMachine", + ["TestConfig:Certificates:Certificate4:Source"] = "File", + ["TestConfig:Certificates:Certificate4:Path"] = "Certificate2.pfx", + ["TestConfig:Certificates:Certificate4:Password"] = "Password2", + }) + .Build(); + + var fileCertificate1 = new X509Certificate2(); + var fileCertificate2 = new X509Certificate2(); + var storeCertificate1 = new X509Certificate2(); + var storeCertificate2 = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(fileCertificate1); + certificateFileLoader + .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) + .Returns(fileCertificate2); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(storeCertificate1); + certificateStoreLoader + .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) + .Returns(storeCertificate2); + + var certificateLoader = new CertificateLoader( + null, + certificateFileLoader.Object, + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); + Assert.Equal(4, loadedCertificates.Count()); + Assert.Same(storeCertificate1, loadedCertificates.ElementAt(0)); + Assert.Same(fileCertificate1, loadedCertificates.ElementAt(1)); + Assert.Same(storeCertificate2, loadedCertificates.ElementAt(2)); + Assert.Same(fileCertificate2, loadedCertificates.ElementAt(3)); + certificateStoreLoader.VerifyAll(); + } + + [Fact] + public void Throws_MultipleCertificatesInline_FileAndStore_FileNotFound() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificates:Certificate1:Source"] = "Store", + ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", + ["TestConfig:Certificates:Certificate1:StoreName"] = "My", + ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificates:Certificate2:Source"] = "File", + ["TestConfig:Certificates:Certificate2:Path"] = "Certificate1.pfx", + ["TestConfig:Certificates:Certificate2:Password"] = "Password1", + }) + .Build(); + + var exception = new Exception(); + var certificate = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Throws(exception); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(certificate); + + var certificateLoader = new CertificateLoader( + null, + certificateFileLoader.Object, + certificateStoreLoader.Object); + + Assert.Same(exception, Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")))); + } + + [Fact] + public void ReturnsNull_MultipleCertificatesInline_FileAndStore_NotFoundInStore() + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary + { + ["TestConfig:Certificates:Certificate1:Source"] = "Store", + ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", + ["TestConfig:Certificates:Certificate1:StoreName"] = "My", + ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", + ["TestConfig:Certificates:Certificate2:Source"] = "File", + ["TestConfig:Certificates:Certificate2:Path"] = "Certificate1.pfx", + ["TestConfig:Certificates:Certificate2:Password"] = "Password1", + }) + .Build(); + + var certificate = new X509Certificate2(); + + var certificateFileLoader = new Mock(); + certificateFileLoader + .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) + .Returns(certificate); + + var certificateStoreLoader = new Mock(); + certificateStoreLoader + .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) + .Returns(null); + + var certificateLoader = new CertificateLoader( + null, + certificateFileLoader.Object, + certificateStoreLoader.Object); + + var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); + Assert.Equal(1, loadedCertificates.Count()); + Assert.Same(certificate, loadedCertificates.ElementAt(0)); + } + } +} diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index a4676dcc7f..13d57e6616 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -7,7 +7,7 @@ - + @@ -17,6 +17,7 @@ + diff --git a/test/Microsoft.AspNetCore.FunctionalTests/TestArtifacts/Certificate.pfx b/test/Microsoft.AspNetCore.FunctionalTests/TestArtifacts/Certificate.pfx new file mode 100644 index 0000000000000000000000000000000000000000..c792c522488adf723e6f37b354a9f4178dedf98d GIT binary patch literal 2461 zcmV;O31apzf(e-d0Ru3C310>YDuzgg_YDCD0ic2jPy~VrOfZ58NHBr}{{{&vhDe6@ z4FLxRpn?PNFoFZ@0s#Opf&=9S2`Yw2hW8Bt2LUh~1_~;MNQUCLhc?KpZ79UX((b9gtz3l$ShHTW^w(4j=OB4)=~cBICF-(;4ox6qbLYN7}GC8?wNZs!fw~MG~CeO>3{q`?$!YE&|TW)7%ltY`g`J(4!EA+0qG<5f-@An+sS2s zyKPh^XzQo6k{=!X&J>f&qlC6rk8nC2#J1jlBp_18$8vKh-U$SOlzOIq)FBRBa&tg` zR?M@NvBD)UfX4@ypWaR=ez3Y(XT=|lyg$RizAl06K8 zr#J2k1>y5RV4K1`d870`A3QB{3^91xcGGJjnA z?o&nSF>%B)m;bj~^X${eq1{=%dD7bv41prq(x@sC@C{Ux|CklhNTJsPwbdHcnU6aO z_MGTcs3e!*5A|F5ucqU|`7#}Z*Khdo>V`x1Uo*CTvKwpEx#qsTud0(OiO61wr zWsY)LxoLde@Ttox)W3{NslcIT{a`vbL7X6WFHg+d7${@_O!$w4$&u67int_=`alI=5ZenfB@%ode@Q;fL^<;&t0j74IM#t*%O&Eb#E zO3Q0JLna^Ynq)c|cy-Ob09lVVleD}Lc6330Fpna<#uA`2$#oKNgzXM0hIDWxb(s$V z=mM&<1Vvca4{@Gq&+gV^)-i68+iSlE)4C9T6{pXBVY49f&hbPcQJn0EC!Fh`F_y+b z8JRS!vsd+UUsgd_z02z(#_2S|4Opb0xM2A#FoFd^1_>&LNQU<1f~E*r4=p<8OP?$r5q@pf%h z&EDD8e?4ydKLhh0X1jw|iGk*vgA=^gX0p1AZNR#zCAo>PbBd8-BIOL%BFE;!g*H$B z+%|ma9v2wNKO`Lk-c@XG95iEwCmv=hC0hfNaJ5Y?Vzl4P_ACkn6A6(*Xt)~gr24?& zc+?9X2d*291gesBlP(J`eTUNdobKwi*3?i~M`)ta3fK@;q{PEK+IrL7J&qIj20hwK z=FjLbo?5-}nuEo?0O*EM;WroV6@Y;9(0u=E0oZAnYKUmZgO@*BlUf&!yrg|^ZnYQS zWi0?G-9lB32QH2trNhMsRKwW8rzbJjF~4~>BJmD-z4*Ji`w!)TEIh(gI>dnMN`R$Z z=Jikm=|Vhkte489k2e;D)Mg|#af_PODc_GM$G;+R^1ik|-HCl-JgeBtM+o5lF|Di9xq1Z@Wssz@fb zbPnrus>$DBXV7xnJ^E#mF2Lg}$J%^TNrn2?I(t>5fuj^+cY|SyN8kR5EF23+oZTj1 z%$vAm>Ub#v)EGLri#9f_hQ_f2!3bDH)r&Jn${QBL?(7GS(_D`PTw67D>K*P2w4Q_&JRoj>7m zaA93;0I>mecVE^YkUui2b^mZQYw
=S3wwEn5^#$v~O)z)+%fl)_B{=vHjXvs{( zy@6^1ky#X!=Zw<(^`EROArA_6(b|7TC=s=GKFsVpF)PM*r(PTw&lG0&x0Io%!U9;2 zj=jihQxIh2UeSG6S6;zp+6D@@%7}M0&G{8oj}eIoFaW(cX}X(GB;Yqp2oNC;js&>K z4!MD=3=^sWTzc;ZOTmMxdB~e+wFY(hV*xIg)EC;wsZ`%SkjAUb@p2GYltVU5Ttp*T z(tN%{T<*Po);<(6l9pKk*YlK@3HVebh|1Js+1m~5UKrYT>M%KIi~nwzO{^ybk#t*r zNHqrglnI(D8rfWhnHTqMP8URj$C@;Qkk-JZ?!hcI;l{vNH9t+iV;tU}1irx}EWzGn zOf)IR=b-k6fsXnc*VTCl@&%|PujOc*)#Ii{f5SuZ-iR#-b2pc=YG2>2FDZ`JQ0=KS z;ZfPMXPehqQ>l~pxKFs91$jFd6km}OdnDGgAq4W!CMv_%kJO8i?vwn_V4kLz?&j|7 zi}in{dI)eyF*ULRbHg&bPFRx#AI%8;3jw~+y|_AIZ$(m2xa~0|Fe3&DDuzgg_YDCF z6)_eB6ng)VNS~j_hgq$}Xf4Qu|9}4v;V>~UAutIB1uG5%0vZJX1Qd*Ji=f=R`J3~d bWr6|Fzx*IOqG<#OPZEU6;7((40s;sCZpw)y literal 0 HcmV?d00001 diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index 43be04f16e..00e1fbfba6 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -134,8 +134,7 @@ namespace Microsoft.AspNetCore.Tests ""Certificates"": { ""TestCert"": { ""Source"": ""File"", - ""Path"": ""testCert.pfx"", - ""Password"": ""testPassword"" + ""Path"": ""TestArtifacts/Certificate.pfx"" } } } @@ -173,8 +172,7 @@ namespace Microsoft.AspNetCore.Tests ""Port"": 0, ""Certificate"": { ""Source"": ""File"", - ""Path"": ""testCert.pfx"", - ""Password"": ""testPassword"" + ""Path"": ""TestArtifacts/Certificate.pfx"", } } } diff --git a/test/TestArtifacts/testCert.pfx b/test/TestArtifacts/testCert.pfx deleted file mode 100644 index 7118908c2d730670c16e9f8b2c532a262c951989..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b From b3b986bfa9a567e24df7267f10690a95b9493942 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 1 May 2017 12:39:48 -0700 Subject: [PATCH 114/361] Use the bundled NETStandard.Library package in netstandard targeting libraries --- build/dependencies.props | 1 + src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/build/dependencies.props b/build/dependencies.props index e532f8a25d..5e98aa7fa1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,6 +6,7 @@ 4.3.0 2.0.0-* 4.7.1 + $(BundledNETStandardPackageVersion) 10.0.1 15.0.0 2.2.0 diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index bfc4256bf3..c003ee5ef0 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -8,6 +8,7 @@ aspnetcore Microsoft.AspNetCore.All false + $(PackageTargetFallback);portable-net45+win8+wp8+wpa81 From ddd96887dab5f1af1016fc2c3f7f4bcfbd7a05a5 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 1 May 2017 21:41:29 -0700 Subject: [PATCH 115/361] Minimal restore when building deps files --- build/repo.targets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index bf1dd5f259..2c09d54d90 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -37,7 +37,7 @@ Condition="Exists('$(DependencyBuildDirectory)')" /> - + @@ -59,6 +59,7 @@ + From dc44c1f12326e1d25b371b3363ed94e386104035 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 2 May 2017 14:28:22 -0700 Subject: [PATCH 116/361] Use win7-x64/x86 rids for runtime store --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 2c09d54d90..95aafd08ea 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -47,7 +47,7 @@ win$(PACKAGE_CACHE_PLATFORM) linux osx - win-$(PACKAGE_CACHE_PLATFORM) + win7-$(PACKAGE_CACHE_PLATFORM) linux-$(PACKAGE_CACHE_PLATFORM) osx-$(PACKAGE_CACHE_PLATFORM) From fbd3d9438a5b417d1fb71a1b51c975acde826555 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Wed, 3 May 2017 11:44:29 -0700 Subject: [PATCH 117/361] Store sample app's certificate passwords in user secrets. --- samples/AppSettings/AppSettings.csproj | 2 -- samples/AppSettings/appsettings.json | 4 ---- 2 files changed, 6 deletions(-) diff --git a/samples/AppSettings/AppSettings.csproj b/samples/AppSettings/AppSettings.csproj index bf6be606f3..621da3c9ca 100644 --- a/samples/AppSettings/AppSettings.csproj +++ b/samples/AppSettings/AppSettings.csproj @@ -16,10 +16,8 @@ - diff --git a/samples/AppSettings/appsettings.json b/samples/AppSettings/appsettings.json index fac810ec12..ab315a0242 100644 --- a/samples/AppSettings/appsettings.json +++ b/samples/AppSettings/appsettings.json @@ -27,8 +27,6 @@ "Certificate": { "Source": "File", "Path": "testCert.pfx", - // TODO: remove when dotnet user-secrets is working again - "Password": "testPassword" } }, // Add testCert.pfx to the current user's certificate store to enable this scenario. @@ -48,8 +46,6 @@ "TestCert": { "Source": "File", "Path": "testCert.pfx", - // TODO: remove when dotnet user-secrets is working again - "Password": "testPassword" }, // Add testCert.pfx to the current user's certificate store to enable this scenario. //"TestCertInStore": { From 634c9c180cc588fe6f1f40aeac3b680f5c5a2793 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Wed, 3 May 2017 11:48:37 -0700 Subject: [PATCH 118/361] Fix HTTPS functional tests on macOS (#96). --- .../HttpClientSlim.cs | 130 ++++++++++++++++++ ...icrosoft.AspNetCore.FunctionalTests.csproj | 2 +- .../TestArtifacts/Certificate.pfx | Bin 2461 -> 0 bytes .../WebHostFunctionalTests.cs | 25 ++-- .../testCert.pfx | Bin 0 -> 2483 bytes 5 files changed, 140 insertions(+), 17 deletions(-) create mode 100644 test/Microsoft.AspNetCore.FunctionalTests/HttpClientSlim.cs delete mode 100644 test/Microsoft.AspNetCore.FunctionalTests/TestArtifacts/Certificate.pfx create mode 100644 test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx diff --git a/test/Microsoft.AspNetCore.FunctionalTests/HttpClientSlim.cs b/test/Microsoft.AspNetCore.FunctionalTests/HttpClientSlim.cs new file mode 100644 index 0000000000..a85b03aa40 --- /dev/null +++ b/test/Microsoft.AspNetCore.FunctionalTests/HttpClientSlim.cs @@ -0,0 +1,130 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Security; +using System.Net.Sockets; +using System.Security.Authentication; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Testing +{ + // Lightweight version of HttpClient implemented using Socket and SslStream + public static class HttpClientSlim + { + public static async Task GetStringAsync(string requestUri, bool validateCertificate = true) + => await GetStringAsync(new Uri(requestUri), validateCertificate).ConfigureAwait(false); + + public static async Task GetStringAsync(Uri requestUri, bool validateCertificate = true) + { + using (var stream = await GetStream(requestUri, validateCertificate).ConfigureAwait(false)) + { + using (var writer = new StreamWriter(stream, Encoding.ASCII, bufferSize: 1024, leaveOpen: true)) + { + await writer.WriteAsync($"GET {requestUri.PathAndQuery} HTTP/1.0\r\n").ConfigureAwait(false); + await writer.WriteAsync($"Host: {requestUri.Authority}\r\n").ConfigureAwait(false); + await writer.WriteAsync("\r\n").ConfigureAwait(false); + } + + return await ReadResponse(stream).ConfigureAwait(false); + } + } + + public static async Task PostAsync(string requestUri, HttpContent content, bool validateCertificate = true) + => await PostAsync(new Uri(requestUri), content, validateCertificate).ConfigureAwait(false); + + public static async Task PostAsync(Uri requestUri, HttpContent content, bool validateCertificate = true) + { + using (var stream = await GetStream(requestUri, validateCertificate)) + { + using (var writer = new StreamWriter(stream, Encoding.ASCII, bufferSize: 1024, leaveOpen: true)) + { + await writer.WriteAsync($"POST {requestUri.PathAndQuery} HTTP/1.0\r\n").ConfigureAwait(false); + await writer.WriteAsync($"Host: {requestUri.Authority}\r\n").ConfigureAwait(false); + await writer.WriteAsync($"Content-Type: {content.Headers.ContentType}\r\n").ConfigureAwait(false); + await writer.WriteAsync($"Content-Length: {content.Headers.ContentLength}\r\n").ConfigureAwait(false); + await writer.WriteAsync("\r\n").ConfigureAwait(false); + } + + await content.CopyToAsync(stream).ConfigureAwait(false); + + return await ReadResponse(stream).ConfigureAwait(false); + } + } + + private static async Task ReadResponse(Stream stream) + { + using (var reader = new StreamReader(stream, Encoding.ASCII, detectEncodingFromByteOrderMarks: true, + bufferSize: 1024, leaveOpen: true)) + { + var response = await reader.ReadToEndAsync().ConfigureAwait(false); + + var status = GetStatus(response); + new HttpResponseMessage(status).EnsureSuccessStatusCode(); + + var body = response.Substring(response.IndexOf("\r\n\r\n") + 4); + return body; + } + + } + + private static HttpStatusCode GetStatus(string response) + { + var statusStart = response.IndexOf(' ') + 1; + var statusEnd = response.IndexOf(' ', statusStart) - 1; + var statusLength = statusEnd - statusStart + 1; + return (HttpStatusCode)int.Parse(response.Substring(statusStart, statusLength)); + } + + private static async Task GetStream(Uri requestUri, bool validateCertificate) + { + var socket = await GetSocket(requestUri); + var stream = new NetworkStream(socket, ownsSocket: true); + + if (requestUri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) + { + var sslStream = new SslStream(stream, leaveInnerStreamOpen: false, userCertificateValidationCallback: + validateCertificate ? null : (RemoteCertificateValidationCallback)((a, b, c, d) => true)); + + await sslStream.AuthenticateAsClientAsync(requestUri.Host, clientCertificates: null, + enabledSslProtocols: SslProtocols.Tls11 | SslProtocols.Tls12, + checkCertificateRevocation: validateCertificate).ConfigureAwait(false); + return sslStream; + } + else + { + return stream; + } + } + + public static async Task GetSocket(Uri requestUri) + { + var tcs = new TaskCompletionSource(); + + var socketArgs = new SocketAsyncEventArgs(); + socketArgs.RemoteEndPoint = new DnsEndPoint(requestUri.DnsSafeHost, requestUri.Port); + socketArgs.Completed += (s, e) => tcs.TrySetResult(e.ConnectSocket); + + // Must use static ConnectAsync(), since instance Connect() does not support DNS names on OSX/Linux. + if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, socketArgs)) + { + await tcs.Task.ConfigureAwait(false); + } + + var socket = socketArgs.ConnectSocket; + + if (socket == null) + { + throw new SocketException((int)socketArgs.SocketError); + } + else + { + return socket; + } + } + } +} diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index 13d57e6616..e2596080ea 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -7,7 +7,7 @@ - + diff --git a/test/Microsoft.AspNetCore.FunctionalTests/TestArtifacts/Certificate.pfx b/test/Microsoft.AspNetCore.FunctionalTests/TestArtifacts/Certificate.pfx deleted file mode 100644 index c792c522488adf723e6f37b354a9f4178dedf98d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2461 zcmV;O31apzf(e-d0Ru3C310>YDuzgg_YDCD0ic2jPy~VrOfZ58NHBr}{{{&vhDe6@ z4FLxRpn?PNFoFZ@0s#Opf&=9S2`Yw2hW8Bt2LUh~1_~;MNQUCLhc?KpZ79UX((b9gtz3l$ShHTW^w(4j=OB4)=~cBICF-(;4ox6qbLYN7}GC8?wNZs!fw~MG~CeO>3{q`?$!YE&|TW)7%ltY`g`J(4!EA+0qG<5f-@An+sS2s zyKPh^XzQo6k{=!X&J>f&qlC6rk8nC2#J1jlBp_18$8vKh-U$SOlzOIq)FBRBa&tg` zR?M@NvBD)UfX4@ypWaR=ez3Y(XT=|lyg$RizAl06K8 zr#J2k1>y5RV4K1`d870`A3QB{3^91xcGGJjnA z?o&nSF>%B)m;bj~^X${eq1{=%dD7bv41prq(x@sC@C{Ux|CklhNTJsPwbdHcnU6aO z_MGTcs3e!*5A|F5ucqU|`7#}Z*Khdo>V`x1Uo*CTvKwpEx#qsTud0(OiO61wr zWsY)LxoLde@Ttox)W3{NslcIT{a`vbL7X6WFHg+d7${@_O!$w4$&u67int_=`alI=5ZenfB@%ode@Q;fL^<;&t0j74IM#t*%O&Eb#E zO3Q0JLna^Ynq)c|cy-Ob09lVVleD}Lc6330Fpna<#uA`2$#oKNgzXM0hIDWxb(s$V z=mM&<1Vvca4{@Gq&+gV^)-i68+iSlE)4C9T6{pXBVY49f&hbPcQJn0EC!Fh`F_y+b z8JRS!vsd+UUsgd_z02z(#_2S|4Opb0xM2A#FoFd^1_>&LNQU<1f~E*r4=p<8OP?$r5q@pf%h z&EDD8e?4ydKLhh0X1jw|iGk*vgA=^gX0p1AZNR#zCAo>PbBd8-BIOL%BFE;!g*H$B z+%|ma9v2wNKO`Lk-c@XG95iEwCmv=hC0hfNaJ5Y?Vzl4P_ACkn6A6(*Xt)~gr24?& zc+?9X2d*291gesBlP(J`eTUNdobKwi*3?i~M`)ta3fK@;q{PEK+IrL7J&qIj20hwK z=FjLbo?5-}nuEo?0O*EM;WroV6@Y;9(0u=E0oZAnYKUmZgO@*BlUf&!yrg|^ZnYQS zWi0?G-9lB32QH2trNhMsRKwW8rzbJjF~4~>BJmD-z4*Ji`w!)TEIh(gI>dnMN`R$Z z=Jikm=|Vhkte489k2e;D)Mg|#af_PODc_GM$G;+R^1ik|-HCl-JgeBtM+o5lF|Di9xq1Z@Wssz@fb zbPnrus>$DBXV7xnJ^E#mF2Lg}$J%^TNrn2?I(t>5fuj^+cY|SyN8kR5EF23+oZTj1 z%$vAm>Ub#v)EGLri#9f_hQ_f2!3bDH)r&Jn${QBL?(7GS(_D`PTw67D>K*P2w4Q_&JRoj>7m zaA93;0I>mecVE^YkUui2b^mZQYw
=S3wwEn5^#$v~O)z)+%fl)_B{=vHjXvs{( zy@6^1ky#X!=Zw<(^`EROArA_6(b|7TC=s=GKFsVpF)PM*r(PTw&lG0&x0Io%!U9;2 zj=jihQxIh2UeSG6S6;zp+6D@@%7}M0&G{8oj}eIoFaW(cX}X(GB;Yqp2oNC;js&>K z4!MD=3=^sWTzc;ZOTmMxdB~e+wFY(hV*xIg)EC;wsZ`%SkjAUb@p2GYltVU5Ttp*T z(tN%{T<*Po);<(6l9pKk*YlK@3HVebh|1Js+1m~5UKrYT>M%KIi~nwzO{^ybk#t*r zNHqrglnI(D8rfWhnHTqMP8URj$C@;Qkk-JZ?!hcI;l{vNH9t+iV;tU}1irx}EWzGn zOf)IR=b-k6fsXnc*VTCl@&%|PujOc*)#Ii{f5SuZ-iR#-b2pc=YG2>2FDZ`JQ0=KS z;ZfPMXPehqQ>l~pxKFs91$jFd6km}OdnDGgAq4W!CMv_%kJO8i?vwn_V4kLz?&j|7 zi}in{dI)eyF*ULRbHg&bPFRx#AI%8;3jw~+y|_AIZ$(m2xa~0|Fe3&DDuzgg_YDCF z6)_eB6ng)VNS~j_hgq$}Xf4Qu|9}4v;V>~UAutIB1uG5%0vZJX1Qd*Ji=f=R`J3~d bWr6|Fzx*IOqG<#OPZEU6;7((40s;sCZpw)y diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index 00e1fbfba6..fa24b34684 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; using Xunit; @@ -134,7 +135,8 @@ namespace Microsoft.AspNetCore.Tests ""Certificates"": { ""TestCert"": { ""Source"": ""File"", - ""Path"": ""TestArtifacts/Certificate.pfx"" + ""Path"": ""testCert.pfx"", + ""Password"": ""testPassword"" } } } @@ -143,13 +145,8 @@ namespace Microsoft.AspNetCore.Tests { var port = GetWebHostPort(webHost); - Assert.NotEqual(0, port); - - using (var client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = (msg, cert, chain, errors) => true })) - { - var response = await client.GetAsync($"https://127.0.0.1:{port}"); - response.EnsureSuccessStatusCode(); - } + var response = await HttpClientSlim.GetStringAsync($"https://127.0.0.1:{port}", validateCertificate: false); + Assert.Equal("Hello, World!", response); } } finally @@ -172,7 +169,8 @@ namespace Microsoft.AspNetCore.Tests ""Port"": 0, ""Certificate"": { ""Source"": ""File"", - ""Path"": ""TestArtifacts/Certificate.pfx"", + ""Path"": ""testCert.pfx"", + ""Password"": ""testPassword"" } } } @@ -183,13 +181,8 @@ namespace Microsoft.AspNetCore.Tests { var port = GetWebHostPort(webHost); - Assert.NotEqual(0, port); - - using (var client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = (msg, cert, chain, errors) => true })) - { - var response = await client.GetAsync($"https://127.0.0.1:{port}"); - response.EnsureSuccessStatusCode(); - } + var response = await HttpClientSlim.GetStringAsync($"https://127.0.0.1:{port}", validateCertificate: false); + Assert.Equal("Hello, World!", response); } } finally diff --git a/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx b/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..7118908c2d730670c16e9f8b2c532a262c951989 GIT binary patch literal 2483 zcmaKuc|27A8pqF>IWr86E&Q@(n=B)p$ug!;QVB6xij*z;uPLG!yCz#DQB)+9G$9m9 zQU)=DWXU?*EZIwG!+0d++P@yZ4Xhoagg?p6B~|Ue7tN=Ny=UD?x#1n1MTq z#c9MHh+D#gd|(a(cN}8i91v^=GcdgW3SmA$49p~gM-dys3jVWdg8+!iVL)pz1LDE5 zSb=|GAn(@R=(Ux!MfS9@}sFu-xDd zIt2+mqSq$glwy_6UNs<2?(qERU!gJ;5j}Pp&6trxG=wi)=@k(w2+fJVnc+qvXVzy(>Om4;L|^)R`t*3nTpAmEmTl(#i!RV#a0t#u6>Q9mY`-Nmcs7$XjXT7 zUmCD`O~_j7!%R#I?cG-7C^hcH)@l?WC1vyw$FFu_(r)jhOq6p}W8sG7NO{YTy8tG4 zrb$tTkag*G?(7lfoGx$4YWui>{{@}-FB2ub=}RX{1zx?j)s-##J9|G7E1@-;7Nuln z9MQoX7FJ76+D#XXT@ZZmLZCufIdf3@OigG6m8I7!GT=7VD|>?6e!z9=eT}*E_tSn6 zl+clHCZ-kcIR#gen#LjMJW8>0QtViaQB#FhqsCb0YPYr3;jRITl@V9Aph24D?r2d` zetCyyCg<*O-u+M& zW^ptmT|}p$VAOZpmbQ1{5fK-6ytEvre#Po}6c2URn`viQAF2+e?Z~PK2&pd>7=7)I zTCYm)@3PFRu_6a6Kb)IpCzQ%e3l%O#SDA+$Pq{Dk{HCqi7z>qd{nVpebffL7h{c4( zmhXn~G+C27S3(IfC)q2KON=YwqHXEo%zc40DgWLzF{%RIdr@RcLu90qMSHf!Y}JaqP<={8_Rfe;ddR5= zKEo;^Yip&^m((#{czE{kUga3-@`*;&EwO}Jt>QdURP2P>ob^j-A!qld-0S_pm)kjs zkNo48oZnMt){W~o8g^f;4#?lRLr-T@f}wH1o~-Iq=NEVtTVEZ`vrW~!>2yh%;Bc~H zHl&OK>n@d`*e19*9#v>zZpU?I);f7}IPIfSSk#N|ujE492Itg)l!)TJ19@FE^x|p= zH16NC7OfK&|6_!AnWfTIf^YPOa&`|nbk3VR0vql6&s@y1V3QOU%(`Re+kJgrz?r9!{^wOQ4W-eng23gc}f(LxIs zH_Ls~5izbjcRQH#WH6s6hR;zn>j_R8aJ$A)6xNneu8UI-vWV8Z@HZu&WwvG5q{1ZS zdZeVf{Pv5-u281~y;aJe*x%Uv0@biMZ$vPbKj}O`(SOWQc~kJX` zXR&d4DtAe@2RH$^ z0os5*;0eIUeJi3Uh`A%44x(XzjClG8BO~-r_A}odiRuHo2-86#`mhrgN5p~<$RLY? zq(kynfFA5{v#p+EA1 z5aoe1763EQHorRm`C&ktKn(OQ1n)$Q{GZz&jRb`eDEMpl<0O#+)DMV(T7nsIzCG{QuM->B9g7Lrl2SE&gW`M!~(un|y0fIn=b^6_$ z9{zEzgYI~39xn0ZP*9qBL%fg7rg$ttt&TOmvfNNO<6FT0ZavM$Y4CYLQGIcIYv9Y& zBGPUh&QTfW;V2!)oIra@s&d968y-y}Y|ww(R$GzWS*V&)k@W0>Slem{|HdTCjm;_5 zwY*A8W3nUbemE^_f0ng$tbd<`sr?TO-_&VCw+F#7P@LkIl$1PzTBoPY1b88EIO>UO zP-NK7+g2yD3U6g3i|iA6+su>54sf_Sk0F=)1|9odnCM4u2Rs z=&Y?-V&VquSN%3FJ2~ZGweP~iLs|w=l@9yu$tj@}Dp?e-2JUsqOoswdXb=E%&0te_ zA2M+{5Hf-dqD7=yw*r@A*xkn(1IS~nfP}k}e?4Bt|9g(eph4hFX_|S6nj1&Sz9z^= zRw~<&-9d@FzTn6S*RVE{Wj5lgLJr9HLB8S9CgOm*>XA8*y4`JE;^s$=bqD#U4;e5C&x&ggKIAVL zrQ)Yd8|{>7Z(6*B&7&4&9(*vDOfHMuR-Dk1IZia*XM^EZUD^{?cWG>J>KrtElc*{K zaVl(7SN2cH4I6Q$bZOpJ8e5LKaG7p;?tJ~#+9QrTYU@f#5`Vo7cEX!szCT}iX-K^2 w#3o+=C+lQz2J+SOEzVX(eJ)e7=eicC{rr9U2VGDcdH?_b literal 0 HcmV?d00001 From ebdc68ac10d980a960c3e07037f879f3fde8792b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 3 May 2017 11:15:46 -0700 Subject: [PATCH 119/361] Exclude SQLitePCl.bundle_green targets when reference included via the Microsoft.AspNetCore.All metapackage --- build/common.props | 2 ++ build/dependencies.props | 1 + src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build/common.props b/build/common.props index 23cc402e92..c10a7c58f5 100644 --- a/build/common.props +++ b/build/common.props @@ -127,6 +127,8 @@ + + diff --git a/build/dependencies.props b/build/dependencies.props index 5e98aa7fa1..ad3e8345e7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,6 +8,7 @@ 4.7.1 $(BundledNETStandardPackageVersion) 10.0.1 + 1.1.5 15.0.0 2.2.0 diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index c003ee5ef0..a6e47077d0 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -14,7 +14,7 @@ - + From c0f86d5687a8ef253152be98f5b8ed1ba63cbffe Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 3 May 2017 11:31:54 -0700 Subject: [PATCH 120/361] Use ItemDefinitionGroup to simplify the list of packages. See https://docs.microsoft.com/en-us/visualstudio/msbuild/item-definitions --- build/common.props | 332 ++++++++++-------- .../Microsoft.AspNetCore.All.csproj | 2 +- 2 files changed, 181 insertions(+), 153 deletions(-) diff --git a/build/common.props b/build/common.props index 23cc402e92..8fef632523 100644 --- a/build/common.props +++ b/build/common.props @@ -26,159 +26,187 @@ - + + - - - - - - - - - - - - - - - + + $(AspNetCoreVersion) + None + + + $(AspNetCoreVersion) + None + + + $(AspNetCoreVersion) + None + + + $(AspNetCoreVersion) + None + + + None + + + + $(AspNetCoreVersion) + All + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + @@ -186,17 +214,17 @@ - - + + - - - - - + + + + + diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index a6e47077d0..c003ee5ef0 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -14,7 +14,7 @@ - + From 9b32921a77f8076cd13eea52633996d61e84eed6 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 3 May 2017 12:16:25 -0700 Subject: [PATCH 121/361] Missed rename updates --- .../build/PublishWithAspNetCoreTargetManifest.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets index 3922807fbf..57faa895aa 100644 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -4,7 +4,7 @@ - $(TargetManifestFiles);$(MSBuildThisFileDirectory)manifest.win-x64.xml;$(MSBuildThisFileDirectory)manifest.win-x86.xml;$(MSBuildThisFileDirectory)manifest.osx-x64.xml;$(MSBuildThisFileDirectory)manifest.linux-x64.xml + $(TargetManifestFiles);$(MSBuildThisFileDirectory)manifest.win7-x64.xml;$(MSBuildThisFileDirectory)manifest.win7-x86.xml;$(MSBuildThisFileDirectory)manifest.osx-x64.xml;$(MSBuildThisFileDirectory)manifest.linux-x64.xml + + + From 1a0331eaaaea08c9a1cc591267e648a4ed97fedf Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 5 May 2017 17:20:18 -0700 Subject: [PATCH 133/361] Restore template to avoid deps trimming issue --- build/repo.targets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/repo.targets b/build/repo.targets index 95aafd08ea..22487f8b6e 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -60,6 +60,8 @@ + + From f6e6b2cce92cfbb9184a3701f0e231362e830ad8 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 5 May 2017 23:15:34 -0700 Subject: [PATCH 134/361] Fix generation of deps files on macOS and Linux --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 18c0fa597d..32df6946e7 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -63,7 +63,7 @@ - + From 906f1d8f3efc8251054df87ae770c1acaffc8ab4 Mon Sep 17 00:00:00 2001 From: = Date: Sat, 6 May 2017 00:13:33 -0700 Subject: [PATCH 135/361] Fix command on macOS --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 32df6946e7..5232276dbd 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -109,7 +109,7 @@ - + From dd19150ea43f6b95babd215cd324222969c8e1a5 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 8 May 2017 10:16:43 -0700 Subject: [PATCH 136/361] Add test for DI scope validation defaults (#76) --- MetaPackages.sln | 10 ++- .../WebHostFunctionalTests.cs | 31 ++++++++- .../DependencyInjectionApp.csproj | 12 ++++ .../DependencyInjectionApp/Program.cs | 67 +++++++++++++++++++ 4 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj create mode 100644 test/TestSites/DependencyInjectionApp/Program.cs diff --git a/MetaPackages.sln b/MetaPackages.sln index 2528f60958..1404087eaf 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26424.2 +VisualStudioVersion = 15.0.26412.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -44,6 +44,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Archive", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\TrimDeps.csproj", "{67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -94,6 +96,10 @@ Global {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.Build.0 = Debug|Any CPU {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.ActiveCfg = Release|Any CPU {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.Build.0 = Release|Any CPU + {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -112,5 +118,7 @@ Global {AE4216BF-D471-471B-82F3-6B6D004F7D17} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {302400A0-98BB-4C04-88D4-C32DC2D4B945} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + {302400A0-98BB-4C04-88D4-C32DC2D4B945} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} EndGlobalSection EndGlobal diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index 39101acf2c..e7074a1bf3 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -73,6 +73,30 @@ namespace Microsoft.AspNetCore.Tests }, setTestEnvVars: true); } + [Theory] + [InlineData("Development", "InvalidOperationException: Cannot consume scoped service")] + [InlineData("Production", "Success")] + public async Task CreateDefaultBuilder_InitializesDependencyInjectionSettingsBasedOnEnv(string environment, string expected) + { + var applicationName = "DependencyInjectionApp"; + await ExecuteTestApp(applicationName, async (deploymentResult, logger) => + { + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var responseText = await response.Content.ReadAsStringAsync(); + try + { + // Assert UseDeveloperExceptionPage is called in WebHostStartupFilter. + Assert.Contains(expected, responseText); + } + catch (XunitException) + { + logger.LogWarning(response.ToString()); + logger.LogWarning(responseText); + throw; + } + }, setTestEnvVars: true, environment: environment); + } + [Theory] [InlineData("127.0.0.1", "127.0.0.1")] [InlineData("::1", "[::1]")] @@ -247,7 +271,10 @@ namespace Microsoft.AspNetCore.Tests }); } - private async Task ExecuteTestApp(string applicationName, Func assertAction, bool setTestEnvVars = false) + private async Task ExecuteTestApp(string applicationName, + Func assertAction, + bool setTestEnvVars = false, + string environment = "Development") { using (StartLog(out var loggerFactory, applicationName)) { @@ -256,7 +283,7 @@ namespace Microsoft.AspNetCore.Tests if (setTestEnvVars) { - deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("aspnetcore_environment", "Development")); + deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("aspnetcore_environment", environment)); deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("envKey", "envValue")); } diff --git a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj new file mode 100644 index 0000000000..04691e82ed --- /dev/null +++ b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.0 + + + + + + + diff --git a/test/TestSites/DependencyInjectionApp/Program.cs b/test/TestSites/DependencyInjectionApp/Program.cs new file mode 100644 index 0000000000..555dcc7156 --- /dev/null +++ b/test/TestSites/DependencyInjectionApp/Program.cs @@ -0,0 +1,67 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Logging.Console; +using Microsoft.Extensions.Logging.Debug; + +namespace CreateDefaultBuilderApp +{ + public class Program + { + static void Main(string[] args) + { + WebHost.CreateDefaultBuilder() + .ConfigureServices((context, services) => + { + services.AddSingleton(typeof(IService<>), typeof(Service<>)); + services.AddScoped(); + }) + .Configure(app => + { + app.Run(context => + { + try + { + context.RequestServices.GetService>(); + return context.Response.WriteAsync("Success"); + } + catch (Exception ex) + { + return context.Response.WriteAsync(ex.ToString()); + } + }); + }) + .Build().Run(); + } + + interface IService + { + } + + interface IAnotherService + { + } + + class Service: IService + { + public Service(T t) + { + } + } + + class AnotherService: IAnotherService + { + } + } +} From 873b41da7e68d2d726f420487508511997f00bc4 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 12 May 2017 14:39:20 -0700 Subject: [PATCH 137/361] React to Identity Service version updates --- build/common.props | 15 +++++++-------- build/dependencies.props | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/build/common.props b/build/common.props index f3f7aa312e..04bb2ae2bc 100644 --- a/build/common.props +++ b/build/common.props @@ -15,7 +15,6 @@ 2.0.0-$(VersionSuffix) - 1.0.0-$(VersionSuffix) @@ -98,7 +97,7 @@ - + @@ -109,12 +108,12 @@ - - - - - - + + + + + + diff --git a/build/dependencies.props b/build/dependencies.props index d3e2ca5336..344c23b7f9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,7 +2,6 @@ 0.4.0-* 2.0.0-* - 1.0.0-* 4.3.0 2.1.0-* 4.7.1 From b63b86215bfafa6ad1c30dff2ee88517f155c88d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 15 May 2017 09:41:43 -0700 Subject: [PATCH 138/361] Upgrade test framework versions --- build/dependencies.props | 4 ++-- .../Microsoft.AspNetCore.FunctionalTests.csproj | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 344c23b7f9..034b8307a8 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,7 @@ $(BundledNETStandardPackageVersion) 10.0.1 1.1.5 - 15.0.0 - 2.2.0 + 15.3.0-* + 2.3.0-beta2-* diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index 2082b80fb6..1a45e63b7d 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -22,8 +22,4 @@ - - - - - \ No newline at end of file + From e1a0931ca074b6811d17488666edeefc9e560c51 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Fri, 19 May 2017 15:07:04 +0100 Subject: [PATCH 139/361] Add reference to NodeServices and SpaServices --- build/common.props | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/common.props b/build/common.props index 04bb2ae2bc..4c8b824931 100644 --- a/build/common.props +++ b/build/common.props @@ -133,6 +133,7 @@ + @@ -148,6 +149,7 @@ + From d826688ebfbeaec13bf6df22d2802c66ccc561fa Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 19 May 2017 16:20:35 -0700 Subject: [PATCH 140/361] React to dotnet store cli arguments update --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 401d2f7824..86783009c9 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -59,7 +59,7 @@ - + From b9a9ec9305d16bb38ee943ddf348c89c0de0fcd6 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Fri, 19 May 2017 12:10:33 -0700 Subject: [PATCH 141/361] Add support for a default SSL certificate in development When the ssl certificate specified is 'localhost' and no certificate has been explicitly specified in the certificates section, fallback to a certificate with 'CN=localhost' (ASP.NET Core SSL developer certificate) in the current user store and if not found, an ssl certificate with 'CN=localhost' on the current machine (IIS Express developer certificate) --- .../KestrelServerOptionsSetup.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs index a76e7f6c85..c36bf2f59a 100644 --- a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs +++ b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.Linq; using System.Net; using System.Security.Cryptography.X509Certificates; @@ -15,6 +16,9 @@ namespace Microsoft.AspNetCore { internal class KestrelServerOptionsSetup : IConfigureOptions { + private const string DefaultCertificateSubjectName = "CN=localhost"; + private const string DevelopmentSSLCertificateName = "localhost"; + private readonly IHostingEnvironment _hostingEnvironment; private readonly IConfiguration _configurationRoot; private readonly ILoggerFactory _loggerFactory; @@ -65,13 +69,27 @@ namespace Microsoft.AspNetCore options.Listen(address, port, listenOptions => { var certificateConfig = endPoint.GetSection("Certificate"); - X509Certificate2 certificate; - + X509Certificate2 certificate = null; if (certificateConfig.Exists()) { try { - certificate = certificateLoader.Load(certificateConfig).FirstOrDefault(); + try + { + certificate = certificateLoader.Load(certificateConfig).FirstOrDefault(); + } + catch (KeyNotFoundException) when (certificateConfig.Value.Equals(DevelopmentSSLCertificateName, StringComparison.Ordinal) && _hostingEnvironment.IsDevelopment()) + { + var storeLoader = new CertificateStoreLoader(); + certificate = storeLoader.Load(DefaultCertificateSubjectName, "My", StoreLocation.CurrentUser, validOnly: false) ?? + storeLoader.Load(DefaultCertificateSubjectName, "My", StoreLocation.LocalMachine, validOnly: false); + + if (certificate == null) + { + var logger = _loggerFactory.CreateLogger("Microsoft.AspNetCore.KestrelOptionsSetup"); + logger.LogError("No HTTPS certificate was found for development. For information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054."); + } + } if (certificate == null) { From 3963a6aa52c8563084f3dd66a302969e1c15eaba Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 24 May 2017 18:47:32 -0700 Subject: [PATCH 142/361] #125 Add HostingStartup packages to .All --- build/common.props | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/build/common.props b/build/common.props index 4c8b824931..66a48bc874 100644 --- a/build/common.props +++ b/build/common.props @@ -38,7 +38,7 @@ $(AspNetCoreVersion) - None + Compile $(AspNetCoreVersion) @@ -72,8 +72,14 @@ + + + + + + @@ -87,6 +93,7 @@ + @@ -192,6 +199,7 @@ + @@ -217,18 +225,8 @@ - - - - - - - - - - From e3cae98a05f039128e1c509ed1e7cf69ce944b59 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 25 May 2017 18:33:54 -0700 Subject: [PATCH 143/361] Add new packages --- build/common.props | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/common.props b/build/common.props index 66a48bc874..7ad3ee8cfe 100644 --- a/build/common.props +++ b/build/common.props @@ -93,6 +93,7 @@ + @@ -196,6 +197,8 @@ + + From 298776c48c519447333f69ced1932df94d42f2b7 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 25 May 2017 21:12:19 -0700 Subject: [PATCH 144/361] Remove unpushed new identity packages --- build/common.props | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/common.props b/build/common.props index 7ad3ee8cfe..1beed951a0 100644 --- a/build/common.props +++ b/build/common.props @@ -197,8 +197,6 @@ - - From 16191669115f8aa90da2c8fcfba6b2c1699ce0a7 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 24 May 2017 19:37:15 -0700 Subject: [PATCH 145/361] Update manifest names --- build/repo.targets | 17 +++++++++-------- .../Microsoft.AspNetCore.All.csproj | 9 +++++++++ .../PublishWithAspNetCoreTargetManifest.targets | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 86783009c9..85c4753dc3 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -15,6 +15,13 @@ $(RepositoryRoot)src\dotnet-archive\dotnet-archive.csproj $(RepositoryRoot)src\dotnet-archive\bin\$(Configuration)\netcoreapp2.0\dotnet-archive.dll + + $(TIMESTAMP_FREE_VERSION) + final + + $(VersionPrefix)-$(OriginalVersionSuffix)-$(NoTimestampSuffix) + $(VersionPrefix)-$(OriginalVersionSuffix)-$(BuildNumber) + $(MetaPackagePath)bin\work\ $(MetaPackagePath)bin\packageCache\ $(RepositoryRoot)artifacts\ @@ -69,7 +76,7 @@ - manifest.$(RID).xml + aspnetcore-store-$(TimestampVersion)-$(RID).xml <_PackageCacheFiles Include="$(PackageCacheOutputPath)**\*" Exclude="$(PackageCacheOutputPath)**\artifact.xml" /> @@ -78,7 +85,7 @@ - + @@ -158,12 +165,6 @@ - $(TIMESTAMP_FREE_VERSION) - final - - $(VersionPrefix)-$(OriginalVersionSuffix)-$(NoTimestampSuffix) - $(VersionPrefix)-$(OriginalVersionSuffix)-$(BuildNumber) - $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages-NoTimeStamp $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index a6e47077d0..71fb2302b5 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -22,4 +22,13 @@ + + + $(MSBuildThisFileDirectory)build\PublishWithAspNetCoreTargetManifest.targets + + + + + + diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets index 57faa895aa..b729b98b82 100644 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -4,7 +4,7 @@ - $(TargetManifestFiles);$(MSBuildThisFileDirectory)manifest.win7-x64.xml;$(MSBuildThisFileDirectory)manifest.win7-x86.xml;$(MSBuildThisFileDirectory)manifest.osx-x64.xml;$(MSBuildThisFileDirectory)manifest.linux-x64.xml + $(TargetManifestFiles);$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-win7-x64.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-win7-x86.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-osx-x64.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-linux-x64.xml diff --git a/build/dependencies.props b/build/dependencies.props index 5e0e8ee677..302a8149fd 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,10 +2,10 @@ 0.4.0-* 2.0.0-* - 4.3.0 + 4.4.0-* 2.1.0-* 4.7.1 - $(BundledNETStandardPackageVersion) + 2.0.0-* 10.0.1 2.0.0-* 1.1.5 diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index 37ac635939..db4fc54254 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + netcoreapp2.0;net461 aspnetcore-MetaPackagesSampleApp-20170406180413 @@ -16,4 +16,7 @@ + + + diff --git a/src/Microsoft.AspNetCore/CertificateLoader.cs b/src/Microsoft.AspNetCore/CertificateLoader.cs index aa616184c4..b43bdb8fcc 100644 --- a/src/Microsoft.AspNetCore/CertificateLoader.cs +++ b/src/Microsoft.AspNetCore/CertificateLoader.cs @@ -179,7 +179,13 @@ namespace Microsoft.AspNetCore { var certificate = TryLoad(X509KeyStorageFlags.DefaultKeySet, out var error) ?? TryLoad(X509KeyStorageFlags.UserKeySet, out error) - ?? TryLoad(X509KeyStorageFlags.EphemeralKeySet, out error); +#if NETCOREAPP2_0 + ?? TryLoad(X509KeyStorageFlags.EphemeralKeySet, out error) +#elif NET461 +#else +#error target frameworks need to be updated +#endif + ; if (error != null) { diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index f8d430676e..153156b71e 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + netcoreapp2.0;net461 aspnetcore Microsoft.AspNetCore true diff --git a/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj b/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj index f14971a5ef..3bd7d6263e 100644 --- a/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj +++ b/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj @@ -7,8 +7,4 @@ false - - - - diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index 1a45e63b7d..c8e3826622 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -3,7 +3,15 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 + + + true + win7-x64 diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj index 5e36052b25..5a3a180fbc 100644 --- a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj +++ b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj @@ -3,11 +3,12 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 - + From b04be188c08c611250b66fa719187c80d370dbf3 Mon Sep 17 00:00:00 2001 From: Chris R Date: Tue, 30 May 2017 15:51:21 -0700 Subject: [PATCH 151/361] #81 Move CertificateLoader to Hosting --- MetaPackages.sln | 3 +- build/common.props | 1 + .../CertificateFileLoader.cs | 15 - src/Microsoft.AspNetCore/CertificateLoader.cs | 248 ---- .../CertificateStoreLoader.cs | 56 - .../ICertificateFileLoader.cs | 12 - .../ICertificateStoreLoader.cs | 12 - .../KestrelServerOptionsSetup.cs | 1 + .../Microsoft.AspNetCore.csproj | 2 +- .../Properties/AssemblyInfo.cs | 7 - .../CertificateLoaderTests.cs | 1044 ----------------- 11 files changed, 5 insertions(+), 1396 deletions(-) delete mode 100644 src/Microsoft.AspNetCore/CertificateFileLoader.cs delete mode 100644 src/Microsoft.AspNetCore/CertificateLoader.cs delete mode 100644 src/Microsoft.AspNetCore/CertificateStoreLoader.cs delete mode 100644 src/Microsoft.AspNetCore/ICertificateFileLoader.cs delete mode 100644 src/Microsoft.AspNetCore/ICertificateStoreLoader.cs delete mode 100644 src/Microsoft.AspNetCore/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.AspNetCore.FunctionalTests/CertificateLoaderTests.cs diff --git a/MetaPackages.sln b/MetaPackages.sln index ab793361cf..bac992e613 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26507.0 +VisualStudioVersion = 15.0.26524.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -10,6 +10,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.All", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97D53BEB-A511-4FBE-B784-AB407D9A219F}" ProjectSection(SolutionItems) = preProject + NuGet.config = NuGet.config version.props = version.props EndProjectSection EndProject diff --git a/build/common.props b/build/common.props index 4d4fc25989..2ae8536639 100644 --- a/build/common.props +++ b/build/common.props @@ -55,6 +55,7 @@ + diff --git a/src/Microsoft.AspNetCore/CertificateFileLoader.cs b/src/Microsoft.AspNetCore/CertificateFileLoader.cs deleted file mode 100644 index 1c0b6e5759..0000000000 --- a/src/Microsoft.AspNetCore/CertificateFileLoader.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Security.Cryptography.X509Certificates; - -namespace Microsoft.AspNetCore -{ - internal class CertificateFileLoader : ICertificateFileLoader - { - public X509Certificate2 Load(string path, string password, X509KeyStorageFlags flags) - { - return new X509Certificate2(path, password, flags); - } - } -} diff --git a/src/Microsoft.AspNetCore/CertificateLoader.cs b/src/Microsoft.AspNetCore/CertificateLoader.cs deleted file mode 100644 index b43bdb8fcc..0000000000 --- a/src/Microsoft.AspNetCore/CertificateLoader.cs +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography.X509Certificates; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore -{ - /// - /// A helper class to load certificates from files and certificate stores based on data. - /// - public class CertificateLoader - { - private readonly IConfiguration _certificatesConfiguration; - private readonly string _environmentName; - private readonly ICertificateFileLoader _certificateFileLoader; - private readonly ICertificateStoreLoader _certificateStoreLoader; - private readonly ILogger _logger; - - /// - /// Creates a new instance of that can load certificate references from configuration. - /// - /// An with information about certificates. - public CertificateLoader(IConfiguration certificatesConfiguration) - : this(certificatesConfiguration, null, null) - { - } - - /// - /// Creates a new instance of that can load certificate references from configuration. - /// - /// An with information about certificates. - /// An instance. - public CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory) - : this(certificatesConfiguration, loggerFactory, null) - { - } - - /// - /// Creates a new instance of that can load certificate references from configuration. - /// - /// An with information about certificates. - /// An instance. - /// The name of the environment the application is running in. - public CertificateLoader(IConfiguration certificatesConfiguration, ILoggerFactory loggerFactory, string environmentName) - : this(certificatesConfiguration, loggerFactory, environmentName, new CertificateFileLoader(), new CertificateStoreLoader()) - { - } - - internal CertificateLoader( - IConfiguration certificatesConfiguration, - ILoggerFactory loggerFactory, - string environmentName, - ICertificateFileLoader certificateFileLoader, - ICertificateStoreLoader certificateStoreLoader) - { - _environmentName = environmentName; - _certificatesConfiguration = certificatesConfiguration; - _certificateFileLoader = certificateFileLoader; - _certificateStoreLoader = certificateStoreLoader; - _logger = loggerFactory?.CreateLogger("Microsoft.AspNetCore.CertificateLoader"); - } - - /// - /// Loads one or more certificates based on the information found in a configuration section. - /// - /// A configuration section containing either a string value referencing certificates - /// by name, or one or more inline certificate specifications. - /// - /// One or more loaded certificates. - public IEnumerable Load(IConfigurationSection certificateConfiguration) - { - var certificateNames = certificateConfiguration.Value; - var certificates = new List(); - - if (certificateNames != null) - { - foreach (var certificateName in certificateNames.Split(';')) - { - var certificate = LoadSingle(certificateName); - if (certificate != null) - { - certificates.Add(certificate); - } - } - } - else - { - if (certificateConfiguration["Source"] != null) - { - var certificate = LoadSingle(certificateConfiguration); - if (certificate != null) - { - certificates.Add(certificate); - } - } - else - { - certificates.AddRange(LoadMultiple(certificateConfiguration)); - } - } - - return certificates; - } - - /// - /// Loads a certificate by name. - /// - /// The certificate name. - /// The loaded certificate - /// This method only works if the instance was constructed with - /// a reference to an instance containing named certificates. - /// - private X509Certificate2 LoadSingle(string certificateName) - { - var certificateConfiguration = _certificatesConfiguration?.GetSection(certificateName); - - if (!certificateConfiguration.Exists()) - { - var environmentName = _environmentName != null ? $" ({_environmentName})" : ""; - throw new KeyNotFoundException($"No certificate named '{certificateName}' found in configuration for the current environment{environmentName}."); - } - - return LoadSingle(certificateConfiguration); - } - - private X509Certificate2 LoadSingle(IConfigurationSection certificateConfiguration) - { - var sourceKind = certificateConfiguration["Source"]; - - CertificateSource certificateSource; - switch (sourceKind.ToLowerInvariant()) - { - case "file": - certificateSource = new CertificateFileSource(_certificateFileLoader); - break; - case "store": - certificateSource = new CertificateStoreSource(_certificateStoreLoader, _logger); - break; - default: - throw new InvalidOperationException($"Invalid certificate source kind '{sourceKind}'."); - } - - certificateConfiguration.Bind(certificateSource); - - return certificateSource.Load(); - } - - private IEnumerable LoadMultiple(IConfigurationSection certificatesConfiguration) - => certificatesConfiguration.GetChildren() - .Select(LoadSingle) - .Where(c => c != null); - - private abstract class CertificateSource - { - public string Source { get; set; } - - public abstract X509Certificate2 Load(); - } - - private class CertificateFileSource : CertificateSource - { - private ICertificateFileLoader _certificateFileLoader; - - public CertificateFileSource(ICertificateFileLoader certificateFileLoader) - { - _certificateFileLoader = certificateFileLoader; - } - - public string Path { get; set; } - - public string Password { get; set; } - - public override X509Certificate2 Load() - { - var certificate = TryLoad(X509KeyStorageFlags.DefaultKeySet, out var error) - ?? TryLoad(X509KeyStorageFlags.UserKeySet, out error) -#if NETCOREAPP2_0 - ?? TryLoad(X509KeyStorageFlags.EphemeralKeySet, out error) -#elif NET461 -#else -#error target frameworks need to be updated -#endif - ; - - if (error != null) - { - throw new InvalidOperationException($"Unable to load certificate from file '{Path}'. Error details: '{error.Message}'.", error); - } - - return certificate; - } - - private X509Certificate2 TryLoad(X509KeyStorageFlags flags, out Exception exception) - { - try - { - var loadedCertificate = _certificateFileLoader.Load(Path, Password, flags); - exception = null; - return loadedCertificate; - } - catch (Exception e) - { - exception = e; - return null; - } - } - } - - private class CertificateStoreSource : CertificateSource - { - private readonly ICertificateStoreLoader _certificateStoreLoader; - private readonly ILogger _logger; - - public CertificateStoreSource(ICertificateStoreLoader certificateStoreLoader, ILogger logger) - { - _certificateStoreLoader = certificateStoreLoader; - _logger = logger; - } - - public string Subject { get; set; } - public string StoreName { get; set; } - public string StoreLocation { get; set; } - public bool AllowInvalid { get; set; } - - public override X509Certificate2 Load() - { - if (!Enum.TryParse(StoreLocation, ignoreCase: true, result: out StoreLocation storeLocation)) - { - throw new InvalidOperationException($"The certificate store location '{StoreLocation}' is invalid."); - } - - var certificate = _certificateStoreLoader.Load(Subject, StoreName, storeLocation, !AllowInvalid); - - if (certificate == null) - { - _logger?.LogWarning($"Unable to find a matching certificate for subject '{Subject}' in store '{StoreName}' in '{StoreLocation}'."); - } - - return certificate; - } - } - } -} diff --git a/src/Microsoft.AspNetCore/CertificateStoreLoader.cs b/src/Microsoft.AspNetCore/CertificateStoreLoader.cs deleted file mode 100644 index 27158d4da3..0000000000 --- a/src/Microsoft.AspNetCore/CertificateStoreLoader.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Linq; -using System.Security.Cryptography.X509Certificates; - -namespace Microsoft.AspNetCore -{ - internal class CertificateStoreLoader : ICertificateStoreLoader - { - public X509Certificate2 Load(string subject, string storeName, StoreLocation storeLocation, bool validOnly) - { - using (var store = new X509Store(storeName, storeLocation)) - { - X509Certificate2Collection storeCertificates = null; - X509Certificate2Collection foundCertificates = null; - X509Certificate2 foundCertificate = null; - - try - { - store.Open(OpenFlags.ReadOnly); - storeCertificates = store.Certificates; - foundCertificates = storeCertificates.Find(X509FindType.FindBySubjectDistinguishedName, subject, validOnly); - foundCertificate = foundCertificates - .OfType() - .OrderByDescending(certificate => certificate.NotAfter) - .FirstOrDefault(); - - return foundCertificate; - } - finally - { - if (foundCertificate != null) - { - storeCertificates.Remove(foundCertificate); - foundCertificates.Remove(foundCertificate); - } - - DisposeCertificates(storeCertificates); - DisposeCertificates(foundCertificates); - } - } - } - - private void DisposeCertificates(X509Certificate2Collection certificates) - { - if (certificates != null) - { - foreach (var certificate in certificates) - { - certificate.Dispose(); - } - } - } - } -} diff --git a/src/Microsoft.AspNetCore/ICertificateFileLoader.cs b/src/Microsoft.AspNetCore/ICertificateFileLoader.cs deleted file mode 100644 index 4c394bbd02..0000000000 --- a/src/Microsoft.AspNetCore/ICertificateFileLoader.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Security.Cryptography.X509Certificates; - -namespace Microsoft.AspNetCore -{ - internal interface ICertificateFileLoader - { - X509Certificate2 Load(string path, string password, X509KeyStorageFlags flags); - } -} diff --git a/src/Microsoft.AspNetCore/ICertificateStoreLoader.cs b/src/Microsoft.AspNetCore/ICertificateStoreLoader.cs deleted file mode 100644 index f128bbd675..0000000000 --- a/src/Microsoft.AspNetCore/ICertificateStoreLoader.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Security.Cryptography.X509Certificates; - -namespace Microsoft.AspNetCore -{ - internal interface ICertificateStoreLoader - { - X509Certificate2 Load(string subject, string storeName, StoreLocation storeLocation, bool validOnly); - } -} diff --git a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs index c36bf2f59a..a2a5fe1ca2 100644 --- a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs +++ b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Security.Cryptography.X509Certificates; +using Microsoft.AspNetCore.Certificates.Configuration; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.Configuration; diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 153156b71e..cf888d57ca 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0;net461 + netstandard2.0 aspnetcore Microsoft.AspNetCore true diff --git a/src/Microsoft.AspNetCore/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore/Properties/AssemblyInfo.cs deleted file mode 100644 index a3a00f9d5c..0000000000 --- a/src/Microsoft.AspNetCore/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.FunctionalTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.FunctionalTests/CertificateLoaderTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/CertificateLoaderTests.cs deleted file mode 100644 index 1db8765e82..0000000000 --- a/test/Microsoft.AspNetCore.FunctionalTests/CertificateLoaderTests.cs +++ /dev/null @@ -1,1044 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography.X509Certificates; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using Moq; -using Xunit; - -namespace Microsoft.AspNetCore.FunctionalTests -{ - public class CertificateLoaderTests - { - [Fact] - public void Loads_SingleCertificateName_File() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "File", - ["Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["Certificates:Certificate1:Password"] = "Password1", - ["TestConfig:Certificate"] = "Certificate1" - }) - .Build(); - - var certificate = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(certificate); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - certificateFileLoader.Object, - Mock.Of()); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); - Assert.Same(certificate, loadedCertificates.ElementAt(0)); - certificateFileLoader.VerifyAll(); - } - - [Fact] - public void Throws_SingleCertificateName_KeyNotFound() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificate"] = "Certificate1" - }) - .Build(); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - Mock.Of(), - Mock.Of()); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); - Assert.Equal("No certificate named 'Certificate1' found in configuration for the current environment.", exception.Message); - } - - [Fact] - public void Throws_SingleCertificateName_File_FileLoadError() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "File", - ["Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["Certificates:Certificate1:Password"] = "Password1", - ["TestConfig:Certificate"] = "Certificate1" - }) - .Build(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Callback(() => throw new Exception(nameof(Throws_SingleCertificateName_File_FileLoadError))); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - certificateFileLoader.Object, - Mock.Of()); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); - Assert.Equal($"Unable to load certificate from file 'Certificate1.pfx'. Error details: '{nameof(Throws_SingleCertificateName_File_FileLoadError)}'.", exception.Message); - } - - [Fact] - public void Loads_SingleCertificateName_Store() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "Store", - ["Certificates:Certificate1:Subject"] = "localhost", - ["Certificates:Certificate1:StoreName"] = "My", - ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificate"] = "Certificate1" - }) - .Build(); - - var certificate = new X509Certificate2(); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(certificate); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - Mock.Of(), - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); - Assert.Same(certificate, loadedCertificates.ElementAt(0)); - certificateStoreLoader.VerifyAll(); - } - - [Fact] - public void ReturnsNull_SingleCertificateName_Store_NotFoundInStore() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "Store", - ["Certificates:Certificate1:Subject"] = "localhost", - ["Certificates:Certificate1:StoreName"] = "My", - ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificate"] = "Certificate1" - }) - .Build(); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(null); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - Mock.Of(), - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(0, loadedCertificates.Count()); - certificateStoreLoader.VerifyAll(); - } - - [Fact] - public void Loads_MultipleCertificateNames_File() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "File", - ["Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["Certificates:Certificate1:Password"] = "Password1", - ["Certificates:Certificate2:Source"] = "File", - ["Certificates:Certificate2:Path"] = "Certificate2.pfx", - ["Certificates:Certificate2:Password"] = "Password2", - ["TestConfig:Certificate"] = "Certificate1;Certificate2" - }) - .Build(); - - var certificate1 = new X509Certificate2(); - var certificate2 = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(certificate1); - certificateFileLoader - .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) - .Returns(certificate2); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - certificateFileLoader.Object, - Mock.Of()); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(2, loadedCertificates.Count()); - Assert.Same(certificate1, loadedCertificates.ElementAt(0)); - Assert.Same(certificate2, loadedCertificates.ElementAt(1)); - certificateFileLoader.VerifyAll(); - } - - [Theory] - [InlineData("Certificate1;Certificate2")] - [InlineData("Certificate2;Certificate1")] - public void Throws_MultipleCertificateNames_File_FileLoadError(string certificateNames) - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "File", - ["Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["Certificates:Certificate1:Password"] = "Password1", - ["Certificates:Certificate2:Source"] = "File", - ["Certificates:Certificate2:Path"] = "Certificate2.pfx", - ["Certificates:Certificate2:Password"] = "Password2", - ["TestConfig:Certificate"] = certificateNames - }) - .Build(); - - var certificate1 = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(certificate1); - certificateFileLoader - .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) - .Throws(new Exception(nameof(Throws_MultipleCertificateNames_File_FileLoadError))); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - certificateFileLoader.Object, - Mock.Of()); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); - Assert.Equal($"Unable to load certificate from file 'Certificate2.pfx'. Error details: '{nameof(Throws_MultipleCertificateNames_File_FileLoadError)}'.", exception.Message); - } - - [Fact] - public void Loads_MultipleCertificateNames_Store() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "Store", - ["Certificates:Certificate1:Subject"] = "localhost", - ["Certificates:Certificate1:StoreName"] = "My", - ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", - ["Certificates:Certificate2:Source"] = "Store", - ["Certificates:Certificate2:Subject"] = "example.com", - ["Certificates:Certificate2:StoreName"] = "Root", - ["Certificates:Certificate2:StoreLocation"] = "LocalMachine", - ["TestConfig:Certificate"] = "Certificate1;Certificate2" - }) - .Build(); - - var certificate1 = new X509Certificate2(); - var certificate2 = new X509Certificate2(); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(certificate1); - certificateStoreLoader - .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) - .Returns(certificate2); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - Mock.Of(), - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(2, loadedCertificates.Count()); - Assert.Same(certificate1, loadedCertificates.ElementAt(0)); - Assert.Same(certificate2, loadedCertificates.ElementAt(1)); - certificateStoreLoader.VerifyAll(); - } - - [Theory] - [InlineData("Certificate1;Certificate2", 1)] - [InlineData("Certificate2;Certificate1", 1)] - [InlineData("Certificate1;Certificate2;Certificate3", 1)] - [InlineData("Certificate2;Certificate3", 0)] - [InlineData("Certificate2;Certificate3;Certificate1", 1)] - public void ReturnsNull_MultipleCertificateNames_Store_NotFoundInStore(string certificateNames, int expectedFoundCertificates) - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "Store", - ["Certificates:Certificate1:Subject"] = "localhost", - ["Certificates:Certificate1:StoreName"] = "My", - ["Certificates:Certificate1:StoreLocation"] = "CurrentUser", - ["Certificates:Certificate2:Source"] = "Store", - ["Certificates:Certificate2:Subject"] = "example.com", - ["Certificates:Certificate2:StoreName"] = "Root", - ["Certificates:Certificate2:StoreLocation"] = "LocalMachine", - ["Certificates:Certificate3:Source"] = "Store", - ["Certificates:Certificate3:Subject"] = "notfound.com", - ["Certificates:Certificate3:StoreName"] = "Root", - ["Certificates:Certificate3:StoreLocation"] = "LocalMachine", - ["TestConfig:Certificate"] = certificateNames - }) - .Build(); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(new X509Certificate2()); - certificateStoreLoader - .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) - .Returns(null); - certificateStoreLoader - .Setup(loader => loader.Load("notfound.com", "Root", StoreLocation.LocalMachine, It.IsAny())) - .Returns(null); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - Mock.Of(), - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(expectedFoundCertificates, loadedCertificates.Count()); - } - - [Fact] - public void Loads_MultipleCertificateNames_FileAndStore() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "File", - ["Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["Certificates:Certificate1:Password"] = "Password1", - ["Certificates:Certificate2:Source"] = "Store", - ["Certificates:Certificate2:Subject"] = "localhost", - ["Certificates:Certificate2:StoreName"] = "My", - ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificate"] = "Certificate1;Certificate2" - }) - .Build(); - - var fileCertificate = new X509Certificate2(); - var storeCertificate = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(fileCertificate); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(storeCertificate); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - certificateFileLoader.Object, - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(2, loadedCertificates.Count()); - Assert.Same(fileCertificate, loadedCertificates.ElementAt(0)); - Assert.Same(storeCertificate, loadedCertificates.ElementAt(1)); - certificateFileLoader.VerifyAll(); - certificateStoreLoader.VerifyAll(); - } - - [Theory] - [InlineData("Certificate1;Certificate2;NotFound")] - [InlineData("Certificate1;NotFound;Certificate2")] - [InlineData("NotFound;Certificate1;Certificate2")] - public void Throws_MultipleCertificateNames_KeyNotFound(string certificateNames) - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "File", - ["Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["Certificates:Certificate1:Password"] = "Password1", - ["Certificates:Certificate2:Source"] = "Store", - ["Certificates:Certificate2:Subject"] = "localhost", - ["Certificates:Certificate2:StoreName"] = "My", - ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificate"] = certificateNames - }) - .Build(); - - var fileCertificate = new X509Certificate2(); - var storeCertificate = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(fileCertificate); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(storeCertificate); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - certificateFileLoader.Object, - certificateStoreLoader.Object); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); - Assert.Equal("No certificate named 'NotFound' found in configuration for the current environment.", exception.Message); - } - - [Theory] - [InlineData("Certificate1;Certificate2")] - [InlineData("Certificate2;Certificate1")] - public void Throws_MultipleCertificateNames_FileAndStore_FileLoadError(string certificateNames) - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "File", - ["Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["Certificates:Certificate1:Password"] = "Password1", - ["Certificates:Certificate2:Source"] = "Store", - ["Certificates:Certificate2:Subject"] = "localhost", - ["Certificates:Certificate2:StoreName"] = "My", - ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificate"] = certificateNames - }) - .Build(); - - var storeCertificate = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Throws(new Exception(nameof(Throws_MultipleCertificateNames_FileAndStore_FileLoadError))); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(storeCertificate); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - certificateFileLoader.Object, - certificateStoreLoader.Object); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); - Assert.Equal($"Unable to load certificate from file 'Certificate1.pfx'. Error details: '{nameof(Throws_MultipleCertificateNames_FileAndStore_FileLoadError)}'.", exception.Message); - } - - [Theory] - [InlineData("Certificate1;Certificate2")] - [InlineData("Certificate2;Certificate1")] - public void ReturnsNull_MultipleCertificateNames_FileAndStore_NotFoundInStore(string certificateNames) - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["Certificates:Certificate1:Source"] = "File", - ["Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["Certificates:Certificate1:Password"] = "Password1", - ["Certificates:Certificate2:Source"] = "Store", - ["Certificates:Certificate2:Subject"] = "localhost", - ["Certificates:Certificate2:StoreName"] = "My", - ["Certificates:Certificate2:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificate"] = "Certificate1;Certificate2" - }) - .Build(); - - var certificate = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(certificate); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(null); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - certificateFileLoader.Object, - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); - Assert.Same(certificate, loadedCertificates.ElementAt(0)); - certificateFileLoader.VerifyAll(); - certificateStoreLoader.VerifyAll(); - } - - [Fact] - public void Loads_SingleCertificateInline_File() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificate:Source"] = "File", - ["TestConfig:Certificate:Path"] = "Certificate1.pfx", - ["TestConfig:Certificate:Password"] = "Password1" - }) - .Build(); - - var certificate = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(certificate); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - certificateFileLoader.Object, - Mock.Of()); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); - Assert.Same(certificate, loadedCertificates.ElementAt(0)); - certificateFileLoader.VerifyAll(); - } - - [Fact] - public void Throws_SingleCertificateInline_FileLoadError() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificate:Source"] = "File", - ["TestConfig:Certificate:Path"] = "Certificate1.pfx", - ["TestConfig:Certificate:Password"] = "Password1" - }) - .Build(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Throws(new Exception(nameof(Throws_SingleCertificateInline_FileLoadError))); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - certificateFileLoader.Object, - Mock.Of()); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); - Assert.Equal($"Unable to load certificate from file 'Certificate1.pfx'. Error details: '{nameof(Throws_SingleCertificateInline_FileLoadError)}'.", exception.Message); - certificateFileLoader.VerifyAll(); - } - - [Fact] - public void Loads_SingleCertificateInline_Store() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificate:Source"] = "Store", - ["TestConfig:Certificate:Subject"] = "localhost", - ["TestConfig:Certificate:StoreName"] = "My", - ["TestConfig:Certificate:StoreLocation"] = "CurrentUser", - }) - .Build(); - - var certificate = new X509Certificate2(); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(certificate); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - Mock.Of(), - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(1, loadedCertificates.Count()); - Assert.Same(certificate, loadedCertificates.ElementAt(0)); - certificateStoreLoader.VerifyAll(); - } - - [Fact] - public void ReturnsNull_SingleCertificateInline_Store_NotFoundInStore() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificate:Source"] = "Store", - ["TestConfig:Certificate:Subject"] = "localhost", - ["TestConfig:Certificate:StoreName"] = "My", - ["TestConfig:Certificate:StoreLocation"] = "CurrentUser", - }) - .Build(); - - var certificateStoreLoader = new Mock(); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - Mock.Of(), - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificate")); - Assert.Equal(0, loadedCertificates.Count()); - certificateStoreLoader.Verify(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())); - } - - [Fact] - public void Loads_MultipleCertificatesInline_File() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificates:Certificate1:Source"] = "File", - ["TestConfig:Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["TestConfig:Certificates:Certificate1:Password"] = "Password1", - ["TestConfig:Certificates:Certificate2:Source"] = "File", - ["TestConfig:Certificates:Certificate2:Path"] = "Certificate2.pfx", - ["TestConfig:Certificates:Certificate2:Password"] = "Password2", - }) - .Build(); - - var certificate1 = new X509Certificate2(); - var certificate2 = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(certificate1); - certificateFileLoader - .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) - .Returns(certificate2); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - certificateFileLoader.Object, - Mock.Of()); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(2, loadedCertificates.Count()); - Assert.Same(certificate1, loadedCertificates.ElementAt(0)); - Assert.Same(certificate2, loadedCertificates.ElementAt(1)); - certificateFileLoader.VerifyAll(); - } - - [Fact] - public void Throws_MultipleCertificatesInline_File_FileLoadError() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificates:Certificate1:Source"] = "File", - ["TestConfig:Certificates:Certificate1:Path"] = "Certificate1.pfx", - ["TestConfig:Certificates:Certificate1:Password"] = "Password1", - ["TestConfig:Certificates:Certificate2:Source"] = "File", - ["TestConfig:Certificates:Certificate2:Path"] = "Certificate2.pfx", - ["TestConfig:Certificates:Certificate2:Password"] = "Password2", - }) - .Build(); - - var certificate1 = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(certificate1); - certificateFileLoader - .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) - .Throws(new Exception(nameof(Throws_MultipleCertificatesInline_File_FileLoadError))); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - certificateFileLoader.Object, - Mock.Of()); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificates"))); - Assert.Equal($"Unable to load certificate from file 'Certificate2.pfx'. Error details: '{nameof(Throws_MultipleCertificatesInline_File_FileLoadError)}'.", exception.Message); - } - - [Fact] - public void Loads_MultipleCertificatesInline_Store() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificates:Certificate1:Source"] = "Store", - ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", - ["TestConfig:Certificates:Certificate1:StoreName"] = "My", - ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificates:Certificate2:Source"] = "Store", - ["TestConfig:Certificates:Certificate2:Subject"] = "example.com", - ["TestConfig:Certificates:Certificate2:StoreName"] = "Root", - ["TestConfig:Certificates:Certificate2:StoreLocation"] = "LocalMachine" - }) - .Build(); - - var certificate1 = new X509Certificate2(); - var certificate2 = new X509Certificate2(); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(certificate1); - certificateStoreLoader - .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) - .Returns(certificate2); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - Mock.Of(), - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(2, loadedCertificates.Count()); - Assert.Same(certificate1, loadedCertificates.ElementAt(0)); - Assert.Same(certificate2, loadedCertificates.ElementAt(1)); - certificateStoreLoader.VerifyAll(); - } - - [Fact] - public void ReturnsNull_MultipleCertificatesInline_Store_NotFoundInStore() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificates:Certificate1:Source"] = "Store", - ["TestConfig:Certificates:Certificate1:Subject"] = "notfound.com", - ["TestConfig:Certificates:Certificate1:StoreName"] = "Root", - ["TestConfig:Certificates:Certificate1:StoreLocation"] = "LocalMachine", - ["TestConfig:Certificates:Certificate2:Source"] = "Store", - ["TestConfig:Certificates:Certificate2:Subject"] = "localhost", - ["TestConfig:Certificates:Certificate2:StoreName"] = "My", - ["TestConfig:Certificates:Certificate2:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificates:Certificate3:Source"] = "Store", - ["TestConfig:Certificates:Certificate3:Subject"] = "example.com", - ["TestConfig:Certificates:Certificate3:StoreName"] = "Root", - ["TestConfig:Certificates:Certificate3:StoreLocation"] = "LocalMachine" - }) - .Build(); - - var certificate = new X509Certificate2(); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(certificate); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - Mock.Of(), - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(1, loadedCertificates.Count()); - Assert.Same(certificate, loadedCertificates.ElementAt(0)); - certificateStoreLoader.Verify(loader => loader.Load("notfound.com", "Root", StoreLocation.LocalMachine, It.IsAny())); - certificateStoreLoader.Verify(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())); - certificateStoreLoader.Verify(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())); - } - - [Fact] - public void Loads_MultipleCertificatesInline_FileAndStore() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificates:Certificate1:Source"] = "Store", - ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", - ["TestConfig:Certificates:Certificate1:StoreName"] = "My", - ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificates:Certificate2:Source"] = "File", - ["TestConfig:Certificates:Certificate2:Path"] = "Certificate1.pfx", - ["TestConfig:Certificates:Certificate2:Password"] = "Password1", - ["TestConfig:Certificates:Certificate3:Source"] = "Store", - ["TestConfig:Certificates:Certificate3:Subject"] = "example.com", - ["TestConfig:Certificates:Certificate3:StoreName"] = "Root", - ["TestConfig:Certificates:Certificate3:StoreLocation"] = "LocalMachine", - ["TestConfig:Certificates:Certificate4:Source"] = "File", - ["TestConfig:Certificates:Certificate4:Path"] = "Certificate2.pfx", - ["TestConfig:Certificates:Certificate4:Password"] = "Password2", - }) - .Build(); - - var fileCertificate1 = new X509Certificate2(); - var fileCertificate2 = new X509Certificate2(); - var storeCertificate1 = new X509Certificate2(); - var storeCertificate2 = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(fileCertificate1); - certificateFileLoader - .Setup(loader => loader.Load("Certificate2.pfx", "Password2", It.IsAny())) - .Returns(fileCertificate2); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(storeCertificate1); - certificateStoreLoader - .Setup(loader => loader.Load("example.com", "Root", StoreLocation.LocalMachine, It.IsAny())) - .Returns(storeCertificate2); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - certificateFileLoader.Object, - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(4, loadedCertificates.Count()); - Assert.Same(storeCertificate1, loadedCertificates.ElementAt(0)); - Assert.Same(fileCertificate1, loadedCertificates.ElementAt(1)); - Assert.Same(storeCertificate2, loadedCertificates.ElementAt(2)); - Assert.Same(fileCertificate2, loadedCertificates.ElementAt(3)); - certificateStoreLoader.VerifyAll(); - } - - [Fact] - public void Throws_MultipleCertificatesInline_FileAndStore_FileLoadError() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificates:Certificate1:Source"] = "Store", - ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", - ["TestConfig:Certificates:Certificate1:StoreName"] = "My", - ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificates:Certificate2:Source"] = "File", - ["TestConfig:Certificates:Certificate2:Path"] = "Certificate1.pfx", - ["TestConfig:Certificates:Certificate2:Password"] = "Password1", - }) - .Build(); - - var certificate = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Throws(new Exception(nameof(Throws_MultipleCertificatesInline_FileAndStore_FileLoadError))); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(certificate); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - certificateFileLoader.Object, - certificateStoreLoader.Object); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificates"))); - Assert.Equal($"Unable to load certificate from file 'Certificate1.pfx'. Error details: '{nameof(Throws_MultipleCertificatesInline_FileAndStore_FileLoadError)}'.", exception.Message); - } - - [Fact] - public void ReturnsNull_MultipleCertificatesInline_FileAndStore_NotFoundInStore() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificates:Certificate1:Source"] = "Store", - ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", - ["TestConfig:Certificates:Certificate1:StoreName"] = "My", - ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", - ["TestConfig:Certificates:Certificate2:Source"] = "File", - ["TestConfig:Certificates:Certificate2:Path"] = "Certificate1.pfx", - ["TestConfig:Certificates:Certificate2:Password"] = "Password1", - }) - .Build(); - - var certificate = new X509Certificate2(); - - var certificateFileLoader = new Mock(); - certificateFileLoader - .Setup(loader => loader.Load("Certificate1.pfx", "Password1", It.IsAny())) - .Returns(certificate); - - var certificateStoreLoader = new Mock(); - certificateStoreLoader - .Setup(loader => loader.Load("localhost", "My", StoreLocation.CurrentUser, It.IsAny())) - .Returns(null); - - var certificateLoader = new CertificateLoader( - null, - null, - null, - certificateFileLoader.Object, - certificateStoreLoader.Object); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(1, loadedCertificates.Count()); - Assert.Same(certificate, loadedCertificates.ElementAt(0)); - } - - [Theory] - [InlineData("Development")] - [InlineData("Production")] - public void IncludesEnvironmentNameInExceptionWhenAvailable(string environmentName) - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificate"] = "Certificate1" - }) - .Build(); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - environmentName, - Mock.Of(), - Mock.Of()); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); - Assert.Equal($"No certificate named 'Certificate1' found in configuration for the current environment ({environmentName}).", exception.Message); - } - - [Fact] - public void DoesNotIncludeEnvironmentNameInExceptionWhenNotAvailable() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificate"] = "Certificate1" - }) - .Build(); - - var certificateLoader = new CertificateLoader( - configuration.GetSection("Certificates"), - null, - null, - Mock.Of(), - Mock.Of()); - - var exception = Assert.Throws(() => certificateLoader.Load(configuration.GetSection("TestConfig:Certificate"))); - Assert.Equal("No certificate named 'Certificate1' found in configuration for the current environment.", exception.Message); - } - - [Fact] - public void WarningLoggedWhenCertificateNotFoundInStore() - { - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary - { - ["TestConfig:Certificates:Certificate1:Source"] = "Store", - ["TestConfig:Certificates:Certificate1:Subject"] = "localhost", - ["TestConfig:Certificates:Certificate1:StoreName"] = "My", - ["TestConfig:Certificates:Certificate1:StoreLocation"] = "CurrentUser", - }) - .Build(); - - var loggerFactory = new Mock(); - var logger = new MockLogger(); - - loggerFactory - .Setup(factory => factory.CreateLogger("Microsoft.AspNetCore.CertificateLoader")) - .Returns(logger); - - var certificateLoader = new CertificateLoader( - null, - loggerFactory.Object, - null, - Mock.Of(), - Mock.Of()); - - var loadedCertificates = certificateLoader.Load(configuration.GetSection("TestConfig:Certificates")); - Assert.Equal(0, loadedCertificates.Count()); - Assert.Single(logger.LogMessages, logMessage => - logMessage.LogLevel == LogLevel.Warning && - logMessage.Message == "Unable to find a matching certificate for subject 'localhost' in store 'My' in 'CurrentUser'."); - } - - private class MockLogger : ILogger - { - private readonly List _logMessages = new List(); - - public IEnumerable LogMessages => _logMessages; - - public IDisposable BeginScope(TState state) - { - throw new NotImplementedException(); - } - - public bool IsEnabled(LogLevel logLevel) - { - throw new NotImplementedException(); - } - - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) - { - _logMessages.Add(new LogMessage - { - LogLevel = logLevel, - Message = formatter(state, exception) - }); - } - - public class LogMessage - { - public LogLevel LogLevel { get; set; } - public string Message { get; set; } - } - } - } -} From 8f763b4522855585f2020a23ea23cd082e06d067 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 5 May 2017 13:00:11 -0700 Subject: [PATCH 152/361] Exclude build assets from sqlitepclraw and dependencies --- build/common.props | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/common.props b/build/common.props index 2ae8536639..18fa98827a 100644 --- a/build/common.props +++ b/build/common.props @@ -164,16 +164,19 @@ - + - + + + + - + From 9c696b3263cd0aa10847fd65280e1f5f555beb1b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:36:57 -0700 Subject: [PATCH 153/361] Branching for rel/2.0.0-preview2 --- NuGet.config | 7 ++++--- build/dependencies.props | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 0ec8c4d3b2..ad1294860c 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,9 +1,10 @@ - + - + + - + \ No newline at end of file diff --git a/build/dependencies.props b/build/dependencies.props index 302a8149fd..7668901420 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,7 @@ 0.4.0-* - 2.0.0-* + 2.0.0-preview2-* 4.4.0-* 2.1.0-* 4.7.1 From 6d221abf3ebe1791ae715cdd9f5f380f784f34f4 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 31 May 2017 19:53:26 -0700 Subject: [PATCH 154/361] Updating build scripts to point to 2.0.0-preview2 KoreBuild --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..3a2476b2b4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..a40bdb87b1 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0-preview2.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From a43bb4a6cdcbcbe4de9bedfc93846248133c6c80 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 1 Jun 2017 10:47:22 -0700 Subject: [PATCH 155/361] Updating versions to preview3 --- NuGet.config | 3 ++- version.props | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NuGet.config b/NuGet.config index 0ec8c4d3b2..8a937d9f50 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,6 +1,7 @@ - + + diff --git a/version.props b/version.props index 6af4f81de2..193a5999d8 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview2 + preview3 From de5b3560d54c4d1dd3f2ed7e8299c56145c4acb0 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 1 Jun 2017 18:45:28 -0700 Subject: [PATCH 156/361] Skip symbol generation during runtime store creation --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 85c4753dc3..0eb7b0e245 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -66,7 +66,7 @@ - + From 6fcf83fe22c07bb1266c2f7c316c40dd9459e3d2 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 2 Jun 2017 10:47:54 -0700 Subject: [PATCH 157/361] React to logging in DI change --- src/Microsoft.AspNetCore/WebHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 10917099dc..c7f0549601 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -180,7 +180,7 @@ namespace Microsoft.AspNetCore }) .ConfigureLogging((hostingContext, logging) => { - logging.UseConfiguration(hostingContext.Configuration.GetSection("Logging")); + logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); logging.AddDebug(); }) From 2625e2a7682cebaf8835ec178dd8ae86d68acee1 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 1 Jun 2017 17:21:16 -0700 Subject: [PATCH 158/361] Consolidate runtime store dependencies into one package --- build/repo.targets | 21 ++++++++++++++++++- .../Microsoft.AspNetCore.RuntimeStore.csproj | 2 +- .../Build.RuntimeStore.References.csproj | 13 ++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj diff --git a/build/repo.targets b/build/repo.targets index 0eb7b0e245..b267de7f01 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -32,6 +32,8 @@ $(ArtifactsDir)temp\ $(RepositoryRoot)tools\ $(RepositoryRoot).deps\build\ + $(ToolsDir)Build.RuntimeStore.References\ + $(RuntimeStoreReferenceDirectory)bin\Release\ $(PrepareDependsOn); UpdateNuGetConfig @@ -52,6 +54,8 @@ + + win$(PACKAGE_CACHE_PLATFORM) linux @@ -64,10 +68,25 @@ $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip + + + + + + + - + + + diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 3cce763f2b..0e7105f770 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -7,6 +7,6 @@ - + diff --git a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj new file mode 100644 index 0000000000..4a3a2eaaec --- /dev/null +++ b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj @@ -0,0 +1,13 @@ + + + + + + false + netcoreapp2.0 + + + + + + From 3932c68d1857012bead6b0436d811cf53f0741d8 Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 31 May 2017 12:50:18 -0700 Subject: [PATCH 159/361] Move KestrelServerOptionsSetup to Kestrel --- build/common.props | 1 - .../KestrelServerOptionsSetup.cs | 110 ------------------ src/Microsoft.AspNetCore/WebHost.cs | 1 - .../WebHostFunctionalTests.cs | 6 +- 4 files changed, 3 insertions(+), 115 deletions(-) delete mode 100644 src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs diff --git a/build/common.props b/build/common.props index 18fa98827a..6ce891620c 100644 --- a/build/common.props +++ b/build/common.props @@ -55,7 +55,6 @@ - diff --git a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs b/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs deleted file mode 100644 index a2a5fe1ca2..0000000000 --- a/src/Microsoft.AspNetCore/KestrelServerOptionsSetup.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Security.Cryptography.X509Certificates; -using Microsoft.AspNetCore.Certificates.Configuration; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Server.Kestrel.Core; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore -{ - internal class KestrelServerOptionsSetup : IConfigureOptions - { - private const string DefaultCertificateSubjectName = "CN=localhost"; - private const string DevelopmentSSLCertificateName = "localhost"; - - private readonly IHostingEnvironment _hostingEnvironment; - private readonly IConfiguration _configurationRoot; - private readonly ILoggerFactory _loggerFactory; - - public KestrelServerOptionsSetup( - IHostingEnvironment hostingEnvironment, - IConfiguration configurationRoot, - ILoggerFactory loggerFactory) - { - _hostingEnvironment = hostingEnvironment; - _configurationRoot = configurationRoot; - _loggerFactory = loggerFactory; - } - - public void Configure(KestrelServerOptions options) - { - BindConfiguration(options); - } - - private void BindConfiguration(KestrelServerOptions options) - { - var certificateLoader = new CertificateLoader(_configurationRoot.GetSection("Certificates"), _loggerFactory, _hostingEnvironment.EnvironmentName); - - foreach (var endPoint in _configurationRoot.GetSection("Kestrel:EndPoints").GetChildren()) - { - BindEndPoint(options, endPoint, certificateLoader); - } - } - - private void BindEndPoint( - KestrelServerOptions options, - IConfigurationSection endPoint, - CertificateLoader certificateLoader) - { - var configAddress = endPoint.GetValue("Address"); - var configPort = endPoint.GetValue("Port"); - - if (!IPAddress.TryParse(configAddress, out var address)) - { - throw new InvalidOperationException($"Invalid IP address in configuration: {configAddress}"); - } - - if (!int.TryParse(configPort, out var port)) - { - throw new InvalidOperationException($"Invalid port in configuration: {configPort}"); - } - - options.Listen(address, port, listenOptions => - { - var certificateConfig = endPoint.GetSection("Certificate"); - X509Certificate2 certificate = null; - if (certificateConfig.Exists()) - { - try - { - try - { - certificate = certificateLoader.Load(certificateConfig).FirstOrDefault(); - } - catch (KeyNotFoundException) when (certificateConfig.Value.Equals(DevelopmentSSLCertificateName, StringComparison.Ordinal) && _hostingEnvironment.IsDevelopment()) - { - var storeLoader = new CertificateStoreLoader(); - certificate = storeLoader.Load(DefaultCertificateSubjectName, "My", StoreLocation.CurrentUser, validOnly: false) ?? - storeLoader.Load(DefaultCertificateSubjectName, "My", StoreLocation.LocalMachine, validOnly: false); - - if (certificate == null) - { - var logger = _loggerFactory.CreateLogger("Microsoft.AspNetCore.KestrelOptionsSetup"); - logger.LogError("No HTTPS certificate was found for development. For information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054."); - } - } - - if (certificate == null) - { - throw new InvalidOperationException($"No certificate found for endpoint '{endPoint.Key}'."); - } - } - catch (Exception ex) - { - throw new InvalidOperationException("Unable to configure HTTPS endpoint. For information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.", ex); - } - - listenOptions.UseHttps(certificate); - } - }); - } - } -} diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index c7f0549601..7914be620e 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -191,7 +191,6 @@ namespace Microsoft.AspNetCore }) .ConfigureServices(services => { - services.AddTransient, KestrelServerOptionsSetup>(); services.ConfigureAspNetCoreDefaults(); }); diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index e7074a1bf3..58b96d5107 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Tests { File.WriteAllText("appsettings.json", @" { - ""Kestrel"": { + ""Microsoft:AspNetCore:Server:Kestrel"": { ""EndPoints"": { ""EndPoint"": { ""Address"": """ + endPointAddress + @""", @@ -142,7 +142,7 @@ namespace Microsoft.AspNetCore.Tests { File.WriteAllText("appsettings.json", @" { - ""Kestrel"": { + ""Microsoft:AspNetCore:Server:Kestrel"": { ""EndPoints"": { ""EndPoint"": { ""Address"": ""127.0.0.1"", @@ -181,7 +181,7 @@ namespace Microsoft.AspNetCore.Tests { File.WriteAllText("appsettings.json", @" { - ""Kestrel"": { + ""Microsoft:AspNetCore:Server:Kestrel"": { ""EndPoints"": { ""EndPoint"": { ""Address"": ""127.0.0.1"", From dade55083aa697a8dfc21e7b899fe23e0d3c27a5 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 2 Jun 2017 16:48:12 -0700 Subject: [PATCH 160/361] Remove Microsoft.EntityFrameworkCore.*.Design packages (#138) - https://github.com/aspnet/EntityFramework/commit/778a8434444cd05fc5b52ea4de3c6bbb6f5e252d - https://github.com/aspnet/EntityFramework/commit/32434d2d86a75e091e331940384115e447ff33de - https://github.com/aspnet/EntityFramework/commit/73e10420f58bbaa65bc6b7321e98b791b56387ba --- build/common.props | 3 --- 1 file changed, 3 deletions(-) diff --git a/build/common.props b/build/common.props index 6ce891620c..f47dadd2f3 100644 --- a/build/common.props +++ b/build/common.props @@ -174,12 +174,9 @@ - - - From 102b1ca6250021ed52c652d181475c5258731873 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Sat, 3 Jun 2017 10:20:57 -0700 Subject: [PATCH 161/361] Remove Microsoft.EntityFrameworkCore.*.Design packages (#140) - https://github.com/aspnet/EntityFramework/commit/778a8434444cd05fc5b52ea4de3c6bbb6f5e252d - https://github.com/aspnet/EntityFramework/commit/32434d2d86a75e091e331940384115e447ff33de - https://github.com/aspnet/EntityFramework/commit/73e10420f58bbaa65bc6b7321e98b791b56387ba --- src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj index 81a3815a0e..7c60bb855e 100644 --- a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj +++ b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj @@ -10,8 +10,6 @@ - - From c920c459537c21285b47b05f033a48363297e3dc Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 5 Jun 2017 13:40:32 -0700 Subject: [PATCH 162/361] Remove ConfigureDefaultOptions --- MetaPackages.sln | 9 +- build/common.props | 2 +- .../AspNetCoreExtensions.cs | 32 ----- src/Microsoft.AspNetCore/WebHost.cs | 5 - .../WebHostFunctionalTests.cs | 113 ------------------ .../ConfigurationTests.cs | 68 ----------- .../Microsoft.AspNetCore.Tests.csproj | 21 ---- 7 files changed, 2 insertions(+), 248 deletions(-) delete mode 100644 src/Microsoft.AspNetCore/AspNetCoreExtensions.cs delete mode 100644 test/Microsoft.AspNetCore.Tests/ConfigurationTests.cs delete mode 100644 test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj diff --git a/MetaPackages.sln b/MetaPackages.sln index bac992e613..9d03645441 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26524.0 +VisualStudioVersion = 15.0.26507.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -47,8 +47,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Tests", "test\Microsoft.AspNetCore.Tests\Microsoft.AspNetCore.Tests.csproj", "{914D3FAD-8B94-4353-B24F-B264F675481C}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -103,10 +101,6 @@ Global {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.Build.0 = Release|Any CPU - {914D3FAD-8B94-4353-B24F-B264F675481C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {914D3FAD-8B94-4353-B24F-B264F675481C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {914D3FAD-8B94-4353-B24F-B264F675481C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {914D3FAD-8B94-4353-B24F-B264F675481C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -126,6 +120,5 @@ Global {302400A0-98BB-4C04-88D4-C32DC2D4B945} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} - {914D3FAD-8B94-4353-B24F-B264F675481C} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} EndGlobalSection EndGlobal diff --git a/build/common.props b/build/common.props index f47dadd2f3..1c78f057b9 100644 --- a/build/common.props +++ b/build/common.props @@ -69,7 +69,6 @@ - @@ -208,6 +207,7 @@ + diff --git a/src/Microsoft.AspNetCore/AspNetCoreExtensions.cs b/src/Microsoft.AspNetCore/AspNetCoreExtensions.cs deleted file mode 100644 index ce2704246e..0000000000 --- a/src/Microsoft.AspNetCore/AspNetCoreExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; - -namespace Microsoft.AspNetCore -{ - /// - /// Exposes extension method for establishing configuration defaults. - /// - public static class AspNetCoreExtensions - { - /// - /// Allows features to do some default setup for their options, i.e. binding against the default configuration. - /// - /// The to modify. - /// The service collection. - public static IServiceCollection ConfigureAspNetCoreDefaults(this IServiceCollection services) - { - services.AddTransient(typeof(IConfigureOptions<>), typeof(ConfigureDefaults<>)); - services.AddTransient(typeof(IConfigureNamedOptions<>), typeof(ConfigureDefaults<>)); - return services; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 7914be620e..5833404e30 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -13,7 +13,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; namespace Microsoft.AspNetCore { @@ -188,10 +187,6 @@ namespace Microsoft.AspNetCore .UseDefaultServiceProvider((context, options) => { options.ValidateScopes = context.HostingEnvironment.IsDevelopment(); - }) - .ConfigureServices(services => - { - services.ConfigureAspNetCoreDefaults(); }); return builder; diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index 58b96d5107..c769193014 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -97,119 +97,6 @@ namespace Microsoft.AspNetCore.Tests }, setTestEnvVars: true, environment: environment); } - [Theory] - [InlineData("127.0.0.1", "127.0.0.1")] - [InlineData("::1", "[::1]")] - public async Task BindsKestrelHttpEndPointFromConfiguration(string endPointAddress, string requestAddress) - { - try - { - File.WriteAllText("appsettings.json", @" -{ - ""Microsoft:AspNetCore:Server:Kestrel"": { - ""EndPoints"": { - ""EndPoint"": { - ""Address"": """ + endPointAddress + @""", - ""Port"": 0 - } - } - } -} -"); - using (var webHost = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) - { - var port = GetWebHostPort(webHost); - - Assert.NotEqual(0, port); - - using (var client = new HttpClient()) - { - var response = await client.GetAsync($"http://{requestAddress}:{port}"); - response.EnsureSuccessStatusCode(); - } - } - } - finally - { - File.Delete("appsettings.json"); - } - } - - [Fact] - public async Task BindsKestrelHttpsEndPointFromConfiguration_ReferencedCertificateFile() - { - try - { - File.WriteAllText("appsettings.json", @" -{ - ""Microsoft:AspNetCore:Server:Kestrel"": { - ""EndPoints"": { - ""EndPoint"": { - ""Address"": ""127.0.0.1"", - ""Port"": 0, - ""Certificate"": ""TestCert"" - } - } - }, - ""Certificates"": { - ""TestCert"": { - ""Source"": ""File"", - ""Path"": ""testCert.pfx"", - ""Password"": ""testPassword"" - } - } -} -"); - using (var webHost = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) - { - var port = GetWebHostPort(webHost); - - var response = await HttpClientSlim.GetStringAsync($"https://127.0.0.1:{port}", validateCertificate: false); - Assert.Equal("Hello, World!", response); - } - } - finally - { - File.Delete("appsettings.json"); - } - } - - [Fact] - public async Task BindsKestrelHttpsEndPointFromConfiguration_InlineCertificateFile() - { - try - { - File.WriteAllText("appsettings.json", @" -{ - ""Microsoft:AspNetCore:Server:Kestrel"": { - ""EndPoints"": { - ""EndPoint"": { - ""Address"": ""127.0.0.1"", - ""Port"": 0, - ""Certificate"": { - ""Source"": ""File"", - ""Path"": ""testCert.pfx"", - ""Password"": ""testPassword"" - } - } - } - } -} -"); - using (var webHost = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) - { - var port = GetWebHostPort(webHost); - - var response = await HttpClientSlim.GetStringAsync($"https://127.0.0.1:{port}", validateCertificate: false); - Assert.Equal("Hello, World!", response); - } - } - finally - { - File.Delete("appsettings.json"); - } - } - [Fact] public void LoggingConfigurationSectionPassedToLoggerByDefault() { diff --git a/test/Microsoft.AspNetCore.Tests/ConfigurationTests.cs b/test/Microsoft.AspNetCore.Tests/ConfigurationTests.cs deleted file mode 100644 index 2e5362ef5d..0000000000 --- a/test/Microsoft.AspNetCore.Tests/ConfigurationTests.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. See License.txt in the project root for license information. - -using System.Collections.Generic; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Infrastructure; -using Xunit; - -namespace Microsoft.AspNetCore.Tests -{ - public class ConfigurationTests - { - private class TestOptions - { - public string Message { get; set; } - } - - private class ConfigureTestDefault : ConfigureDefaultOptions - { - public ConfigureTestDefault(IConfiguration config) : - base(options => config.GetSection("Test").Bind(options)) - { } - } - - [Fact] - public void ConfigureAspNetCoreDefaultsEnablesBindAgainstDefaultConfig() - { - var dic = new Dictionary - { - { "Test:Message", "yadayada"} - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton(config) - .AddOptions() - .AddTransient, ConfigureTestDefault>() - .ConfigureAspNetCoreDefaults(); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Value; - Assert.Equal("yadayada", options.Message); - } - - [Fact] - public void DefaultConfigIgnoredWithoutConfigureAspNetCoreDefaults() - { - var dic = new Dictionary - { - { "Test:Message", "yadayada"} - }; - var configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddInMemoryCollection(dic); - var config = configurationBuilder.Build(); - var services = new ServiceCollection() - .AddSingleton(config) - .AddOptions() - .AddTransient, ConfigureTestDefault>(); - var sp = services.BuildServiceProvider(); - - var options = sp.GetRequiredService>().Value; - Assert.Null(options.Message); - } - - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj deleted file mode 100644 index 5a3a180fbc..0000000000 --- a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - netcoreapp2.0;net461 - netcoreapp2.0 - - - - - - - - - - - - - - From cb389fe9b0065c09806913733ed07eeaf253378d Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 5 Jun 2017 17:30:13 -0700 Subject: [PATCH 163/361] Display info for dotnet used to create runtime store and deps files --- build/repo.targets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/repo.targets b/build/repo.targets index b267de7f01..36ebc010bb 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -56,6 +56,9 @@ + + + win$(PACKAGE_CACHE_PLATFORM) linux From cde593c0e063d109597cdae409004dbe5bffec76 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 5 Jun 2017 18:18:13 -0700 Subject: [PATCH 164/361] Allow overriding RuntimeFrameworkVersion used for deps generation. --- .../Microsoft.AspNetCore.HostingStartup.Template.csproj | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj index c3e6a50687..00df34bd07 100644 --- a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj +++ b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj @@ -14,9 +14,11 @@ - $(DepsOutputPath)\$(HostingStartupPackageName)\shared\Microsoft.NETCore.App\$(RuntimeFrameworkVersion)\$(HostingStartupPackageName).deps.json + $(RuntimeFrameworkVersion) + $(DepsOutputPath)\$(HostingStartupPackageName)\shared\Microsoft.NETCore.App\$(CurrentRuntimeFrameworkVersion)\$(HostingStartupPackageName).deps.json - - + + + From d0d9298f6d2c73db59ed17b6b5b4dde7a5dcad6b Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 5 Jun 2017 18:22:30 -0700 Subject: [PATCH 165/361] Put runtime version into dependencies.props and rename. --- .../Microsoft.AspNetCore.HostingStartup.Template.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj index 00df34bd07..021bb290c5 100644 --- a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj +++ b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj @@ -14,8 +14,8 @@ - $(RuntimeFrameworkVersion) - $(DepsOutputPath)\$(HostingStartupPackageName)\shared\Microsoft.NETCore.App\$(CurrentRuntimeFrameworkVersion)\$(HostingStartupPackageName).deps.json + $(RuntimeFrameworkVersion) + $(DepsOutputPath)\$(HostingStartupPackageName)\shared\Microsoft.NETCore.App\$(DepsRuntimeFrameworkVersion)\$(HostingStartupPackageName).deps.json From d4a83886dd2c3e3b520dd89236bbc76fe8cb668f Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 5 Jun 2017 20:27:51 -0700 Subject: [PATCH 166/361] Override with shared framework version --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index 7668901420..5b5eb99b64 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,6 +3,7 @@ 0.4.0-* 2.0.0-preview2-* 4.4.0-* + 2.0.0-preview2-25402-02 2.1.0-* 4.7.1 2.0.0-* From b19146dcc5a1bbdd5cf522c1238abd2e4f8509cc Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Tue, 6 Jun 2017 11:42:45 -0700 Subject: [PATCH 167/361] Update shared framework version to 2.0.0-preview2-25406-03 (#145) --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5b5eb99b64..f664d022b9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,7 +3,7 @@ 0.4.0-* 2.0.0-preview2-* 4.4.0-* - 2.0.0-preview2-25402-02 + 2.0.0-preview2-25406-03 2.1.0-* 4.7.1 2.0.0-* From 35ec06975d3b3738e83c6381d587c7c1d9e2eaf1 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 5 Jun 2017 17:11:49 -0700 Subject: [PATCH 168/361] Use file globbing to resolve manifests --- .../Microsoft.AspNetCore.All.csproj | 9 --------- .../PublishWithAspNetCoreTargetManifest.targets | 15 +++++++++------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 71fb2302b5..a6e47077d0 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -22,13 +22,4 @@ - - - $(MSBuildThisFileDirectory)build\PublishWithAspNetCoreTargetManifest.targets - - - - - - diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets index b729b98b82..f49dc6ad79 100644 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -3,10 +3,6 @@ true - - $(TargetManifestFiles);$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-win7-x64.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-win7-x86.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-osx-x64.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-linux-x64.xml - - + + + + + + + $(TargetManifestFiles);@(AspNetCoreTargetManifestFiles) + From 2fe2c324977e0ee791ece4aef453e14813914e95 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Wed, 7 Jun 2017 09:57:42 -0700 Subject: [PATCH 169/361] Remove identity service packages from the metapackage --- build/common.props | 8 -------- 1 file changed, 8 deletions(-) diff --git a/build/common.props b/build/common.props index 1c78f057b9..83f45ec078 100644 --- a/build/common.props +++ b/build/common.props @@ -104,7 +104,6 @@ - @@ -115,13 +114,6 @@ - - - - - - - From 108df3eb24faa8a250c89cce77a3458579117a76 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 7 Jun 2017 11:33:05 -0700 Subject: [PATCH 170/361] React to Logging.Configuration package addition (#146) --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index 83f45ec078..e69a14a908 100644 --- a/build/common.props +++ b/build/common.props @@ -67,6 +67,7 @@ + From f7a1d98e3109b910e2a1793055f8ba07bc6c39b5 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 7 Jun 2017 11:34:07 -0700 Subject: [PATCH 171/361] Revert "React to Logging.Configuration package addition (#146)" This reverts commit 108df3eb24faa8a250c89cce77a3458579117a76. --- build/common.props | 1 - 1 file changed, 1 deletion(-) diff --git a/build/common.props b/build/common.props index e69a14a908..83f45ec078 100644 --- a/build/common.props +++ b/build/common.props @@ -67,7 +67,6 @@ - From 8fa5e9651627c97a07a8d3f7226b9d42c0faee7e Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 7 Jun 2017 11:33:05 -0700 Subject: [PATCH 172/361] React to Logging.Configuration package addition (#146) --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index 83f45ec078..e69a14a908 100644 --- a/build/common.props +++ b/build/common.props @@ -67,6 +67,7 @@ + From 4f67914e3a9883f07af04415728baacfbf77af17 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 2 Jun 2017 20:15:45 -0700 Subject: [PATCH 173/361] Re-enable building symbols for runtime store By adding Microsoft.DiaSymReader.Native.*.dll to the path --- .gitignore | 2 + build/repo.targets | 85 ++++++++++++++++++++++------- tools/GetSharedFrameworkVersion.ps1 | 6 ++ tools/zip2tgz.sh | 31 +++++++++++ 4 files changed, 103 insertions(+), 21 deletions(-) create mode 100644 tools/GetSharedFrameworkVersion.ps1 create mode 100755 tools/zip2tgz.sh diff --git a/.gitignore b/.gitignore index 8e80baa565..3af0091ea3 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ global.json # Dependencies from pre-requisite builds .deps/ +.rw/ +.ro/ diff --git a/build/repo.targets b/build/repo.targets index 36ebc010bb..ef5f176ece 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -22,13 +22,15 @@ $(VersionPrefix)-$(OriginalVersionSuffix)-$(NoTimestampSuffix) $(VersionPrefix)-$(OriginalVersionSuffix)-$(BuildNumber) - $(MetaPackagePath)bin\work\ - $(MetaPackagePath)bin\packageCache\ + $(RepositoryRoot).rw\ + $(RepositoryRoot).ro\ $(RepositoryRoot)artifacts\ $(ArtifactsDir)zip\ $(ArtifactsDir)deps\ - $(ArtifactsZipDir)ts\ - $(ArtifactsZipDir)nt\ + $(ArtifactsZipDir)t\ + $(ArtifactsZipDir)n\ + $(ArtifactsZipDir)st\ + $(ArtifactsZipDir)sn\ $(ArtifactsDir)temp\ $(RepositoryRoot)tools\ $(RepositoryRoot).deps\build\ @@ -48,7 +50,7 @@ Condition="Exists('$(DependencyBuildDirectory)')" /> - + @@ -69,6 +71,10 @@ $(ArtifactsDir)Build.RS.$(OutputZipSufix)-$(VersionSuffix).zip $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip + $(ArtifactsDir)Build.Symbols.RS.$(OutputZipSufix)-$(VersionSuffix).zip + $(ArtifactsDir)Build.Symbols.RS.$(OutputZipSufix).zip + $(ArtifactsDir)Build.Symbols.RS.$(OutputZipSufix)-$(VersionSuffix).tar.gz + $(ArtifactsDir)Build.Symbols.RS.$(OutputZipSufix).tar.gz @@ -84,10 +90,10 @@ Condition="Exists('$(RuntimeStoreReferencePackageDirectory)')" /> - - + + - + @@ -97,42 +103,79 @@ - + aspnetcore-store-$(TimestampVersion)-$(RID).xml - <_PackageCacheFiles Include="$(PackageCacheOutputPath)**\*" Exclude="$(PackageCacheOutputPath)**\artifact.xml" /> - + <_RuntimeStoreFiles Include="$(RuntimeStoreOutputPath)**\*" Exclude="$(RuntimeStoreOutputPath)**\artifact.xml;$(RuntimeStoreOutputPath)symbols\**\*" /> + $([System.String]::new('%(RecursiveDir)').Replace('-$(BuildNumber)', '-final')) - + + <_RuntimeStoreSymbolFiles Include="$(RuntimeStoreOutputPath)symbols\**\*" /> + + $([System.String]::new('%(RecursiveDir)').Replace('-$(BuildNumber)', '-final')) + - - - - + + + + + + - + - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + $(DotnetHomeDirectory)shared\Microsoft.NETCore.App\$(SharedFrameworkVersion) + + + + + + + diff --git a/tools/GetSharedFrameworkVersion.ps1 b/tools/GetSharedFrameworkVersion.ps1 new file mode 100644 index 0000000000..9fb7365c08 --- /dev/null +++ b/tools/GetSharedFrameworkVersion.ps1 @@ -0,0 +1,6 @@ +$infoOutput = dotnet --info +$versions = $infoOutput | Select-String -Pattern "version" +$FXVersionRaw = $versions | Select-Object -Last 1 +$FXVersionString = $FXVersionRaw.ToString() +$FXVersion = $FXVersionString.SubString($FXVersionString.IndexOf(':') + 1).Trim() +Write-Host $FXVersion \ No newline at end of file diff --git a/tools/zip2tgz.sh b/tools/zip2tgz.sh new file mode 100755 index 0000000000..15a5cd2a12 --- /dev/null +++ b/tools/zip2tgz.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +if [[ $# < 2 ]]; then + echo "Usage: [src] [dest]" + exit 1 +fi + +function realpath() { + [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" +} + +src="$(realpath $1)" +dest="$(realpath $2)" + +echo "Converting:" +echo " - $src" +echo " => $dest" + +tmp="$(mktemp -d)" +echo "Using temp dir $tmp" +function cleanup() { + echo "Cleaning up" + rm -rf $tmp + echo "Done" +} +trap cleanup INT TERM EXIT +set -e + +unzip -q $src -d $tmp +chmod -R +r $tmp +tar -c -z -f $dest -C $tmp . From 859177479ca309d8a01dd18e47f7e5a2360fc1fe Mon Sep 17 00:00:00 2001 From: = Date: Wed, 7 Jun 2017 17:01:29 -0700 Subject: [PATCH 174/361] Fix PackageCache builds No symbols are generated for macOS Add environment variable to pass additional arguments to dotnet store --- build/repo.targets | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index ef5f176ece..c892592976 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -93,7 +93,7 @@ - + @@ -141,18 +141,18 @@ - - + + - - + + - + From 88eb593c4f2687fc5cee09bfb6403be1c9b9488f Mon Sep 17 00:00:00 2001 From: = Date: Wed, 7 Jun 2017 17:01:29 -0700 Subject: [PATCH 175/361] Fix PackageCache builds No symbols are generated for macOS Add environment variable to pass additional arguments to dotnet store --- build/repo.targets | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index ef5f176ece..c892592976 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -93,7 +93,7 @@ - + @@ -141,18 +141,18 @@ - - + + - - + + - + From 87665284704159fcd0fc75cb41ac9d7fc905404d Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Wed, 7 Jun 2017 17:15:39 -0700 Subject: [PATCH 176/361] Update shared framework version to 2.0.0-preview2-25407-01 --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index f664d022b9..6f95091533 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,7 +3,7 @@ 0.4.0-* 2.0.0-preview2-* 4.4.0-* - 2.0.0-preview2-25406-03 + 2.0.0-preview2-25407-01 2.1.0-* 4.7.1 2.0.0-* From 0e3f19e3bff361a02448dfc62ac1e99d29c4cff1 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 7 Jun 2017 17:23:00 -0700 Subject: [PATCH 177/361] Skip symbol zips when no symbols are produced --- build/repo.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index c892592976..d56501eef6 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -141,8 +141,8 @@ - - + + From e055aaa72fb9478737db9b34ce9f11ab587bd83d Mon Sep 17 00:00:00 2001 From: = Date: Wed, 7 Jun 2017 18:10:56 -0700 Subject: [PATCH 178/361] Fix typo --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index d56501eef6..8bc3dc002d 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -142,7 +142,7 @@ - + From d58bcba814c2427a484252533b9ee50e9b104f04 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 7 Jun 2017 19:25:37 -0700 Subject: [PATCH 179/361] Re-enable symbols generation on x86 --- build/repo.targets | 27 +++++++++++++++++++++++---- tools/GetSharedFrameworkVersion.ps1 | 2 +- tools/InstallSharedFrameworkx86.ps1 | 28 ++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 tools/InstallSharedFrameworkx86.ps1 diff --git a/build/repo.targets b/build/repo.targets index 8bc3dc002d..ffc26b1bc1 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -36,6 +36,8 @@ $(RepositoryRoot).deps\build\ $(ToolsDir)Build.RuntimeStore.References\ $(RuntimeStoreReferenceDirectory)bin\Release\ + $(RepositoryRoot).build\temp\ + $(PrepareDependsOn); UpdateNuGetConfig @@ -158,15 +160,20 @@ + + + + + + + + + - - - - $(DotnetHomeDirectory)shared\Microsoft.NETCore.App\$(SharedFrameworkVersion) @@ -176,6 +183,18 @@ + + + + + $(BuildTempDirectory)shared\Microsoft.NETCore.App\$(SharedFrameworkVersion) + + + + + + + diff --git a/tools/GetSharedFrameworkVersion.ps1 b/tools/GetSharedFrameworkVersion.ps1 index 9fb7365c08..37772625fe 100644 --- a/tools/GetSharedFrameworkVersion.ps1 +++ b/tools/GetSharedFrameworkVersion.ps1 @@ -3,4 +3,4 @@ $versions = $infoOutput | Select-String -Pattern "version" $FXVersionRaw = $versions | Select-Object -Last 1 $FXVersionString = $FXVersionRaw.ToString() $FXVersion = $FXVersionString.SubString($FXVersionString.IndexOf(':') + 1).Trim() -Write-Host $FXVersion \ No newline at end of file +Write-Host $FXVersion diff --git a/tools/InstallSharedFrameworkx86.ps1 b/tools/InstallSharedFrameworkx86.ps1 new file mode 100644 index 0000000000..9931660110 --- /dev/null +++ b/tools/InstallSharedFrameworkx86.ps1 @@ -0,0 +1,28 @@ +param ( + [string]$sharedRuntimeVersion, + [string]$installationDirectory +) + +$sharedRuntimeChannel = "master" +if ($env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL) +{ + $sharedRuntimeChannel = $env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL +} + +function InstallSharedRuntime([string] $version, [string] $channel, [string] $installDir) +{ + $sharedRuntimePath = [IO.Path]::Combine($installDir, 'shared', 'Microsoft.NETCore.App', $version) + # Avoid redownloading the CLI if it's already installed. + if (!(Test-Path $sharedRuntimePath)) + { + & "$PSScriptRoot\..\.build\dotnet\dotnet-install.ps1" ` + -Channel $channel ` + -SharedRuntime ` + -Version $version ` + -Architecture 'x86' ` + -InstallDir $installDir ` + -NoPath + } +} + +InstallSharedRuntime -version $sharedRuntimeVersion -channel $sharedRuntimeChannel -installDir $installationDirectory From 512195247a060f5e8368786a2cf7c43dbf155abf Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 12 Jun 2017 10:03:11 -0700 Subject: [PATCH 180/361] Update DiaSymReader path update MSBuild doesn't update environment variables when called through MSBuild Target --- build/repo.targets | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index ffc26b1bc1..cc8682e134 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -159,17 +159,16 @@ - + + + + - - - - - + @@ -183,7 +182,7 @@ - + From 0b844b2ccf76fcd01c25dfaf7d4b9c417a84b38a Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 14 Jun 2017 14:33:20 -0700 Subject: [PATCH 181/361] Changed all references of PackageTargetFallback to AssetTargetFallback --- src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj | 2 +- src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj index 7c60bb855e..f35af42bb5 100644 --- a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj +++ b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false netcoreapp2.0 diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 71fb2302b5..121e1766d0 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -8,7 +8,7 @@ aspnetcore Microsoft.AspNetCore.All false - $(PackageTargetFallback);portable-net45+win8+wp8+wpa81 + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81 From 07a227f2e8d0490fe3bbaa282102378710acc077 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 7 Jun 2017 16:22:01 -0700 Subject: [PATCH 182/361] Build .deb installers --- build/dependencies.props | 1 + build/repo.targets | 159 +++++++++++++++++- tools/RestoreRuntimeStore/NuGet.config | 7 + .../RestoreRuntimeStore.csproj | 13 ++ tools/debian_config.json | 30 ++++ tools/docker/debian/Dockerfile | 51 ++++++ tools/docker/ubuntu.14.04/Dockerfile | 52 ++++++ tools/docker/ubuntu.16.04/Dockerfile | 48 ++++++ tools/docker/ubuntu.16.10/Dockerfile | 52 ++++++ tools/dotnet-deb-tool-consumer/NuGet.config | 8 + .../dotnet-deb-tool-consumer.csproj | 13 ++ 11 files changed, 433 insertions(+), 1 deletion(-) create mode 100644 tools/RestoreRuntimeStore/NuGet.config create mode 100644 tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj create mode 100644 tools/debian_config.json create mode 100644 tools/docker/debian/Dockerfile create mode 100644 tools/docker/ubuntu.14.04/Dockerfile create mode 100644 tools/docker/ubuntu.16.04/Dockerfile create mode 100644 tools/docker/ubuntu.16.10/Dockerfile create mode 100644 tools/dotnet-deb-tool-consumer/NuGet.config create mode 100644 tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj diff --git a/build/dependencies.props b/build/dependencies.props index 6f95091533..6491dc142b 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,6 +4,7 @@ 2.0.0-preview2-* 4.4.0-* 2.0.0-preview2-25407-01 + 2.0.0-preview2-* 2.1.0-* 4.7.1 2.0.0-* diff --git a/build/repo.targets b/build/repo.targets index cc8682e134..2b8b8e14b6 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -31,12 +31,26 @@ $(ArtifactsZipDir)n\ $(ArtifactsZipDir)st\ $(ArtifactsZipDir)sn\ + $(ArtifactsDir)installers\ + $(ArtifactsDir)rsArchive\ + $(ArtifactsDir)itLayout\ + $(RuntimeStoreInstallerLayoutTimestampDirectory)package_root\ + $(ArtifactsDir)inLayout\ + $(RuntimeStoreInstallerLayoutNoTimestampDirectory)package_root\ + $(ArtifactsDir)itOutput\ + $(ArtifactsDir)inOutput\ $(ArtifactsDir)temp\ $(RepositoryRoot)tools\ + $(ToolsDir)docker\ $(RepositoryRoot).deps\build\ $(ToolsDir)Build.RuntimeStore.References\ $(RuntimeStoreReferenceDirectory)bin\Release\ - $(RepositoryRoot).build\temp\ + $(ToolsDir)debian_config.json + $(ToolsDir)dotnet-deb-tool-consumer\ + $(ToolsDir)RestoreRuntimeStore\ + $(RepositoryRoot).build\ + $(BuildDirectory)temp\ + $(BuildDirectory)dotnet\ $(PrepareDependsOn); @@ -289,4 +303,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + aspnetcore-store-$(TimestampVersion) + aspnetcore-store-$(NoTimestampVersion) + $(RuntimeStoreTimestampDebianPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb + $(RuntimeStoreNoTimestampDebianPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/RestoreRuntimeStore/NuGet.config b/tools/RestoreRuntimeStore/NuGet.config new file mode 100644 index 0000000000..e17aed4552 --- /dev/null +++ b/tools/RestoreRuntimeStore/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj b/tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj new file mode 100644 index 0000000000..a0392260c4 --- /dev/null +++ b/tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj @@ -0,0 +1,13 @@ + + + + + + netcoreapp2.0 + + + + + + + diff --git a/tools/debian_config.json b/tools/debian_config.json new file mode 100644 index 0000000000..65d171eb35 --- /dev/null +++ b/tools/debian_config.json @@ -0,0 +1,30 @@ +{ + "maintainer_name":"Microsoft", + "maintainer_email": "nugetaspnet@microsoft.com", + + "package_name": "aspnetcore-store", + "install_root": "/usr/share/dotnet", + + "short_description": "Microsoft ASP.NET Core Runtime Package Store 2.0.0 - Preview 2", + "long_description": "Runtime package store for Microsoft ASP.NET Core. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs.", + "homepage": "https://www.asp.net/", + + "release":{ + "package_version":"0.0.0.0", + "package_revision":"1", + "urgency" : "low", + "changelog_message" : "Bootstrap loop package" + }, + + "control": { + "priority":"standard", + "section":"devel", + "architecture":"any" + }, + + "copyright": "Microsoft", + "license": { + "type": "Apache", + "full_text": "Copyright (c) .NET Foundation. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthese files except in compliance with the License. You may obtain a copy of the\nLicense at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License." + } +} \ No newline at end of file diff --git a/tools/docker/debian/Dockerfile b/tools/docker/debian/Dockerfile new file mode 100644 index 0000000000..0c032b9d7f --- /dev/null +++ b/tools/docker/debian/Dockerfile @@ -0,0 +1,51 @@ +# +# Copyright (c) .NET Foundation. All rights reserved. +# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +# + +# Dockerfile that creates a container suitable to build dotnet-cli +FROM debian:jessie + +# Misc Dependencies for build +RUN apt-get update && \ + apt-get -qqy install \ + curl \ + unzip \ + gettext \ + sudo \ + libunwind8 \ + libkrb5-3 \ + libicu52 \ + liblttng-ust0 \ + libssl1.0.0 \ + zlib1g \ + libuuid1 \ + debhelper \ + build-essential \ + devscripts \ + git \ + cmake \ + clang-3.5 \ + wget && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Use clang as c++ compiler +RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100 +RUN update-alternatives --set c++ /usr/bin/clang++-3.5 + +# Setup User to match Host User, and give superuser permissions +ARG USER_ID=0 +RUN useradd -m code_executor -u ${USER_ID} -g sudo +RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# With the User Change, we need to change permissions on these directories +RUN chmod -R a+rwx /usr/local +RUN chmod -R a+rwx /home +RUN chmod -R 755 /usr/lib/sudo + +# Set user to the one we just created +USER ${USER_ID} + +# Set working directory +WORKDIR /opt/code diff --git a/tools/docker/ubuntu.14.04/Dockerfile b/tools/docker/ubuntu.14.04/Dockerfile new file mode 100644 index 0000000000..f039506971 --- /dev/null +++ b/tools/docker/ubuntu.14.04/Dockerfile @@ -0,0 +1,52 @@ +# +# Copyright (c) .NET Foundation. All rights reserved. +# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +# + +# Dockerfile that creates a container suitable to build dotnet-cli +FROM ubuntu:14.04 + +# Misc Dependencies for build +RUN apt-get update && \ + apt-get -qqy install \ + curl \ + unzip \ + gettext \ + sudo \ + libunwind8 \ + libkrb5-3 \ + libicu52 \ + liblttng-ust0 \ + libssl1.0.0 \ + zlib1g \ + libuuid1 \ + debhelper \ + build-essential \ + devscripts \ + git \ + cmake \ + clang-3.5 \ + lldb-3.6 \ + wget && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Use clang as c++ compiler +RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100 +RUN update-alternatives --set c++ /usr/bin/clang++-3.5 + +# Setup User to match Host User, and give superuser permissions +ARG USER_ID=0 +RUN useradd -m code_executor -u ${USER_ID} -g sudo +RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# With the User Change, we need to change permissions on these directories +RUN chmod -R a+rwx /usr/local +RUN chmod -R a+rwx /home +RUN chmod -R 755 /usr/lib/sudo + +# Set user to the one we just created +USER ${USER_ID} + +# Set working directory +WORKDIR /opt/code diff --git a/tools/docker/ubuntu.16.04/Dockerfile b/tools/docker/ubuntu.16.04/Dockerfile new file mode 100644 index 0000000000..79e76f0703 --- /dev/null +++ b/tools/docker/ubuntu.16.04/Dockerfile @@ -0,0 +1,48 @@ +# +# Copyright (c) .NET Foundation. All rights reserved. +# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +# + +FROM ubuntu:16.04 + +# Install the base toolchain we need to build anything (clang, cmake, make and the like) +# this does not include libraries that we need to compile different projects, we'd like +# them in a different layer. +RUN apt-get update && \ + apt-get install -y cmake \ + make \ + llvm-3.5 \ + clang-3.5 \ + git \ + curl \ + tar \ + sudo \ + debhelper \ + build-essential \ + devscripts \ + libunwind8 \ + libkrb5-3 \ + libicu55 \ + liblttng-ust0 \ + libssl1.0.0 \ + zlib1g \ + libuuid1 \ + liblldb-3.6 \ + wget && \ + apt-get clean + +# Setup User to match Host User, and give superuser permissions +ARG USER_ID=0 +RUN useradd -m code_executor -u ${USER_ID} -g sudo +RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# With the User Change, we need to change permissions on these directories +RUN chmod -R a+rwx /usr/local +RUN chmod -R a+rwx /home +RUN chmod -R 755 /usr/lib/sudo + +# Set user to the one we just created +USER ${USER_ID} + +# Set working directory +WORKDIR /opt/code \ No newline at end of file diff --git a/tools/docker/ubuntu.16.10/Dockerfile b/tools/docker/ubuntu.16.10/Dockerfile new file mode 100644 index 0000000000..c57bd4c3ff --- /dev/null +++ b/tools/docker/ubuntu.16.10/Dockerfile @@ -0,0 +1,52 @@ +# +# Copyright (c) .NET Foundation. All rights reserved. +# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +# + +# Dockerfile that creates a container suitable to build dotnet-cli +FROM ubuntu:16.10 + +# Misc Dependencies for build +RUN apt-get update && \ + apt-get -qqy install \ + curl \ + unzip \ + gettext \ + sudo \ + libunwind8 \ + libkrb5-3 \ + libicu57 \ + liblttng-ust0 \ + libssl1.0.0 \ + zlib1g \ + libuuid1 \ + liblldb-3.5 \ + debhelper \ + build-essential \ + devscripts \ + git \ + cmake \ + clang-3.5 \ + wget && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Use clang as c++ compiler +RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100 +RUN update-alternatives --set c++ /usr/bin/clang++-3.5 + +# Setup User to match Host User, and give superuser permissions +ARG USER_ID=0 +RUN useradd -m code_executor -u ${USER_ID} -g sudo +RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# With the User Change, we need to change permissions on these directories +RUN chmod -R a+rwx /usr/local +RUN chmod -R a+rwx /home +RUN chmod -R 755 /usr/lib/sudo + +# Set user to the one we just created +USER ${USER_ID} + +# Set working directory +WORKDIR /opt/code \ No newline at end of file diff --git a/tools/dotnet-deb-tool-consumer/NuGet.config b/tools/dotnet-deb-tool-consumer/NuGet.config new file mode 100644 index 0000000000..6deac15dda --- /dev/null +++ b/tools/dotnet-deb-tool-consumer/NuGet.config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj b/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj new file mode 100644 index 0000000000..2c37471075 --- /dev/null +++ b/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj @@ -0,0 +1,13 @@ + + + + + + netcoreapp2.0 + + + + + + + From efbc95386815b8a77f912eef3e36a7509ec7a1d3 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 15 Jun 2017 11:18:10 -0700 Subject: [PATCH 183/361] Update debian_config.json package name --- tools/debian_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/debian_config.json b/tools/debian_config.json index 65d171eb35..cf70358d53 100644 --- a/tools/debian_config.json +++ b/tools/debian_config.json @@ -5,7 +5,7 @@ "package_name": "aspnetcore-store", "install_root": "/usr/share/dotnet", - "short_description": "Microsoft ASP.NET Core Runtime Package Store 2.0.0 - Preview 2", + "short_description": "Microsoft ASP.NET Core Runtime Package Store 2.0.0 - Preview 3", "long_description": "Runtime package store for Microsoft ASP.NET Core. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs.", "homepage": "https://www.asp.net/", From 3326b3ed2a1eccf36e8093f003b9432551d2ef4e Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 15 Jun 2017 12:55:46 -0700 Subject: [PATCH 184/361] #157 Remove DockerSecrets --- build/common.props | 1 - 1 file changed, 1 deletion(-) diff --git a/build/common.props b/build/common.props index e69a14a908..08fc030aca 100644 --- a/build/common.props +++ b/build/common.props @@ -178,7 +178,6 @@ - From 531cdd5936c95adf394b115cdee3f7bf2f64ce6d Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 15 Jun 2017 13:04:03 -0700 Subject: [PATCH 185/361] Revert to SQLitePCLRaw 1.1.3 --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 6491dc142b..4a35c4bc17 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -10,7 +10,7 @@ 2.0.0-* 10.0.1 2.0.0-* - 1.1.5 + 1.1.3 15.3.0-* 2.3.0-beta2-* From 02e4933f49bd21447b0a61f3c390c55fc6b45810 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 15 Jun 2017 14:16:38 -0700 Subject: [PATCH 186/361] Remove scaffolding packages --- build/common.props | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/build/common.props b/build/common.props index 08fc030aca..4e6d84df1f 100644 --- a/build/common.props +++ b/build/common.props @@ -47,11 +47,6 @@ None - - - $(AspNetCoreVersion) - All - @@ -206,17 +201,6 @@ - - - - - - - - - - - From dd1baa9130f1eba16017aa39e76b14fb1e14665b Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 15 Jun 2017 15:15:38 -0700 Subject: [PATCH 187/361] Fix tool restore during installer build --- tools/dotnet-deb-tool-consumer/NuGet.config | 2 -- tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/dotnet-deb-tool-consumer/NuGet.config b/tools/dotnet-deb-tool-consumer/NuGet.config index 6deac15dda..60d3088e1f 100644 --- a/tools/dotnet-deb-tool-consumer/NuGet.config +++ b/tools/dotnet-deb-tool-consumer/NuGet.config @@ -1,8 +1,6 @@ - - diff --git a/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj b/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj index 2c37471075..3512a7a21c 100644 --- a/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj +++ b/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + netcoreapp1.0 From 7ac4bf14f2f2d3a9b72d2da52a8adcccd8b035d6 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 5 Jun 2017 17:11:49 -0700 Subject: [PATCH 188/361] Use file globbing to resolve manifests --- .../Microsoft.AspNetCore.All.csproj | 9 --------- .../PublishWithAspNetCoreTargetManifest.targets | 15 +++++++++------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 121e1766d0..b3fc5e5d5d 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -22,13 +22,4 @@ - - - $(MSBuildThisFileDirectory)build\PublishWithAspNetCoreTargetManifest.targets - - - - - - diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets index b729b98b82..f49dc6ad79 100644 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -3,10 +3,6 @@ true - - $(TargetManifestFiles);$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-win7-x64.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-win7-x86.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-osx-x64.xml;$(MSBuildThisFileDirectory)aspnetcore-store-__MANIFEST_VERSION__-linux-x64.xml - - + + + + + + + $(TargetManifestFiles);@(AspNetCoreTargetManifestFiles) + From 89a2dadfcad2a5811662fac93730b1283a38c346 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 19 Jun 2017 17:18:17 -0700 Subject: [PATCH 189/361] Remove ViewCompilation from publish manifests --- build/repo.targets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/repo.targets b/build/repo.targets index 2b8b8e14b6..e95b22bd99 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -166,6 +166,9 @@ + + + From dfd79297469f05da5f35df0dcf46f7e9ce24a243 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 14 Jun 2017 16:53:06 -0700 Subject: [PATCH 190/361] Build RPM installers --- build/repo.targets | 164 ++++++++++++++++++++++++++++++++--- tools/changelog | 2 + tools/docker/rhel/Dockerfile | 27 ++++++ 3 files changed, 179 insertions(+), 14 deletions(-) create mode 100644 tools/changelog create mode 100644 tools/docker/rhel/Dockerfile diff --git a/build/repo.targets b/build/repo.targets index e95b22bd99..0ef94646ec 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -22,6 +22,9 @@ $(VersionPrefix)-$(OriginalVersionSuffix)-$(NoTimestampSuffix) $(VersionPrefix)-$(OriginalVersionSuffix)-$(BuildNumber) + aspnetcore-store-$(TimestampVersion) + aspnetcore-store-$(NoTimestampVersion) + $(RepositoryRoot).rw\ $(RepositoryRoot).ro\ $(RepositoryRoot)artifacts\ @@ -46,11 +49,13 @@ $(ToolsDir)Build.RuntimeStore.References\ $(RuntimeStoreReferenceDirectory)bin\Release\ $(ToolsDir)debian_config.json + $(ToolsDir)changelog $(ToolsDir)dotnet-deb-tool-consumer\ $(ToolsDir)RestoreRuntimeStore\ $(RepositoryRoot).build\ $(BuildDirectory)temp\ $(BuildDirectory)dotnet\ + /opt/code/ $(PrepareDependsOn); @@ -307,10 +312,9 @@ - - - + + @@ -328,12 +332,146 @@ + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + $(RuntimeStoreTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm + $(RuntimeStoreNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm + @(RPMDirectories->' --directories "%(FullPath)"', ' ') + Microsoft ASP.NET Core Runtime Package Store 2.0.0 - Preview 2 + Runtime package store for Microsoft ASP.NET Core. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs. + Microsoft + nugetaspnet@microsoft.com + .NET Foundation + Apache + 1 + https://www.asp.net/ + /usr/share/dotnet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -357,12 +495,11 @@ + - aspnetcore-store-$(TimestampVersion) - aspnetcore-store-$(NoTimestampVersion) - $(RuntimeStoreTimestampDebianPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb - $(RuntimeStoreNoTimestampDebianPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb + $(RuntimeStoreTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb + $(RuntimeStoreNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb @@ -384,21 +521,20 @@ diff --git a/tools/changelog b/tools/changelog new file mode 100644 index 0000000000..51aa8e9e04 --- /dev/null +++ b/tools/changelog @@ -0,0 +1,2 @@ +* DATE Microsoft - PACKAGE_VERSION-1 +- Bootstrap loop package \ No newline at end of file diff --git a/tools/docker/rhel/Dockerfile b/tools/docker/rhel/Dockerfile new file mode 100644 index 0000000000..73247d2809 --- /dev/null +++ b/tools/docker/rhel/Dockerfile @@ -0,0 +1,27 @@ +# +# Copyright (c) .NET Foundation. All rights reserved. +# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +# + +# Dockerfile that creates a container suitable to build dotnet-cli +FROM microsoft/dotnet-buildtools-prereqs:rhel-7-rpmpkg-c982313-20174116044113 + +# Install from sudo main package TODO This package needs to be mirrored +RUN yum install -y https://www.sudo.ws/sudo/dist/packages/RHEL/7/sudo-1.8.20-3.el7.x86_64.rpm \ + && yum clean all + +# Setup User to match Host User, and give superuser permissions +ARG USER_ID=0 +RUN useradd -m code_executor -u ${USER_ID} -g root +RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# With the User Change, we need to change permssions on these directories +RUN chmod -R a+rwx /usr/local +RUN chmod -R a+rwx /home +RUN chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo + +# Set user to the one we just created +USER ${USER_ID} + +# Set working directory +WORKDIR /opt/code From fc502c7645132d69f132adf7a998c1aaf40a4a72 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 21 Jun 2017 11:09:32 -0700 Subject: [PATCH 191/361] Set license to Apache 2.0 --- build/repo.targets | 2 +- tools/debian_config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 0ef94646ec..d6c44d2375 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -381,7 +381,7 @@ Microsoft nugetaspnet@microsoft.com .NET Foundation - Apache + Apache-2.0 1 https://www.asp.net/ /usr/share/dotnet diff --git a/tools/debian_config.json b/tools/debian_config.json index 65d171eb35..64d9abd2ad 100644 --- a/tools/debian_config.json +++ b/tools/debian_config.json @@ -24,7 +24,7 @@ "copyright": "Microsoft", "license": { - "type": "Apache", + "type": "Apache-2.0", "full_text": "Copyright (c) .NET Foundation. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthese files except in compliance with the License. You may obtain a copy of the\nLicense at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License." } } \ No newline at end of file From 2d1a4e33af157b7caa9950891867b9ae4cb67581 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Wed, 21 Jun 2017 14:59:25 -0700 Subject: [PATCH 192/361] Remove Kestrel.Transport.Sockets (#170) --- build/common.props | 1 - 1 file changed, 1 deletion(-) diff --git a/build/common.props b/build/common.props index 4e6d84df1f..c54c649a59 100644 --- a/build/common.props +++ b/build/common.props @@ -143,7 +143,6 @@ - From 0e4db81898b72b6a0f193b1b9027288dbd18c92f Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 22 Jun 2017 12:47:06 -0700 Subject: [PATCH 193/361] Remove dotnet-archive and Microsoft.Dotnet.Archive --- MetaPackages.sln | 16 +- build/repo.props | 2 - build/repo.targets | 6 - .../Archive.AspNetCore.All.csproj | 2 + .../CompressionUtility.cs | 107 -- .../ConsoleProgressReport.cs | 59 - .../IndexedArchive.cs | 541 ------ .../LZMA/Common/CRC.cs | 58 - .../LZMA/Common/InBuffer.cs | 75 - .../LZMA/Common/OutBuffer.cs | 50 - .../LZMA/Compress/LZ/IMatchFinder.cs | 27 - .../LZMA/Compress/LZ/LzBinTree.cs | 370 ---- .../LZMA/Compress/LZ/LzInWindow.cs | 135 -- .../LZMA/Compress/LZ/LzOutWindow.cs | 113 -- .../LZMA/Compress/LZMA/LzmaBase.cs | 79 - .../LZMA/Compress/LZMA/LzmaDecoder.cs | 402 ----- .../LZMA/Compress/LZMA/LzmaEncoder.cs | 1483 ----------------- .../LZMA/Compress/RangeCoder/RangeCoder.cs | 237 --- .../LZMA/Compress/RangeCoder/RangeCoderBit.cs | 120 -- .../Compress/RangeCoder/RangeCoderBitTree.cs | 160 -- src/Microsoft.DotNet.Archive/LZMA/ICoder.cs | 160 -- src/Microsoft.DotNet.Archive/LZMA/README.md | 10 - .../Microsoft.DotNet.Archive.csproj | 10 - .../ProgressReport.cs | 29 - .../Properties/AssemblyInfo.cs | 6 - .../ThreadLocalZipArchive.cs | 59 - .../CommandLine/CommandArgument.cs | 29 - .../CommandLine/CommandLineApplication.cs | 693 -------- .../CommandLine/CommandOption.cs | 135 -- .../CommandLine/CommandOptionType.cs | 14 - .../CommandLine/CommandParsingException.cs | 45 - .../CommandLine/HelpMessageStrings.cs | 10 - .../CommandLine/LocalizableStrings.cs | 50 - .../CommonLocalizableStrings.cs | 189 --- src/dotnet-archive/Program.cs | 97 -- src/dotnet-archive/dotnet-archive.csproj | 16 - 36 files changed, 3 insertions(+), 5591 deletions(-) delete mode 100644 src/Microsoft.DotNet.Archive/CompressionUtility.cs delete mode 100644 src/Microsoft.DotNet.Archive/ConsoleProgressReport.cs delete mode 100644 src/Microsoft.DotNet.Archive/IndexedArchive.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Common/CRC.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Common/InBuffer.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Common/OutBuffer.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/IMatchFinder.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzBinTree.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzInWindow.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzOutWindow.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaBase.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaDecoder.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaEncoder.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoder.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBit.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/ICoder.cs delete mode 100644 src/Microsoft.DotNet.Archive/LZMA/README.md delete mode 100644 src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj delete mode 100644 src/Microsoft.DotNet.Archive/ProgressReport.cs delete mode 100644 src/Microsoft.DotNet.Archive/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.DotNet.Archive/ThreadLocalZipArchive.cs delete mode 100644 src/dotnet-archive/CommandLine/CommandArgument.cs delete mode 100644 src/dotnet-archive/CommandLine/CommandLineApplication.cs delete mode 100644 src/dotnet-archive/CommandLine/CommandOption.cs delete mode 100644 src/dotnet-archive/CommandLine/CommandOptionType.cs delete mode 100644 src/dotnet-archive/CommandLine/CommandParsingException.cs delete mode 100644 src/dotnet-archive/CommandLine/HelpMessageStrings.cs delete mode 100644 src/dotnet-archive/CommandLine/LocalizableStrings.cs delete mode 100644 src/dotnet-archive/CommonLocalizableStrings.cs delete mode 100644 src/dotnet-archive/Program.cs delete mode 100644 src/dotnet-archive/dotnet-archive.csproj diff --git a/MetaPackages.sln b/MetaPackages.sln index 9d03645441..ba7c6ada0a 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26507.0 +VisualStudioVersion = 15.0.26510.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -39,10 +39,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRequestDelegateUrlApp" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateDefaultBuilderApp", "test\TestSites\CreateDefaultBuilderApp\CreateDefaultBuilderApp.csproj", "{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-archive", "src\dotnet-archive\dotnet-archive.csproj", "{AE4216BF-D471-471B-82F3-6B6D004F7D17}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Archive", "src\Microsoft.DotNet.Archive\Microsoft.DotNet.Archive.csproj", "{302400A0-98BB-4C04-88D4-C32DC2D4B945}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\TrimDeps.csproj", "{67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" @@ -85,14 +81,6 @@ Global {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.Build.0 = Debug|Any CPU {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.ActiveCfg = Release|Any CPU {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.Build.0 = Release|Any CPU - {AE4216BF-D471-471B-82F3-6B6D004F7D17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE4216BF-D471-471B-82F3-6B6D004F7D17}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE4216BF-D471-471B-82F3-6B6D004F7D17}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE4216BF-D471-471B-82F3-6B6D004F7D17}.Release|Any CPU.Build.0 = Release|Any CPU - {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Debug|Any CPU.Build.0 = Debug|Any CPU - {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Release|Any CPU.ActiveCfg = Release|Any CPU - {302400A0-98BB-4C04-88D4-C32DC2D4B945}.Release|Any CPU.Build.0 = Release|Any CPU {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.Build.0 = Debug|Any CPU {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -116,8 +104,6 @@ Global {3A85FA52-F601-422E-A42E-9F187DB28492} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {401C741B-6C7C-4E08-9F09-C3D43D22C0DE} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} - {AE4216BF-D471-471B-82F3-6B6D004F7D17} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} - {302400A0-98BB-4C04-88D4-C32DC2D4B945} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} EndGlobalSection diff --git a/build/repo.props b/build/repo.props index 0b28f5ecaa..eab8b85f3b 100644 --- a/build/repo.props +++ b/build/repo.props @@ -2,7 +2,5 @@ - - diff --git a/build/repo.targets b/build/repo.targets index d6c44d2375..4c1eb9f35d 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -12,8 +12,6 @@ $(RepositoryRoot)src\Archive.AspNetCore.All\ $(FallbackArchiveDir)Archive.AspNetCore.All.csproj - $(RepositoryRoot)src\dotnet-archive\dotnet-archive.csproj - $(RepositoryRoot)src\dotnet-archive\bin\$(Configuration)\netcoreapp2.0\dotnet-archive.dll $(TIMESTAMP_FREE_VERSION) @@ -274,10 +272,6 @@ $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages - - - - diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj index f35af42bb5..a3e6e316d6 100644 --- a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj +++ b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj @@ -1,5 +1,7 @@ + + netcoreapp2.0 $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; diff --git a/src/Microsoft.DotNet.Archive/CompressionUtility.cs b/src/Microsoft.DotNet.Archive/CompressionUtility.cs deleted file mode 100644 index 0b4e937dc6..0000000000 --- a/src/Microsoft.DotNet.Archive/CompressionUtility.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using SevenZip; -using System; -using System.IO; - -namespace Microsoft.DotNet.Archive -{ - internal static class CompressionUtility - { - enum MeasureBy - { - Input, - Output - } - - private class LzmaProgress : ICodeProgress - { - private IProgress progress; - private long totalSize; - private string phase; - private MeasureBy measureBy; - - public LzmaProgress(IProgress progress, string phase, long totalSize, MeasureBy measureBy) - { - this.progress = progress; - this.totalSize = totalSize; - this.phase = phase; - this.measureBy = measureBy; - } - - public void SetProgress(long inSize, long outSize) - { - progress.Report(phase, measureBy == MeasureBy.Input ? inSize : outSize, totalSize); - } - } - - public static void Compress(Stream inStream, Stream outStream, IProgress progress) - { - SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder(); - - CoderPropID[] propIDs = - { - CoderPropID.DictionarySize, - CoderPropID.PosStateBits, - CoderPropID.LitContextBits, - CoderPropID.LitPosBits, - CoderPropID.Algorithm, - CoderPropID.NumFastBytes, - CoderPropID.MatchFinder, - CoderPropID.EndMarker - }; - object[] properties = - { - (Int32)(1 << 26), - (Int32)(1), - (Int32)(8), - (Int32)(0), - (Int32)(2), - (Int32)(96), - "bt4", - false - }; - - encoder.SetCoderProperties(propIDs, properties); - encoder.WriteCoderProperties(outStream); - - Int64 inSize = inStream.Length; - for (int i = 0; i < 8; i++) - { - outStream.WriteByte((Byte)(inSize >> (8 * i))); - } - - var lzmaProgress = new LzmaProgress(progress, "Compressing", inSize, MeasureBy.Input); - lzmaProgress.SetProgress(0, 0); - encoder.Code(inStream, outStream, -1, -1, lzmaProgress); - lzmaProgress.SetProgress(inSize, outStream.Length); - } - - public static void Decompress(Stream inStream, Stream outStream, IProgress progress) - { - byte[] properties = new byte[5]; - - if (inStream.Read(properties, 0, 5) != 5) - throw (new Exception("input .lzma is too short")); - - SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); - decoder.SetDecoderProperties(properties); - - long outSize = 0; - for (int i = 0; i < 8; i++) - { - int v = inStream.ReadByte(); - if (v < 0) - throw (new Exception("Can't Read 1")); - outSize |= ((long)(byte)v) << (8 * i); - } - - long compressedSize = inStream.Length - inStream.Position; - var lzmaProgress = new LzmaProgress(progress, "Decompressing", outSize, MeasureBy.Output); - lzmaProgress.SetProgress(0, 0); - decoder.Code(inStream, outStream, compressedSize, outSize, lzmaProgress); - lzmaProgress.SetProgress(inStream.Length, outSize); - } - } -} diff --git a/src/Microsoft.DotNet.Archive/ConsoleProgressReport.cs b/src/Microsoft.DotNet.Archive/ConsoleProgressReport.cs deleted file mode 100644 index e8f6cd0dff..0000000000 --- a/src/Microsoft.DotNet.Archive/ConsoleProgressReport.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Diagnostics; - -namespace Microsoft.DotNet.Archive -{ - public class ConsoleProgressReport : IProgress - { - private string _currentPhase; - private int _lastLineLength = 0; - private double _lastProgress = -1; - private Stopwatch _stopwatch; - private object _stateLock = new object(); - - public void Report(ProgressReport value) - { - long progress = (long)(100 * ((double)value.Ticks / value.Total)); - - if (progress == _lastProgress && value.Phase == _currentPhase) - { - return; - } - _lastProgress = progress; - - lock (_stateLock) - { - string line = $"{value.Phase} {progress}%"; - if (value.Phase == _currentPhase) - { - if (Console.IsOutputRedirected) - { - Console.Write($"...{progress}%"); - } - else - { - Console.Write(new string('\b', _lastLineLength)); - Console.Write(line); - } - - _lastLineLength = line.Length; - - if (progress == 100) - { - Console.WriteLine($" {_stopwatch.ElapsedMilliseconds} ms"); - } - } - else - { - Console.Write(line); - _currentPhase = value.Phase; - _lastLineLength = line.Length; - _stopwatch = Stopwatch.StartNew(); - } - } - } - } -} diff --git a/src/Microsoft.DotNet.Archive/IndexedArchive.cs b/src/Microsoft.DotNet.Archive/IndexedArchive.cs deleted file mode 100644 index e94912ea5b..0000000000 --- a/src/Microsoft.DotNet.Archive/IndexedArchive.cs +++ /dev/null @@ -1,541 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading; - -namespace Microsoft.DotNet.Archive -{ - public class IndexedArchive : IDisposable - { - private class DestinationFileInfo - { - public DestinationFileInfo(string destinationPath, string hash) - { - // Normalize the path - DestinationPath = destinationPath.Replace(Path.DirectorySeparatorChar, '/'); - Hash = hash; - } - - public string DestinationPath { get; } - public string Hash { get; } - } - - private class ArchiveSource - { - public ArchiveSource(string sourceArchive, string sourceFile, string archivePath, string hash, long size) - { - Hash = hash; - Size = size; - - // Normalize the paths - SourceArchive = sourceArchive?.Replace(Path.DirectorySeparatorChar, '/'); - SourceFile = sourceFile.Replace(Path.DirectorySeparatorChar, '/'); - ArchivePath = archivePath.Replace(Path.DirectorySeparatorChar, '/'); - } - - public string SourceArchive { get; set; } - public string SourceFile { get; set; } - public string ArchivePath { get; } - public string Hash { get; } - public string FileName { get { return Path.GetFileNameWithoutExtension(ArchivePath); } } - public string Extension { get { return Path.GetExtension(ArchivePath); } } - public long Size { get; } - - public void CopyTo(Stream destination) - { - if (!String.IsNullOrEmpty(SourceArchive)) - { - using (var zip = new ZipArchive(File.OpenRead(SourceArchive), ZipArchiveMode.Read)) - using (var sourceStream = zip.GetEntry(SourceFile)?.Open()) - { - if (sourceStream == null) - { - throw new Exception($"Couldn't find entry {SourceFile} in archive {SourceArchive}"); - } - - sourceStream.CopyTo(destination); - } - } - else - { - using (var sourceStream = File.OpenRead(SourceFile)) - { - sourceStream.CopyTo(destination); - } - } - } - } - - static string[] ZipExtensions = new[] { ".zip", ".nupkg" }; - static string IndexFileName = "index.txt"; - - // maps file hash to archve path - // $ prefix indicates that the file is not in the archive and path is a hash - private Dictionary _archiveFiles = new Dictionary(); - // maps file hash to external path - private Dictionary _externalFiles = new Dictionary(); - // lists all extracted files & hashes - private List _destFiles = new List(); - private bool _disposed = false; - private ThreadLocal _sha = new ThreadLocal(() => SHA256.Create()); - - public IndexedArchive() - { } - - private static Stream CreateTemporaryStream() - { - string temp = Path.GetTempPath(); - string tempFile = Path.Combine(temp, Guid.NewGuid().ToString()); - return File.Create(tempFile, 4096, FileOptions.DeleteOnClose); - } - - private static FileStream CreateTemporaryFileStream() - { - string temp = Path.GetTempPath(); - string tempFile = Path.Combine(temp, Guid.NewGuid().ToString()); - return new FileStream(tempFile, FileMode.Create, FileAccess.ReadWrite, FileShare.Read | FileShare.Delete, 4096, FileOptions.DeleteOnClose); - } - - public void Save(string archivePath, IProgress progress) - { - CheckDisposed(); - - using (var archiveStream = CreateTemporaryStream()) - { - using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create, true)) - { - BuildArchive(archive, progress); - } // close archive - - archiveStream.Seek(0, SeekOrigin.Begin); - - using (var lzmaStream = File.Create(archivePath)) - { - CompressionUtility.Compress(archiveStream, lzmaStream, progress); - } - } // close archiveStream - } - - private void BuildArchive(ZipArchive archive, IProgress progress) - { - // write the file index - var indexEntry = archive.CreateEntry(IndexFileName, CompressionLevel.NoCompression); - - using (var stream = indexEntry.Open()) - using (var textWriter = new StreamWriter(stream)) - { - foreach (var entry in _destFiles) - { - var archiveFile = _archiveFiles[entry.Hash]; - string archivePath = _archiveFiles[entry.Hash].ArchivePath; - if (archiveFile.SourceFile == null) - { - archivePath = "$" + archivePath; - } - - textWriter.WriteLine($"{entry.DestinationPath}|{archivePath}"); - } - } - - // sort the files so that similar files are close together - var filesToArchive = _archiveFiles.Values.ToList(); - filesToArchive.Sort((f1, f2) => - { - // first sort by extension - var comp = String.Compare(f1.Extension, f2.Extension, StringComparison.OrdinalIgnoreCase); - - if (comp == 0) - { - // then sort by filename - comp = String.Compare(f1.FileName, f2.FileName, StringComparison.OrdinalIgnoreCase); - } - - if (comp == 0) - { - // sort by file size (helps differentiate ref/lib/facade) - comp = f1.Size.CompareTo(f2.Size); - } - - if (comp == 0) - { - // finally sort by full archive path so we have stable output - comp = String.Compare(f1.ArchivePath, f2.ArchivePath, StringComparison.OrdinalIgnoreCase); - } - - return comp; - }); - - int filesAdded = 0; - // add all the files - foreach (var fileToArchive in filesToArchive) - { - var entry = archive.CreateEntry(fileToArchive.ArchivePath, CompressionLevel.NoCompression); - using (var entryStream = entry.Open()) - { - fileToArchive.CopyTo(entryStream); - } - - progress.Report("Archiving files", ++filesAdded, filesToArchive.Count); - } - } - - private abstract class ExtractOperation - { - public ExtractOperation(string destinationPath) - { - DestinationPath = destinationPath; - } - - public string DestinationPath { get; } - public virtual void DoOperation() - { - string directory = Path.GetDirectoryName(DestinationPath); - - if (!Directory.Exists(directory)) - { - Directory.CreateDirectory(directory); - } - - Execute(); - } - protected abstract void Execute(); - } - - private class CopyOperation : ExtractOperation - { - public CopyOperation(ExtractSource source, string destinationPath) : base(destinationPath) - { - Source = source; - } - public ExtractSource Source { get; } - protected override void Execute() - { - if (Source.LocalPath != null) - { - File.Copy(Source.LocalPath, DestinationPath, true); - } - else - { - using (var destinationStream = File.Create(DestinationPath)) - { - Source.CopyToStream(destinationStream); - } - } - } - } - - private class ZipOperation : ExtractOperation - { - public ZipOperation(string destinationPath) : base(destinationPath) - { - } - - private List> entries = new List>(); - - public void AddEntry(string entryName, ExtractSource source) - { - entries.Add(Tuple.Create(entryName, source)); - } - - protected override void Execute() - { - using (var archiveStream = File.Create(DestinationPath)) - using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Create)) - { - foreach (var zipSource in entries) - { - var entry = archive.CreateEntry(zipSource.Item1, CompressionLevel.Optimal); - using (var entryStream = entry.Open()) - { - zipSource.Item2.CopyToStream(entryStream); - } - } - } - } - } - - private class ExtractSource - { - private string _entryName; - private readonly string _localPath; - private ThreadLocalZipArchive _archive; - - public ExtractSource(string sourceString, Dictionary externalFiles, ThreadLocalZipArchive archive) - { - if (sourceString[0] == '$') - { - var externalHash = sourceString.Substring(1); - if (!externalFiles.TryGetValue(externalHash, out _localPath)) - { - throw new Exception("Could not find external file with hash {externalHash}."); - } - } - else - { - _entryName = sourceString; - _archive = archive; - } - } - - public string LocalPath { get { return _localPath; } } - - public void CopyToStream(Stream destinationStream) - { - if (_localPath != null) - { - using (var sourceStream = File.OpenRead(_localPath)) - { - sourceStream.CopyTo(destinationStream); - } - } - else - { - using (var sourceStream = _archive.Archive.GetEntry(_entryName).Open()) - { - sourceStream.CopyTo(destinationStream); - } - } - - } - } - - private static char[] pipeSeperator = new[] { '|' }; - public void Extract(string compressedArchivePath, string outputDirectory, IProgress progress) - { - using (var archiveStream = CreateTemporaryFileStream()) - { - // decompress the LZMA stream - using (var lzmaStream = File.OpenRead(compressedArchivePath)) - { - CompressionUtility.Decompress(lzmaStream, archiveStream, progress); - } - - var archivePath = ((FileStream)archiveStream).Name; - - // reset the uncompressed stream - archiveStream.Seek(0, SeekOrigin.Begin); - - // read as a zip archive - using (var archive = new ZipArchive(archiveStream, ZipArchiveMode.Read)) - using (var tlArchive = new ThreadLocalZipArchive(archivePath, archive)) - { - List extractOperations = new List(); - Dictionary sourceCache = new Dictionary(); - - // process the index to determine all extraction operations - var indexEntry = archive.GetEntry(IndexFileName); - using (var indexReader = new StreamReader(indexEntry.Open())) - { - Dictionary zipOperations = new Dictionary(StringComparer.OrdinalIgnoreCase); - for (var line = indexReader.ReadLine(); line != null; line = indexReader.ReadLine()) - { - var lineParts = line.Split(pipeSeperator); - if (lineParts.Length != 2) - { - throw new Exception("Unexpected index line format, too many '|'s."); - } - - string target = lineParts[0]; - string source = lineParts[1]; - - ExtractSource extractSource; - if (!sourceCache.TryGetValue(source, out extractSource)) - { - sourceCache[source] = extractSource = new ExtractSource(source, _externalFiles, tlArchive); - } - - var zipSeperatorIndex = target.IndexOf("::", StringComparison.OrdinalIgnoreCase); - - if (zipSeperatorIndex != -1) - { - string zipRelativePath = target.Substring(0, zipSeperatorIndex); - string zipEntryName = target.Substring(zipSeperatorIndex + 2); - string destinationPath = Path.Combine(outputDirectory, zipRelativePath); - - // operations on a zip file will be sequential - ZipOperation currentZipOperation; - - if (!zipOperations.TryGetValue(destinationPath, out currentZipOperation)) - { - extractOperations.Add(currentZipOperation = new ZipOperation(destinationPath)); - zipOperations.Add(destinationPath, currentZipOperation); - } - currentZipOperation.AddEntry(zipEntryName, extractSource); - } - else - { - string destinationPath = Path.Combine(outputDirectory, target); - extractOperations.Add(new CopyOperation(extractSource, destinationPath)); - } - } - } - - int opsExecuted = 0; - // execute all operations - //foreach(var extractOperation in extractOperations) - extractOperations.AsParallel().ForAll(extractOperation => - { - extractOperation.DoOperation(); - progress.Report("Expanding", Interlocked.Increment(ref opsExecuted), extractOperations.Count); - }); - } - } - } - - public void AddExternalDirectory(string externalDirectory) - { - CheckDisposed(); - foreach (var externalFile in Directory.EnumerateFiles(externalDirectory, "*", SearchOption.AllDirectories)) - { - AddExternalFile(externalFile); - } - } - - public void AddExternalFile(string externalFile) - { - CheckDisposed(); - using (var fs = File.OpenRead(externalFile)) - { - string hash = GetHash(fs); - // $ prefix indicates that the file is not in the archive and path is relative to an external directory - _archiveFiles[hash] = new ArchiveSource(null, null, "$" + hash, hash, fs.Length); - _externalFiles[hash] = externalFile; - } - } - public void AddDirectory(string sourceDirectory, IProgress progress, string destinationDirectory = null) - { - var sourceFiles = Directory.EnumerateFiles(sourceDirectory, "*", SearchOption.AllDirectories).ToArray(); - int filesAdded = 0; - sourceFiles.AsParallel().ForAll(sourceFile => - { - // path relative to the destination/extracted directory to write the file - string destinationRelativePath = sourceFile.Substring(sourceDirectory.Length + 1); - - if (destinationDirectory != null) - { - destinationRelativePath = Path.Combine(destinationDirectory, destinationRelativePath); - } - - string extension = Path.GetExtension(sourceFile); - - if (ZipExtensions.Any(ze => ze.Equals(extension, StringComparison.OrdinalIgnoreCase))) - { - AddZip(sourceFile, destinationRelativePath); - } - else - { - AddFile(sourceFile, destinationRelativePath); - } - - progress.Report($"Adding {sourceDirectory}", Interlocked.Increment(ref filesAdded), sourceFiles.Length); - }); - } - - public void AddZip(string sourceZipFile, string destinationZipFile) - { - CheckDisposed(); - - using (var sourceArchive = new ZipArchive(File.OpenRead(sourceZipFile), ZipArchiveMode.Read)) - { - foreach (var entry in sourceArchive.Entries) - { - string hash = null; - long size = entry.Length; - string destinationPath = $"{destinationZipFile}::{entry.FullName}"; - using (var stream = entry.Open()) - { - hash = GetHash(stream); - } - - AddArchiveSource(sourceZipFile, entry.FullName, destinationPath, hash, size); - } - } - } - - public void AddFile(string sourceFilePath, string destinationPath) - { - CheckDisposed(); - - string hash; - long size; - // lifetime of this stream is managed by AddStream - using (var stream = File.Open(sourceFilePath, FileMode.Open)) - { - hash = GetHash(stream); - size = stream.Length; - } - - AddArchiveSource(null, sourceFilePath, destinationPath, hash, size); - } - - private void AddArchiveSource(string sourceArchive, string sourceFile, string destinationPath, string hash, long size) - { - lock (_archiveFiles) - { - _destFiles.Add(new DestinationFileInfo(destinationPath, hash)); - - // see if we already have this file in the archive/external - ArchiveSource existing = null; - if (_archiveFiles.TryGetValue(hash, out existing)) - { - // if we have raw source file, prefer that over a zipped source file - if (sourceArchive == null && existing.SourceArchive != null) - { - existing.SourceArchive = null; - existing.SourceFile = sourceFile; - } - } - else - { - var archivePath = Path.Combine(hash, Path.GetFileName(destinationPath)); - - _archiveFiles.Add(hash, new ArchiveSource(sourceArchive, sourceFile, archivePath, hash, size)); - } - } - } - - public string GetHash(Stream stream) - { - var hashBytes = _sha.Value.ComputeHash(stream); - - return GetHashString(hashBytes); - } - - private static string GetHashString(byte[] hashBytes) - { - StringBuilder builder = new StringBuilder(hashBytes.Length * 2); - foreach (var b in hashBytes) - { - builder.AppendFormat("{0:x2}", b); - } - return builder.ToString(); - } - - public void Dispose() - { - if (!_disposed) - { - if (_sha != null) - { - _sha.Dispose(); - _sha = null; - } - } - } - - private void CheckDisposed() - { - if (_disposed) - { - throw new ObjectDisposedException(nameof(IndexedArchive)); - } - } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Common/CRC.cs b/src/Microsoft.DotNet.Archive/LZMA/Common/CRC.cs deleted file mode 100644 index 5d38bf911b..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Common/CRC.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// Common/CRC.cs - -namespace SevenZip -{ - class CRC - { - public static readonly uint[] Table; - - static CRC() - { - Table = new uint[256]; - const uint kPoly = 0xEDB88320; - for (uint i = 0; i < 256; i++) - { - uint r = i; - for (int j = 0; j < 8; j++) - if ((r & 1) != 0) - r = (r >> 1) ^ kPoly; - else - r >>= 1; - Table[i] = r; - } - } - - uint _value = 0xFFFFFFFF; - - public void Init() { _value = 0xFFFFFFFF; } - - public void UpdateByte(byte b) - { - _value = Table[(((byte)(_value)) ^ b)] ^ (_value >> 8); - } - - public void Update(byte[] data, uint offset, uint size) - { - for (uint i = 0; i < size; i++) - _value = Table[(((byte)(_value)) ^ data[offset + i])] ^ (_value >> 8); - } - - public uint GetDigest() { return _value ^ 0xFFFFFFFF; } - - static uint CalculateDigest(byte[] data, uint offset, uint size) - { - CRC crc = new CRC(); - // crc.Init(); - crc.Update(data, offset, size); - return crc.GetDigest(); - } - - static bool VerifyDigest(uint digest, byte[] data, uint offset, uint size) - { - return (CalculateDigest(data, offset, size) == digest); - } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Common/InBuffer.cs b/src/Microsoft.DotNet.Archive/LZMA/Common/InBuffer.cs deleted file mode 100644 index a26bf4a29b..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Common/InBuffer.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// InBuffer.cs - -namespace SevenZip.Buffer -{ - public class InBuffer - { - byte[] m_Buffer; - uint m_Pos; - uint m_Limit; - uint m_BufferSize; - System.IO.Stream m_Stream; - bool m_StreamWasExhausted; - ulong m_ProcessedSize; - - public InBuffer(uint bufferSize) - { - m_Buffer = new byte[bufferSize]; - m_BufferSize = bufferSize; - } - - public void Init(System.IO.Stream stream) - { - m_Stream = stream; - m_ProcessedSize = 0; - m_Limit = 0; - m_Pos = 0; - m_StreamWasExhausted = false; - } - - public bool ReadBlock() - { - if (m_StreamWasExhausted) - return false; - m_ProcessedSize += m_Pos; - int aNumProcessedBytes = m_Stream.Read(m_Buffer, 0, (int)m_BufferSize); - m_Pos = 0; - m_Limit = (uint)aNumProcessedBytes; - m_StreamWasExhausted = (aNumProcessedBytes == 0); - return (!m_StreamWasExhausted); - } - - - public void ReleaseStream() - { - // m_Stream.Close(); - m_Stream = null; - } - - public bool ReadByte(byte b) // check it - { - if (m_Pos >= m_Limit) - if (!ReadBlock()) - return false; - b = m_Buffer[m_Pos++]; - return true; - } - - public byte ReadByte() - { - // return (byte)m_Stream.ReadByte(); - if (m_Pos >= m_Limit) - if (!ReadBlock()) - return 0xFF; - return m_Buffer[m_Pos++]; - } - - public ulong GetProcessedSize() - { - return m_ProcessedSize + m_Pos; - } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Common/OutBuffer.cs b/src/Microsoft.DotNet.Archive/LZMA/Common/OutBuffer.cs deleted file mode 100644 index 429bccfc91..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Common/OutBuffer.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// OutBuffer.cs - -namespace SevenZip.Buffer -{ - public class OutBuffer - { - byte[] m_Buffer; - uint m_Pos; - uint m_BufferSize; - System.IO.Stream m_Stream; - ulong m_ProcessedSize; - - public OutBuffer(uint bufferSize) - { - m_Buffer = new byte[bufferSize]; - m_BufferSize = bufferSize; - } - - public void SetStream(System.IO.Stream stream) { m_Stream = stream; } - public void FlushStream() { m_Stream.Flush(); } - public void CloseStream() { m_Stream.Dispose(); } - public void ReleaseStream() { m_Stream = null; } - - public void Init() - { - m_ProcessedSize = 0; - m_Pos = 0; - } - - public void WriteByte(byte b) - { - m_Buffer[m_Pos++] = b; - if (m_Pos >= m_BufferSize) - FlushData(); - } - - public void FlushData() - { - if (m_Pos == 0) - return; - m_Stream.Write(m_Buffer, 0, (int)m_Pos); - m_Pos = 0; - } - - public ulong GetProcessedSize() { return m_ProcessedSize + m_Pos; } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/IMatchFinder.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/IMatchFinder.cs deleted file mode 100644 index 2916aedb0f..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/IMatchFinder.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// IMatchFinder.cs - -using System; - -namespace SevenZip.Compression.LZ -{ - interface IInWindowStream - { - void SetStream(System.IO.Stream inStream); - void Init(); - void ReleaseStream(); - Byte GetIndexByte(Int32 index); - UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit); - UInt32 GetNumAvailableBytes(); - } - - interface IMatchFinder : IInWindowStream - { - void Create(UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter); - UInt32 GetMatches(UInt32[] distances); - void Skip(UInt32 num); - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzBinTree.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzBinTree.cs deleted file mode 100644 index 017cf8ea2f..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzBinTree.cs +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// LzBinTree.cs - -using System; - -namespace SevenZip.Compression.LZ -{ - public class BinTree : InWindow, IMatchFinder - { - UInt32 _cyclicBufferPos; - UInt32 _cyclicBufferSize = 0; - UInt32 _matchMaxLen; - - UInt32[] _son; - UInt32[] _hash; - - UInt32 _cutValue = 0xFF; - UInt32 _hashMask; - UInt32 _hashSizeSum = 0; - - bool HASH_ARRAY = true; - - const UInt32 kHash2Size = 1 << 10; - const UInt32 kHash3Size = 1 << 16; - const UInt32 kBT2HashSize = 1 << 16; - const UInt32 kStartMaxLen = 1; - const UInt32 kHash3Offset = kHash2Size; - const UInt32 kEmptyHashValue = 0; - const UInt32 kMaxValForNormalize = ((UInt32)1 << 31) - 1; - - UInt32 kNumHashDirectBytes = 0; - UInt32 kMinMatchCheck = 4; - UInt32 kFixHashSize = kHash2Size + kHash3Size; - - public void SetType(int numHashBytes) - { - HASH_ARRAY = (numHashBytes > 2); - if (HASH_ARRAY) - { - kNumHashDirectBytes = 0; - kMinMatchCheck = 4; - kFixHashSize = kHash2Size + kHash3Size; - } - else - { - kNumHashDirectBytes = 2; - kMinMatchCheck = 2 + 1; - kFixHashSize = 0; - } - } - - public new void SetStream(System.IO.Stream stream) { base.SetStream(stream); } - public new void ReleaseStream() { base.ReleaseStream(); } - - public new void Init() - { - base.Init(); - for (UInt32 i = 0; i < _hashSizeSum; i++) - _hash[i] = kEmptyHashValue; - _cyclicBufferPos = 0; - ReduceOffsets(-1); - } - - public new void MovePos() - { - if (++_cyclicBufferPos >= _cyclicBufferSize) - _cyclicBufferPos = 0; - base.MovePos(); - if (_pos == kMaxValForNormalize) - Normalize(); - } - - public new Byte GetIndexByte(Int32 index) { return base.GetIndexByte(index); } - - public new UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) - { return base.GetMatchLen(index, distance, limit); } - - public new UInt32 GetNumAvailableBytes() { return base.GetNumAvailableBytes(); } - - public void Create(UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter) - { - if (historySize > kMaxValForNormalize - 256) - throw new Exception(); - _cutValue = 16 + (matchMaxLen >> 1); - - UInt32 windowReservSize = (historySize + keepAddBufferBefore + - matchMaxLen + keepAddBufferAfter) / 2 + 256; - - base.Create(historySize + keepAddBufferBefore, matchMaxLen + keepAddBufferAfter, windowReservSize); - - _matchMaxLen = matchMaxLen; - - UInt32 cyclicBufferSize = historySize + 1; - if (_cyclicBufferSize != cyclicBufferSize) - _son = new UInt32[(_cyclicBufferSize = cyclicBufferSize) * 2]; - - UInt32 hs = kBT2HashSize; - - if (HASH_ARRAY) - { - hs = historySize - 1; - hs |= (hs >> 1); - hs |= (hs >> 2); - hs |= (hs >> 4); - hs |= (hs >> 8); - hs >>= 1; - hs |= 0xFFFF; - if (hs > (1 << 24)) - hs >>= 1; - _hashMask = hs; - hs++; - hs += kFixHashSize; - } - if (hs != _hashSizeSum) - _hash = new UInt32[_hashSizeSum = hs]; - } - - public UInt32 GetMatches(UInt32[] distances) - { - UInt32 lenLimit; - if (_pos + _matchMaxLen <= _streamPos) - lenLimit = _matchMaxLen; - else - { - lenLimit = _streamPos - _pos; - if (lenLimit < kMinMatchCheck) - { - MovePos(); - return 0; - } - } - - UInt32 offset = 0; - UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0; - UInt32 cur = _bufferOffset + _pos; - UInt32 maxLen = kStartMaxLen; // to avoid items for len < hashSize; - UInt32 hashValue, hash2Value = 0, hash3Value = 0; - - if (HASH_ARRAY) - { - UInt32 temp = CRC.Table[_bufferBase[cur]] ^ _bufferBase[cur + 1]; - hash2Value = temp & (kHash2Size - 1); - temp ^= ((UInt32)(_bufferBase[cur + 2]) << 8); - hash3Value = temp & (kHash3Size - 1); - hashValue = (temp ^ (CRC.Table[_bufferBase[cur + 3]] << 5)) & _hashMask; - } - else - hashValue = _bufferBase[cur] ^ ((UInt32)(_bufferBase[cur + 1]) << 8); - - UInt32 curMatch = _hash[kFixHashSize + hashValue]; - if (HASH_ARRAY) - { - UInt32 curMatch2 = _hash[hash2Value]; - UInt32 curMatch3 = _hash[kHash3Offset + hash3Value]; - _hash[hash2Value] = _pos; - _hash[kHash3Offset + hash3Value] = _pos; - if (curMatch2 > matchMinPos) - if (_bufferBase[_bufferOffset + curMatch2] == _bufferBase[cur]) - { - distances[offset++] = maxLen = 2; - distances[offset++] = _pos - curMatch2 - 1; - } - if (curMatch3 > matchMinPos) - if (_bufferBase[_bufferOffset + curMatch3] == _bufferBase[cur]) - { - if (curMatch3 == curMatch2) - offset -= 2; - distances[offset++] = maxLen = 3; - distances[offset++] = _pos - curMatch3 - 1; - curMatch2 = curMatch3; - } - if (offset != 0 && curMatch2 == curMatch) - { - offset -= 2; - maxLen = kStartMaxLen; - } - } - - _hash[kFixHashSize + hashValue] = _pos; - - UInt32 ptr0 = (_cyclicBufferPos << 1) + 1; - UInt32 ptr1 = (_cyclicBufferPos << 1); - - UInt32 len0, len1; - len0 = len1 = kNumHashDirectBytes; - - if (kNumHashDirectBytes != 0) - { - if (curMatch > matchMinPos) - { - if (_bufferBase[_bufferOffset + curMatch + kNumHashDirectBytes] != - _bufferBase[cur + kNumHashDirectBytes]) - { - distances[offset++] = maxLen = kNumHashDirectBytes; - distances[offset++] = _pos - curMatch - 1; - } - } - } - - UInt32 count = _cutValue; - - while(true) - { - if(curMatch <= matchMinPos || count-- == 0) - { - _son[ptr0] = _son[ptr1] = kEmptyHashValue; - break; - } - UInt32 delta = _pos - curMatch; - UInt32 cyclicPos = ((delta <= _cyclicBufferPos) ? - (_cyclicBufferPos - delta) : - (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; - - UInt32 pby1 = _bufferOffset + curMatch; - UInt32 len = Math.Min(len0, len1); - if (_bufferBase[pby1 + len] == _bufferBase[cur + len]) - { - while(++len != lenLimit) - if (_bufferBase[pby1 + len] != _bufferBase[cur + len]) - break; - if (maxLen < len) - { - distances[offset++] = maxLen = len; - distances[offset++] = delta - 1; - if (len == lenLimit) - { - _son[ptr1] = _son[cyclicPos]; - _son[ptr0] = _son[cyclicPos + 1]; - break; - } - } - } - if (_bufferBase[pby1 + len] < _bufferBase[cur + len]) - { - _son[ptr1] = curMatch; - ptr1 = cyclicPos + 1; - curMatch = _son[ptr1]; - len1 = len; - } - else - { - _son[ptr0] = curMatch; - ptr0 = cyclicPos; - curMatch = _son[ptr0]; - len0 = len; - } - } - MovePos(); - return offset; - } - - public void Skip(UInt32 num) - { - do - { - UInt32 lenLimit; - if (_pos + _matchMaxLen <= _streamPos) - lenLimit = _matchMaxLen; - else - { - lenLimit = _streamPos - _pos; - if (lenLimit < kMinMatchCheck) - { - MovePos(); - continue; - } - } - - UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0; - UInt32 cur = _bufferOffset + _pos; - - UInt32 hashValue; - - if (HASH_ARRAY) - { - UInt32 temp = CRC.Table[_bufferBase[cur]] ^ _bufferBase[cur + 1]; - UInt32 hash2Value = temp & (kHash2Size - 1); - _hash[hash2Value] = _pos; - temp ^= ((UInt32)(_bufferBase[cur + 2]) << 8); - UInt32 hash3Value = temp & (kHash3Size - 1); - _hash[kHash3Offset + hash3Value] = _pos; - hashValue = (temp ^ (CRC.Table[_bufferBase[cur + 3]] << 5)) & _hashMask; - } - else - hashValue = _bufferBase[cur] ^ ((UInt32)(_bufferBase[cur + 1]) << 8); - - UInt32 curMatch = _hash[kFixHashSize + hashValue]; - _hash[kFixHashSize + hashValue] = _pos; - - UInt32 ptr0 = (_cyclicBufferPos << 1) + 1; - UInt32 ptr1 = (_cyclicBufferPos << 1); - - UInt32 len0, len1; - len0 = len1 = kNumHashDirectBytes; - - UInt32 count = _cutValue; - while (true) - { - if (curMatch <= matchMinPos || count-- == 0) - { - _son[ptr0] = _son[ptr1] = kEmptyHashValue; - break; - } - - UInt32 delta = _pos - curMatch; - UInt32 cyclicPos = ((delta <= _cyclicBufferPos) ? - (_cyclicBufferPos - delta) : - (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; - - UInt32 pby1 = _bufferOffset + curMatch; - UInt32 len = Math.Min(len0, len1); - if (_bufferBase[pby1 + len] == _bufferBase[cur + len]) - { - while (++len != lenLimit) - if (_bufferBase[pby1 + len] != _bufferBase[cur + len]) - break; - if (len == lenLimit) - { - _son[ptr1] = _son[cyclicPos]; - _son[ptr0] = _son[cyclicPos + 1]; - break; - } - } - if (_bufferBase[pby1 + len] < _bufferBase[cur + len]) - { - _son[ptr1] = curMatch; - ptr1 = cyclicPos + 1; - curMatch = _son[ptr1]; - len1 = len; - } - else - { - _son[ptr0] = curMatch; - ptr0 = cyclicPos; - curMatch = _son[ptr0]; - len0 = len; - } - } - MovePos(); - } - while (--num != 0); - } - - void NormalizeLinks(UInt32[] items, UInt32 numItems, UInt32 subValue) - { - for (UInt32 i = 0; i < numItems; i++) - { - UInt32 value = items[i]; - if (value <= subValue) - value = kEmptyHashValue; - else - value -= subValue; - items[i] = value; - } - } - - void Normalize() - { - UInt32 subValue = _pos - _cyclicBufferSize; - NormalizeLinks(_son, _cyclicBufferSize * 2, subValue); - NormalizeLinks(_hash, _hashSizeSum, subValue); - ReduceOffsets((Int32)subValue); - } - - public void SetCutValue(UInt32 cutValue) { _cutValue = cutValue; } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzInWindow.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzInWindow.cs deleted file mode 100644 index 1ee8282f11..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzInWindow.cs +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// LzInWindow.cs - -using System; - -namespace SevenZip.Compression.LZ -{ - public class InWindow - { - public Byte[] _bufferBase = null; // pointer to buffer with data - System.IO.Stream _stream; - UInt32 _posLimit; // offset (from _buffer) of first byte when new block reading must be done - bool _streamEndWasReached; // if (true) then _streamPos shows real end of stream - - UInt32 _pointerToLastSafePosition; - - public UInt32 _bufferOffset; - - public UInt32 _blockSize; // Size of Allocated memory block - public UInt32 _pos; // offset (from _buffer) of curent byte - UInt32 _keepSizeBefore; // how many BYTEs must be kept in buffer before _pos - UInt32 _keepSizeAfter; // how many BYTEs must be kept buffer after _pos - public UInt32 _streamPos; // offset (from _buffer) of first not read byte from Stream - - public void MoveBlock() - { - UInt32 offset = (UInt32)(_bufferOffset) + _pos - _keepSizeBefore; - // we need one additional byte, since MovePos moves on 1 byte. - if (offset > 0) - offset--; - - UInt32 numBytes = (UInt32)(_bufferOffset) + _streamPos - offset; - - // check negative offset ???? - for (UInt32 i = 0; i < numBytes; i++) - _bufferBase[i] = _bufferBase[offset + i]; - _bufferOffset -= offset; - } - - public virtual void ReadBlock() - { - if (_streamEndWasReached) - return; - while (true) - { - int size = (int)((0 - _bufferOffset) + _blockSize - _streamPos); - if (size == 0) - return; - int numReadBytes = _stream.Read(_bufferBase, (int)(_bufferOffset + _streamPos), size); - if (numReadBytes == 0) - { - _posLimit = _streamPos; - UInt32 pointerToPostion = _bufferOffset + _posLimit; - if (pointerToPostion > _pointerToLastSafePosition) - _posLimit = (UInt32)(_pointerToLastSafePosition - _bufferOffset); - - _streamEndWasReached = true; - return; - } - _streamPos += (UInt32)numReadBytes; - if (_streamPos >= _pos + _keepSizeAfter) - _posLimit = _streamPos - _keepSizeAfter; - } - } - - void Free() { _bufferBase = null; } - - public void Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv) - { - _keepSizeBefore = keepSizeBefore; - _keepSizeAfter = keepSizeAfter; - UInt32 blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv; - if (_bufferBase == null || _blockSize != blockSize) - { - Free(); - _blockSize = blockSize; - _bufferBase = new Byte[_blockSize]; - } - _pointerToLastSafePosition = _blockSize - keepSizeAfter; - } - - public void SetStream(System.IO.Stream stream) { _stream = stream; } - public void ReleaseStream() { _stream = null; } - - public void Init() - { - _bufferOffset = 0; - _pos = 0; - _streamPos = 0; - _streamEndWasReached = false; - ReadBlock(); - } - - public void MovePos() - { - _pos++; - if (_pos > _posLimit) - { - UInt32 pointerToPostion = _bufferOffset + _pos; - if (pointerToPostion > _pointerToLastSafePosition) - MoveBlock(); - ReadBlock(); - } - } - - public Byte GetIndexByte(Int32 index) { return _bufferBase[_bufferOffset + _pos + index]; } - - // index + limit have not to exceed _keepSizeAfter; - public UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) - { - if (_streamEndWasReached) - if ((_pos + index) + limit > _streamPos) - limit = _streamPos - (UInt32)(_pos + index); - distance++; - // Byte *pby = _buffer + (size_t)_pos + index; - UInt32 pby = _bufferOffset + _pos + (UInt32)index; - - UInt32 i; - for (i = 0; i < limit && _bufferBase[pby + i] == _bufferBase[pby + i - distance]; i++); - return i; - } - - public UInt32 GetNumAvailableBytes() { return _streamPos - _pos; } - - public void ReduceOffsets(Int32 subValue) - { - _bufferOffset += (UInt32)subValue; - _posLimit -= (UInt32)subValue; - _pos -= (UInt32)subValue; - _streamPos -= (UInt32)subValue; - } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzOutWindow.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzOutWindow.cs deleted file mode 100644 index 479ae4f130..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZ/LzOutWindow.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// LzOutWindow.cs - -namespace SevenZip.Compression.LZ -{ - public class OutWindow - { - byte[] _buffer = null; - uint _pos; - uint _windowSize = 0; - uint _streamPos; - System.IO.Stream _stream; - - public uint TrainSize = 0; - - public void Create(uint windowSize) - { - if (_windowSize != windowSize) - { - // System.GC.Collect(); - _buffer = new byte[windowSize]; - } - _windowSize = windowSize; - _pos = 0; - _streamPos = 0; - } - - public void Init(System.IO.Stream stream, bool solid) - { - ReleaseStream(); - _stream = stream; - if (!solid) - { - _streamPos = 0; - _pos = 0; - TrainSize = 0; - } - } - - public bool Train(System.IO.Stream stream) - { - long len = stream.Length; - uint size = (len < _windowSize) ? (uint)len : _windowSize; - TrainSize = size; - stream.Position = len - size; - _streamPos = _pos = 0; - while (size > 0) - { - uint curSize = _windowSize - _pos; - if (size < curSize) - curSize = size; - int numReadBytes = stream.Read(_buffer, (int)_pos, (int)curSize); - if (numReadBytes == 0) - return false; - size -= (uint)numReadBytes; - _pos += (uint)numReadBytes; - _streamPos += (uint)numReadBytes; - if (_pos == _windowSize) - _streamPos = _pos = 0; - } - return true; - } - - public void ReleaseStream() - { - Flush(); - _stream = null; - } - - public void Flush() - { - uint size = _pos - _streamPos; - if (size == 0) - return; - _stream.Write(_buffer, (int)_streamPos, (int)size); - if (_pos >= _windowSize) - _pos = 0; - _streamPos = _pos; - } - - public void CopyBlock(uint distance, uint len) - { - uint pos = _pos - distance - 1; - if (pos >= _windowSize) - pos += _windowSize; - for (; len > 0; len--) - { - if (pos >= _windowSize) - pos = 0; - _buffer[_pos++] = _buffer[pos++]; - if (_pos >= _windowSize) - Flush(); - } - } - - public void PutByte(byte b) - { - _buffer[_pos++] = b; - if (_pos >= _windowSize) - Flush(); - } - - public byte GetByte(uint distance) - { - uint pos = _pos - distance - 1; - if (pos >= _windowSize) - pos += _windowSize; - return _buffer[pos]; - } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaBase.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaBase.cs deleted file mode 100644 index f4a8f823f0..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaBase.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// LzmaBase.cs - -namespace SevenZip.Compression.LZMA -{ - internal abstract class Base - { - public const uint kNumRepDistances = 4; - public const uint kNumStates = 12; - - // static byte []kLiteralNextStates = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; - // static byte []kMatchNextStates = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; - // static byte []kRepNextStates = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; - // static byte []kShortRepNextStates = {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; - - public struct State - { - public uint Index; - public void Init() { Index = 0; } - public void UpdateChar() - { - if (Index < 4) Index = 0; - else if (Index < 10) Index -= 3; - else Index -= 6; - } - public void UpdateMatch() { Index = (uint)(Index < 7 ? 7 : 10); } - public void UpdateRep() { Index = (uint)(Index < 7 ? 8 : 11); } - public void UpdateShortRep() { Index = (uint)(Index < 7 ? 9 : 11); } - public bool IsCharState() { return Index < 7; } - } - - public const int kNumPosSlotBits = 6; - public const int kDicLogSizeMin = 0; - // public const int kDicLogSizeMax = 30; - // public const uint kDistTableSizeMax = kDicLogSizeMax * 2; - - public const int kNumLenToPosStatesBits = 2; // it's for speed optimization - public const uint kNumLenToPosStates = 1 << kNumLenToPosStatesBits; - - public const uint kMatchMinLen = 2; - - public static uint GetLenToPosState(uint len) - { - len -= kMatchMinLen; - if (len < kNumLenToPosStates) - return len; - return (uint)(kNumLenToPosStates - 1); - } - - public const int kNumAlignBits = 4; - public const uint kAlignTableSize = 1 << kNumAlignBits; - public const uint kAlignMask = (kAlignTableSize - 1); - - public const uint kStartPosModelIndex = 4; - public const uint kEndPosModelIndex = 14; - public const uint kNumPosModels = kEndPosModelIndex - kStartPosModelIndex; - - public const uint kNumFullDistances = 1 << ((int)kEndPosModelIndex / 2); - - public const uint kNumLitPosStatesBitsEncodingMax = 4; - public const uint kNumLitContextBitsMax = 8; - - public const int kNumPosStatesBitsMax = 4; - public const uint kNumPosStatesMax = (1 << kNumPosStatesBitsMax); - public const int kNumPosStatesBitsEncodingMax = 4; - public const uint kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax); - - public const int kNumLowLenBits = 3; - public const int kNumMidLenBits = 3; - public const int kNumHighLenBits = 8; - public const uint kNumLowLenSymbols = 1 << kNumLowLenBits; - public const uint kNumMidLenSymbols = 1 << kNumMidLenBits; - public const uint kNumLenSymbols = kNumLowLenSymbols + kNumMidLenSymbols + - (1 << kNumHighLenBits); - public const uint kMatchMaxLen = kMatchMinLen + kNumLenSymbols - 1; - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaDecoder.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaDecoder.cs deleted file mode 100644 index 95d42eed06..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaDecoder.cs +++ /dev/null @@ -1,402 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// LzmaDecoder.cs - -using System; - -namespace SevenZip.Compression.LZMA -{ - using RangeCoder; - - public class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream - { - class LenDecoder - { - BitDecoder m_Choice = new BitDecoder(); - BitDecoder m_Choice2 = new BitDecoder(); - BitTreeDecoder[] m_LowCoder = new BitTreeDecoder[Base.kNumPosStatesMax]; - BitTreeDecoder[] m_MidCoder = new BitTreeDecoder[Base.kNumPosStatesMax]; - BitTreeDecoder m_HighCoder = new BitTreeDecoder(Base.kNumHighLenBits); - uint m_NumPosStates = 0; - - public void Create(uint numPosStates) - { - for (uint posState = m_NumPosStates; posState < numPosStates; posState++) - { - m_LowCoder[posState] = new BitTreeDecoder(Base.kNumLowLenBits); - m_MidCoder[posState] = new BitTreeDecoder(Base.kNumMidLenBits); - } - m_NumPosStates = numPosStates; - } - - public void Init() - { - m_Choice.Init(); - for (uint posState = 0; posState < m_NumPosStates; posState++) - { - m_LowCoder[posState].Init(); - m_MidCoder[posState].Init(); - } - m_Choice2.Init(); - m_HighCoder.Init(); - } - - public uint Decode(RangeCoder.Decoder rangeDecoder, uint posState) - { - if (m_Choice.Decode(rangeDecoder) == 0) - return m_LowCoder[posState].Decode(rangeDecoder); - else - { - uint symbol = Base.kNumLowLenSymbols; - if (m_Choice2.Decode(rangeDecoder) == 0) - symbol += m_MidCoder[posState].Decode(rangeDecoder); - else - { - symbol += Base.kNumMidLenSymbols; - symbol += m_HighCoder.Decode(rangeDecoder); - } - return symbol; - } - } - } - - class LiteralDecoder - { - struct Decoder2 - { - BitDecoder[] m_Decoders; - public void Create() { m_Decoders = new BitDecoder[0x300]; } - public void Init() { for (int i = 0; i < 0x300; i++) m_Decoders[i].Init(); } - - public byte DecodeNormal(RangeCoder.Decoder rangeDecoder) - { - uint symbol = 1; - do - symbol = (symbol << 1) | m_Decoders[symbol].Decode(rangeDecoder); - while (symbol < 0x100); - return (byte)symbol; - } - - public byte DecodeWithMatchByte(RangeCoder.Decoder rangeDecoder, byte matchByte) - { - uint symbol = 1; - do - { - uint matchBit = (uint)(matchByte >> 7) & 1; - matchByte <<= 1; - uint bit = m_Decoders[((1 + matchBit) << 8) + symbol].Decode(rangeDecoder); - symbol = (symbol << 1) | bit; - if (matchBit != bit) - { - while (symbol < 0x100) - symbol = (symbol << 1) | m_Decoders[symbol].Decode(rangeDecoder); - break; - } - } - while (symbol < 0x100); - return (byte)symbol; - } - } - - Decoder2[] m_Coders; - int m_NumPrevBits; - int m_NumPosBits; - uint m_PosMask; - - public void Create(int numPosBits, int numPrevBits) - { - if (m_Coders != null && m_NumPrevBits == numPrevBits && - m_NumPosBits == numPosBits) - return; - m_NumPosBits = numPosBits; - m_PosMask = ((uint)1 << numPosBits) - 1; - m_NumPrevBits = numPrevBits; - uint numStates = (uint)1 << (m_NumPrevBits + m_NumPosBits); - m_Coders = new Decoder2[numStates]; - for (uint i = 0; i < numStates; i++) - m_Coders[i].Create(); - } - - public void Init() - { - uint numStates = (uint)1 << (m_NumPrevBits + m_NumPosBits); - for (uint i = 0; i < numStates; i++) - m_Coders[i].Init(); - } - - uint GetState(uint pos, byte prevByte) - { return ((pos & m_PosMask) << m_NumPrevBits) + (uint)(prevByte >> (8 - m_NumPrevBits)); } - - public byte DecodeNormal(RangeCoder.Decoder rangeDecoder, uint pos, byte prevByte) - { return m_Coders[GetState(pos, prevByte)].DecodeNormal(rangeDecoder); } - - public byte DecodeWithMatchByte(RangeCoder.Decoder rangeDecoder, uint pos, byte prevByte, byte matchByte) - { return m_Coders[GetState(pos, prevByte)].DecodeWithMatchByte(rangeDecoder, matchByte); } - }; - - LZ.OutWindow m_OutWindow = new LZ.OutWindow(); - RangeCoder.Decoder m_RangeDecoder = new RangeCoder.Decoder(); - - BitDecoder[] m_IsMatchDecoders = new BitDecoder[Base.kNumStates << Base.kNumPosStatesBitsMax]; - BitDecoder[] m_IsRepDecoders = new BitDecoder[Base.kNumStates]; - BitDecoder[] m_IsRepG0Decoders = new BitDecoder[Base.kNumStates]; - BitDecoder[] m_IsRepG1Decoders = new BitDecoder[Base.kNumStates]; - BitDecoder[] m_IsRepG2Decoders = new BitDecoder[Base.kNumStates]; - BitDecoder[] m_IsRep0LongDecoders = new BitDecoder[Base.kNumStates << Base.kNumPosStatesBitsMax]; - - BitTreeDecoder[] m_PosSlotDecoder = new BitTreeDecoder[Base.kNumLenToPosStates]; - BitDecoder[] m_PosDecoders = new BitDecoder[Base.kNumFullDistances - Base.kEndPosModelIndex]; - - BitTreeDecoder m_PosAlignDecoder = new BitTreeDecoder(Base.kNumAlignBits); - - LenDecoder m_LenDecoder = new LenDecoder(); - LenDecoder m_RepLenDecoder = new LenDecoder(); - - LiteralDecoder m_LiteralDecoder = new LiteralDecoder(); - - uint m_DictionarySize; - uint m_DictionarySizeCheck; - - uint m_PosStateMask; - - public Decoder() - { - m_DictionarySize = 0xFFFFFFFF; - for (int i = 0; i < Base.kNumLenToPosStates; i++) - m_PosSlotDecoder[i] = new BitTreeDecoder(Base.kNumPosSlotBits); - } - - void SetDictionarySize(uint dictionarySize) - { - if (m_DictionarySize != dictionarySize) - { - m_DictionarySize = dictionarySize; - m_DictionarySizeCheck = Math.Max(m_DictionarySize, 1); - uint blockSize = Math.Max(m_DictionarySizeCheck, (1 << 12)); - m_OutWindow.Create(blockSize); - } - } - - void SetLiteralProperties(int lp, int lc) - { - if (lp > 8) - throw new InvalidParamException(); - if (lc > 8) - throw new InvalidParamException(); - m_LiteralDecoder.Create(lp, lc); - } - - void SetPosBitsProperties(int pb) - { - if (pb > Base.kNumPosStatesBitsMax) - throw new InvalidParamException(); - uint numPosStates = (uint)1 << pb; - m_LenDecoder.Create(numPosStates); - m_RepLenDecoder.Create(numPosStates); - m_PosStateMask = numPosStates - 1; - } - - bool _solid = false; - void Init(System.IO.Stream inStream, System.IO.Stream outStream) - { - m_RangeDecoder.Init(inStream); - m_OutWindow.Init(outStream, _solid); - - uint i; - for (i = 0; i < Base.kNumStates; i++) - { - for (uint j = 0; j <= m_PosStateMask; j++) - { - uint index = (i << Base.kNumPosStatesBitsMax) + j; - m_IsMatchDecoders[index].Init(); - m_IsRep0LongDecoders[index].Init(); - } - m_IsRepDecoders[i].Init(); - m_IsRepG0Decoders[i].Init(); - m_IsRepG1Decoders[i].Init(); - m_IsRepG2Decoders[i].Init(); - } - - m_LiteralDecoder.Init(); - for (i = 0; i < Base.kNumLenToPosStates; i++) - m_PosSlotDecoder[i].Init(); - // m_PosSpecDecoder.Init(); - for (i = 0; i < Base.kNumFullDistances - Base.kEndPosModelIndex; i++) - m_PosDecoders[i].Init(); - - m_LenDecoder.Init(); - m_RepLenDecoder.Init(); - m_PosAlignDecoder.Init(); - } - - public void Code(System.IO.Stream inStream, System.IO.Stream outStream, - Int64 inSize, Int64 outSize, ICodeProgress progress) - { - Init(inStream, outStream); - - Base.State state = new Base.State(); - state.Init(); - uint rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0; - - UInt64 nowPos64 = 0; - UInt64 outSize64 = (UInt64)outSize; - if (nowPos64 < outSize64) - { - if (m_IsMatchDecoders[state.Index << Base.kNumPosStatesBitsMax].Decode(m_RangeDecoder) != 0) - throw new DataErrorException(); - state.UpdateChar(); - byte b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, 0, 0); - m_OutWindow.PutByte(b); - nowPos64++; - } - while (nowPos64 < outSize64) - { - progress.SetProgress(inStream.Position, (long)nowPos64); - // UInt64 next = Math.Min(nowPos64 + (1 << 18), outSize64); - // while(nowPos64 < next) - { - uint posState = (uint)nowPos64 & m_PosStateMask; - if (m_IsMatchDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0) - { - byte b; - byte prevByte = m_OutWindow.GetByte(0); - if (!state.IsCharState()) - b = m_LiteralDecoder.DecodeWithMatchByte(m_RangeDecoder, - (uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0)); - else - b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, (uint)nowPos64, prevByte); - m_OutWindow.PutByte(b); - state.UpdateChar(); - nowPos64++; - } - else - { - uint len; - if (m_IsRepDecoders[state.Index].Decode(m_RangeDecoder) == 1) - { - if (m_IsRepG0Decoders[state.Index].Decode(m_RangeDecoder) == 0) - { - if (m_IsRep0LongDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0) - { - state.UpdateShortRep(); - m_OutWindow.PutByte(m_OutWindow.GetByte(rep0)); - nowPos64++; - continue; - } - } - else - { - UInt32 distance; - if (m_IsRepG1Decoders[state.Index].Decode(m_RangeDecoder) == 0) - { - distance = rep1; - } - else - { - if (m_IsRepG2Decoders[state.Index].Decode(m_RangeDecoder) == 0) - distance = rep2; - else - { - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - len = m_RepLenDecoder.Decode(m_RangeDecoder, posState) + Base.kMatchMinLen; - state.UpdateRep(); - } - else - { - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - len = Base.kMatchMinLen + m_LenDecoder.Decode(m_RangeDecoder, posState); - state.UpdateMatch(); - uint posSlot = m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(m_RangeDecoder); - if (posSlot >= Base.kStartPosModelIndex) - { - int numDirectBits = (int)((posSlot >> 1) - 1); - rep0 = ((2 | (posSlot & 1)) << numDirectBits); - if (posSlot < Base.kEndPosModelIndex) - rep0 += BitTreeDecoder.ReverseDecode(m_PosDecoders, - rep0 - posSlot - 1, m_RangeDecoder, numDirectBits); - else - { - rep0 += (m_RangeDecoder.DecodeDirectBits( - numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits); - rep0 += m_PosAlignDecoder.ReverseDecode(m_RangeDecoder); - } - } - else - rep0 = posSlot; - } - if (rep0 >= m_OutWindow.TrainSize + nowPos64 || rep0 >= m_DictionarySizeCheck) - { - if (rep0 == 0xFFFFFFFF) - break; - throw new DataErrorException(); - } - m_OutWindow.CopyBlock(rep0, len); - nowPos64 += len; - } - } - } - m_OutWindow.Flush(); - m_OutWindow.ReleaseStream(); - m_RangeDecoder.ReleaseStream(); - } - - public void SetDecoderProperties(byte[] properties) - { - if (properties.Length < 5) - throw new InvalidParamException(); - int lc = properties[0] % 9; - int remainder = properties[0] / 9; - int lp = remainder % 5; - int pb = remainder / 5; - if (pb > Base.kNumPosStatesBitsMax) - throw new InvalidParamException(); - UInt32 dictionarySize = 0; - for (int i = 0; i < 4; i++) - dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8); - SetDictionarySize(dictionarySize); - SetLiteralProperties(lp, lc); - SetPosBitsProperties(pb); - } - - public bool Train(System.IO.Stream stream) - { - _solid = true; - return m_OutWindow.Train(stream); - } - - /* - public override bool CanRead { get { return true; }} - public override bool CanWrite { get { return true; }} - public override bool CanSeek { get { return true; }} - public override long Length { get { return 0; }} - public override long Position - { - get { return 0; } - set { } - } - public override void Flush() { } - public override int Read(byte[] buffer, int offset, int count) - { - return 0; - } - public override void Write(byte[] buffer, int offset, int count) - { - } - public override long Seek(long offset, System.IO.SeekOrigin origin) - { - return 0; - } - public override void SetLength(long value) {} - */ - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaEncoder.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaEncoder.cs deleted file mode 100644 index 527a67e0ca..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/LZMA/LzmaEncoder.cs +++ /dev/null @@ -1,1483 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// LzmaEncoder.cs - -using System; - -namespace SevenZip.Compression.LZMA -{ - using RangeCoder; - - public class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties - { - enum EMatchFinderType - { - BT2, - BT4, - }; - - const UInt32 kIfinityPrice = 0xFFFFFFF; - - static Byte[] g_FastPos = new Byte[1 << 11]; - - static Encoder() - { - const Byte kFastSlots = 22; - int c = 2; - g_FastPos[0] = 0; - g_FastPos[1] = 1; - for (Byte slotFast = 2; slotFast < kFastSlots; slotFast++) - { - UInt32 k = ((UInt32)1 << ((slotFast >> 1) - 1)); - for (UInt32 j = 0; j < k; j++, c++) - g_FastPos[c] = slotFast; - } - } - - static UInt32 GetPosSlot(UInt32 pos) - { - if (pos < (1 << 11)) - return g_FastPos[pos]; - if (pos < (1 << 21)) - return (UInt32)(g_FastPos[pos >> 10] + 20); - return (UInt32)(g_FastPos[pos >> 20] + 40); - } - - static UInt32 GetPosSlot2(UInt32 pos) - { - if (pos < (1 << 17)) - return (UInt32)(g_FastPos[pos >> 6] + 12); - if (pos < (1 << 27)) - return (UInt32)(g_FastPos[pos >> 16] + 32); - return (UInt32)(g_FastPos[pos >> 26] + 52); - } - - Base.State _state = new Base.State(); - Byte _previousByte; - UInt32[] _repDistances = new UInt32[Base.kNumRepDistances]; - - void BaseInit() - { - _state.Init(); - _previousByte = 0; - for (UInt32 i = 0; i < Base.kNumRepDistances; i++) - _repDistances[i] = 0; - } - - const int kDefaultDictionaryLogSize = 22; - const UInt32 kNumFastBytesDefault = 0x20; - - class LiteralEncoder - { - public struct Encoder2 - { - BitEncoder[] m_Encoders; - - public void Create() { m_Encoders = new BitEncoder[0x300]; } - - public void Init() { for (int i = 0; i < 0x300; i++) m_Encoders[i].Init(); } - - public void Encode(RangeCoder.Encoder rangeEncoder, byte symbol) - { - uint context = 1; - for (int i = 7; i >= 0; i--) - { - uint bit = (uint)((symbol >> i) & 1); - m_Encoders[context].Encode(rangeEncoder, bit); - context = (context << 1) | bit; - } - } - - public void EncodeMatched(RangeCoder.Encoder rangeEncoder, byte matchByte, byte symbol) - { - uint context = 1; - bool same = true; - for (int i = 7; i >= 0; i--) - { - uint bit = (uint)((symbol >> i) & 1); - uint state = context; - if (same) - { - uint matchBit = (uint)((matchByte >> i) & 1); - state += ((1 + matchBit) << 8); - same = (matchBit == bit); - } - m_Encoders[state].Encode(rangeEncoder, bit); - context = (context << 1) | bit; - } - } - - public uint GetPrice(bool matchMode, byte matchByte, byte symbol) - { - uint price = 0; - uint context = 1; - int i = 7; - if (matchMode) - { - for (; i >= 0; i--) - { - uint matchBit = (uint)(matchByte >> i) & 1; - uint bit = (uint)(symbol >> i) & 1; - price += m_Encoders[((1 + matchBit) << 8) + context].GetPrice(bit); - context = (context << 1) | bit; - if (matchBit != bit) - { - i--; - break; - } - } - } - for (; i >= 0; i--) - { - uint bit = (uint)(symbol >> i) & 1; - price += m_Encoders[context].GetPrice(bit); - context = (context << 1) | bit; - } - return price; - } - } - - Encoder2[] m_Coders; - int m_NumPrevBits; - int m_NumPosBits; - uint m_PosMask; - - public void Create(int numPosBits, int numPrevBits) - { - if (m_Coders != null && m_NumPrevBits == numPrevBits && m_NumPosBits == numPosBits) - return; - m_NumPosBits = numPosBits; - m_PosMask = ((uint)1 << numPosBits) - 1; - m_NumPrevBits = numPrevBits; - uint numStates = (uint)1 << (m_NumPrevBits + m_NumPosBits); - m_Coders = new Encoder2[numStates]; - for (uint i = 0; i < numStates; i++) - m_Coders[i].Create(); - } - - public void Init() - { - uint numStates = (uint)1 << (m_NumPrevBits + m_NumPosBits); - for (uint i = 0; i < numStates; i++) - m_Coders[i].Init(); - } - - public Encoder2 GetSubCoder(UInt32 pos, Byte prevByte) - { return m_Coders[((pos & m_PosMask) << m_NumPrevBits) + (uint)(prevByte >> (8 - m_NumPrevBits))]; } - } - - class LenEncoder - { - RangeCoder.BitEncoder _choice = new RangeCoder.BitEncoder(); - RangeCoder.BitEncoder _choice2 = new RangeCoder.BitEncoder(); - RangeCoder.BitTreeEncoder[] _lowCoder = new RangeCoder.BitTreeEncoder[Base.kNumPosStatesEncodingMax]; - RangeCoder.BitTreeEncoder[] _midCoder = new RangeCoder.BitTreeEncoder[Base.kNumPosStatesEncodingMax]; - RangeCoder.BitTreeEncoder _highCoder = new RangeCoder.BitTreeEncoder(Base.kNumHighLenBits); - - public LenEncoder() - { - for (UInt32 posState = 0; posState < Base.kNumPosStatesEncodingMax; posState++) - { - _lowCoder[posState] = new RangeCoder.BitTreeEncoder(Base.kNumLowLenBits); - _midCoder[posState] = new RangeCoder.BitTreeEncoder(Base.kNumMidLenBits); - } - } - - public void Init(UInt32 numPosStates) - { - _choice.Init(); - _choice2.Init(); - for (UInt32 posState = 0; posState < numPosStates; posState++) - { - _lowCoder[posState].Init(); - _midCoder[posState].Init(); - } - _highCoder.Init(); - } - - public void Encode(RangeCoder.Encoder rangeEncoder, UInt32 symbol, UInt32 posState) - { - if (symbol < Base.kNumLowLenSymbols) - { - _choice.Encode(rangeEncoder, 0); - _lowCoder[posState].Encode(rangeEncoder, symbol); - } - else - { - symbol -= Base.kNumLowLenSymbols; - _choice.Encode(rangeEncoder, 1); - if (symbol < Base.kNumMidLenSymbols) - { - _choice2.Encode(rangeEncoder, 0); - _midCoder[posState].Encode(rangeEncoder, symbol); - } - else - { - _choice2.Encode(rangeEncoder, 1); - _highCoder.Encode(rangeEncoder, symbol - Base.kNumMidLenSymbols); - } - } - } - - public void SetPrices(UInt32 posState, UInt32 numSymbols, UInt32[] prices, UInt32 st) - { - UInt32 a0 = _choice.GetPrice0(); - UInt32 a1 = _choice.GetPrice1(); - UInt32 b0 = a1 + _choice2.GetPrice0(); - UInt32 b1 = a1 + _choice2.GetPrice1(); - UInt32 i = 0; - for (i = 0; i < Base.kNumLowLenSymbols; i++) - { - if (i >= numSymbols) - return; - prices[st + i] = a0 + _lowCoder[posState].GetPrice(i); - } - for (; i < Base.kNumLowLenSymbols + Base.kNumMidLenSymbols; i++) - { - if (i >= numSymbols) - return; - prices[st + i] = b0 + _midCoder[posState].GetPrice(i - Base.kNumLowLenSymbols); - } - for (; i < numSymbols; i++) - prices[st + i] = b1 + _highCoder.GetPrice(i - Base.kNumLowLenSymbols - Base.kNumMidLenSymbols); - } - }; - - const UInt32 kNumLenSpecSymbols = Base.kNumLowLenSymbols + Base.kNumMidLenSymbols; - - class LenPriceTableEncoder : LenEncoder - { - UInt32[] _prices = new UInt32[Base.kNumLenSymbols << Base.kNumPosStatesBitsEncodingMax]; - UInt32 _tableSize; - UInt32[] _counters = new UInt32[Base.kNumPosStatesEncodingMax]; - - public void SetTableSize(UInt32 tableSize) { _tableSize = tableSize; } - - public UInt32 GetPrice(UInt32 symbol, UInt32 posState) - { - return _prices[posState * Base.kNumLenSymbols + symbol]; - } - - void UpdateTable(UInt32 posState) - { - SetPrices(posState, _tableSize, _prices, posState * Base.kNumLenSymbols); - _counters[posState] = _tableSize; - } - - public void UpdateTables(UInt32 numPosStates) - { - for (UInt32 posState = 0; posState < numPosStates; posState++) - UpdateTable(posState); - } - - public new void Encode(RangeCoder.Encoder rangeEncoder, UInt32 symbol, UInt32 posState) - { - base.Encode(rangeEncoder, symbol, posState); - if (--_counters[posState] == 0) - UpdateTable(posState); - } - } - - const UInt32 kNumOpts = 1 << 12; - class Optimal - { - public Base.State State; - - public bool Prev1IsChar; - public bool Prev2; - - public UInt32 PosPrev2; - public UInt32 BackPrev2; - - public UInt32 Price; - public UInt32 PosPrev; - public UInt32 BackPrev; - - public UInt32 Backs0; - public UInt32 Backs1; - public UInt32 Backs2; - public UInt32 Backs3; - - public void MakeAsChar() { BackPrev = 0xFFFFFFFF; Prev1IsChar = false; } - public void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; } - public bool IsShortRep() { return (BackPrev == 0); } - }; - Optimal[] _optimum = new Optimal[kNumOpts]; - LZ.IMatchFinder _matchFinder = null; - RangeCoder.Encoder _rangeEncoder = new RangeCoder.Encoder(); - - RangeCoder.BitEncoder[] _isMatch = new RangeCoder.BitEncoder[Base.kNumStates << Base.kNumPosStatesBitsMax]; - RangeCoder.BitEncoder[] _isRep = new RangeCoder.BitEncoder[Base.kNumStates]; - RangeCoder.BitEncoder[] _isRepG0 = new RangeCoder.BitEncoder[Base.kNumStates]; - RangeCoder.BitEncoder[] _isRepG1 = new RangeCoder.BitEncoder[Base.kNumStates]; - RangeCoder.BitEncoder[] _isRepG2 = new RangeCoder.BitEncoder[Base.kNumStates]; - RangeCoder.BitEncoder[] _isRep0Long = new RangeCoder.BitEncoder[Base.kNumStates << Base.kNumPosStatesBitsMax]; - - RangeCoder.BitTreeEncoder[] _posSlotEncoder = new RangeCoder.BitTreeEncoder[Base.kNumLenToPosStates]; - - RangeCoder.BitEncoder[] _posEncoders = new RangeCoder.BitEncoder[Base.kNumFullDistances - Base.kEndPosModelIndex]; - RangeCoder.BitTreeEncoder _posAlignEncoder = new RangeCoder.BitTreeEncoder(Base.kNumAlignBits); - - LenPriceTableEncoder _lenEncoder = new LenPriceTableEncoder(); - LenPriceTableEncoder _repMatchLenEncoder = new LenPriceTableEncoder(); - - LiteralEncoder _literalEncoder = new LiteralEncoder(); - - UInt32[] _matchDistances = new UInt32[Base.kMatchMaxLen * 2 + 2]; - - UInt32 _numFastBytes = kNumFastBytesDefault; - UInt32 _longestMatchLength; - UInt32 _numDistancePairs; - - UInt32 _additionalOffset; - - UInt32 _optimumEndIndex; - UInt32 _optimumCurrentIndex; - - bool _longestMatchWasFound; - - UInt32[] _posSlotPrices = new UInt32[1 << (Base.kNumPosSlotBits + Base.kNumLenToPosStatesBits)]; - UInt32[] _distancesPrices = new UInt32[Base.kNumFullDistances << Base.kNumLenToPosStatesBits]; - UInt32[] _alignPrices = new UInt32[Base.kAlignTableSize]; - UInt32 _alignPriceCount; - - UInt32 _distTableSize = (kDefaultDictionaryLogSize * 2); - - int _posStateBits = 2; - UInt32 _posStateMask = (4 - 1); - int _numLiteralPosStateBits = 0; - int _numLiteralContextBits = 3; - - UInt32 _dictionarySize = (1 << kDefaultDictionaryLogSize); - UInt32 _dictionarySizePrev = 0xFFFFFFFF; - UInt32 _numFastBytesPrev = 0xFFFFFFFF; - - Int64 nowPos64; - bool _finished; - System.IO.Stream _inStream; - - EMatchFinderType _matchFinderType = EMatchFinderType.BT4; - bool _writeEndMark = false; - - bool _needReleaseMFStream; - - void Create() - { - if (_matchFinder == null) - { - LZ.BinTree bt = new LZ.BinTree(); - int numHashBytes = 4; - if (_matchFinderType == EMatchFinderType.BT2) - numHashBytes = 2; - bt.SetType(numHashBytes); - _matchFinder = bt; - } - _literalEncoder.Create(_numLiteralPosStateBits, _numLiteralContextBits); - - if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes) - return; - _matchFinder.Create(_dictionarySize, kNumOpts, _numFastBytes, Base.kMatchMaxLen + 1); - _dictionarySizePrev = _dictionarySize; - _numFastBytesPrev = _numFastBytes; - } - - public Encoder() - { - for (int i = 0; i < kNumOpts; i++) - _optimum[i] = new Optimal(); - for (int i = 0; i < Base.kNumLenToPosStates; i++) - _posSlotEncoder[i] = new RangeCoder.BitTreeEncoder(Base.kNumPosSlotBits); - } - - void SetWriteEndMarkerMode(bool writeEndMarker) - { - _writeEndMark = writeEndMarker; - } - - void Init() - { - BaseInit(); - _rangeEncoder.Init(); - - uint i; - for (i = 0; i < Base.kNumStates; i++) - { - for (uint j = 0; j <= _posStateMask; j++) - { - uint complexState = (i << Base.kNumPosStatesBitsMax) + j; - _isMatch[complexState].Init(); - _isRep0Long[complexState].Init(); - } - _isRep[i].Init(); - _isRepG0[i].Init(); - _isRepG1[i].Init(); - _isRepG2[i].Init(); - } - _literalEncoder.Init(); - for (i = 0; i < Base.kNumLenToPosStates; i++) - _posSlotEncoder[i].Init(); - for (i = 0; i < Base.kNumFullDistances - Base.kEndPosModelIndex; i++) - _posEncoders[i].Init(); - - _lenEncoder.Init((UInt32)1 << _posStateBits); - _repMatchLenEncoder.Init((UInt32)1 << _posStateBits); - - _posAlignEncoder.Init(); - - _longestMatchWasFound = false; - _optimumEndIndex = 0; - _optimumCurrentIndex = 0; - _additionalOffset = 0; - } - - void ReadMatchDistances(out UInt32 lenRes, out UInt32 numDistancePairs) - { - lenRes = 0; - numDistancePairs = _matchFinder.GetMatches(_matchDistances); - if (numDistancePairs > 0) - { - lenRes = _matchDistances[numDistancePairs - 2]; - if (lenRes == _numFastBytes) - lenRes += _matchFinder.GetMatchLen((int)lenRes - 1, _matchDistances[numDistancePairs - 1], - Base.kMatchMaxLen - lenRes); - } - _additionalOffset++; - } - - - void MovePos(UInt32 num) - { - if (num > 0) - { - _matchFinder.Skip(num); - _additionalOffset += num; - } - } - - UInt32 GetRepLen1Price(Base.State state, UInt32 posState) - { - return _isRepG0[state.Index].GetPrice0() + - _isRep0Long[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0(); - } - - UInt32 GetPureRepPrice(UInt32 repIndex, Base.State state, UInt32 posState) - { - UInt32 price; - if (repIndex == 0) - { - price = _isRepG0[state.Index].GetPrice0(); - price += _isRep0Long[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice1(); - } - else - { - price = _isRepG0[state.Index].GetPrice1(); - if (repIndex == 1) - price += _isRepG1[state.Index].GetPrice0(); - else - { - price += _isRepG1[state.Index].GetPrice1(); - price += _isRepG2[state.Index].GetPrice(repIndex - 2); - } - } - return price; - } - - UInt32 GetRepPrice(UInt32 repIndex, UInt32 len, Base.State state, UInt32 posState) - { - UInt32 price = _repMatchLenEncoder.GetPrice(len - Base.kMatchMinLen, posState); - return price + GetPureRepPrice(repIndex, state, posState); - } - - UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) - { - UInt32 price; - UInt32 lenToPosState = Base.GetLenToPosState(len); - if (pos < Base.kNumFullDistances) - price = _distancesPrices[(lenToPosState * Base.kNumFullDistances) + pos]; - else - price = _posSlotPrices[(lenToPosState << Base.kNumPosSlotBits) + GetPosSlot2(pos)] + - _alignPrices[pos & Base.kAlignMask]; - return price + _lenEncoder.GetPrice(len - Base.kMatchMinLen, posState); - } - - UInt32 Backward(out UInt32 backRes, UInt32 cur) - { - _optimumEndIndex = cur; - UInt32 posMem = _optimum[cur].PosPrev; - UInt32 backMem = _optimum[cur].BackPrev; - do - { - if (_optimum[cur].Prev1IsChar) - { - _optimum[posMem].MakeAsChar(); - _optimum[posMem].PosPrev = posMem - 1; - if (_optimum[cur].Prev2) - { - _optimum[posMem - 1].Prev1IsChar = false; - _optimum[posMem - 1].PosPrev = _optimum[cur].PosPrev2; - _optimum[posMem - 1].BackPrev = _optimum[cur].BackPrev2; - } - } - UInt32 posPrev = posMem; - UInt32 backCur = backMem; - - backMem = _optimum[posPrev].BackPrev; - posMem = _optimum[posPrev].PosPrev; - - _optimum[posPrev].BackPrev = backCur; - _optimum[posPrev].PosPrev = cur; - cur = posPrev; - } - while (cur > 0); - backRes = _optimum[0].BackPrev; - _optimumCurrentIndex = _optimum[0].PosPrev; - return _optimumCurrentIndex; - } - - UInt32[] reps = new UInt32[Base.kNumRepDistances]; - UInt32[] repLens = new UInt32[Base.kNumRepDistances]; - - - UInt32 GetOptimum(UInt32 position, out UInt32 backRes) - { - if (_optimumEndIndex != _optimumCurrentIndex) - { - UInt32 lenRes = _optimum[_optimumCurrentIndex].PosPrev - _optimumCurrentIndex; - backRes = _optimum[_optimumCurrentIndex].BackPrev; - _optimumCurrentIndex = _optimum[_optimumCurrentIndex].PosPrev; - return lenRes; - } - _optimumCurrentIndex = _optimumEndIndex = 0; - - UInt32 lenMain, numDistancePairs; - if (!_longestMatchWasFound) - { - ReadMatchDistances(out lenMain, out numDistancePairs); - } - else - { - lenMain = _longestMatchLength; - numDistancePairs = _numDistancePairs; - _longestMatchWasFound = false; - } - - UInt32 numAvailableBytes = _matchFinder.GetNumAvailableBytes() + 1; - if (numAvailableBytes < 2) - { - backRes = 0xFFFFFFFF; - return 1; - } - if (numAvailableBytes > Base.kMatchMaxLen) - numAvailableBytes = Base.kMatchMaxLen; - - UInt32 repMaxIndex = 0; - UInt32 i; - for (i = 0; i < Base.kNumRepDistances; i++) - { - reps[i] = _repDistances[i]; - repLens[i] = _matchFinder.GetMatchLen(0 - 1, reps[i], Base.kMatchMaxLen); - if (repLens[i] > repLens[repMaxIndex]) - repMaxIndex = i; - } - if (repLens[repMaxIndex] >= _numFastBytes) - { - backRes = repMaxIndex; - UInt32 lenRes = repLens[repMaxIndex]; - MovePos(lenRes - 1); - return lenRes; - } - - if (lenMain >= _numFastBytes) - { - backRes = _matchDistances[numDistancePairs - 1] + Base.kNumRepDistances; - MovePos(lenMain - 1); - return lenMain; - } - - Byte currentByte = _matchFinder.GetIndexByte(0 - 1); - Byte matchByte = _matchFinder.GetIndexByte((Int32)(0 - _repDistances[0] - 1 - 1)); - - if (lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2) - { - backRes = (UInt32)0xFFFFFFFF; - return 1; - } - - _optimum[0].State = _state; - - UInt32 posState = (position & _posStateMask); - - _optimum[1].Price = _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0() + - _literalEncoder.GetSubCoder(position, _previousByte).GetPrice(!_state.IsCharState(), matchByte, currentByte); - _optimum[1].MakeAsChar(); - - UInt32 matchPrice = _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice1(); - UInt32 repMatchPrice = matchPrice + _isRep[_state.Index].GetPrice1(); - - if (matchByte == currentByte) - { - UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(_state, posState); - if (shortRepPrice < _optimum[1].Price) - { - _optimum[1].Price = shortRepPrice; - _optimum[1].MakeAsShortRep(); - } - } - - UInt32 lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]); - - if(lenEnd < 2) - { - backRes = _optimum[1].BackPrev; - return 1; - } - - _optimum[1].PosPrev = 0; - - _optimum[0].Backs0 = reps[0]; - _optimum[0].Backs1 = reps[1]; - _optimum[0].Backs2 = reps[2]; - _optimum[0].Backs3 = reps[3]; - - UInt32 len = lenEnd; - do - _optimum[len--].Price = kIfinityPrice; - while (len >= 2); - - for (i = 0; i < Base.kNumRepDistances; i++) - { - UInt32 repLen = repLens[i]; - if (repLen < 2) - continue; - UInt32 price = repMatchPrice + GetPureRepPrice(i, _state, posState); - do - { - UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(repLen - 2, posState); - Optimal optimum = _optimum[repLen]; - if (curAndLenPrice < optimum.Price) - { - optimum.Price = curAndLenPrice; - optimum.PosPrev = 0; - optimum.BackPrev = i; - optimum.Prev1IsChar = false; - } - } - while (--repLen >= 2); - } - - UInt32 normalMatchPrice = matchPrice + _isRep[_state.Index].GetPrice0(); - - len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2); - if (len <= lenMain) - { - UInt32 offs = 0; - while (len > _matchDistances[offs]) - offs += 2; - for (; ; len++) - { - UInt32 distance = _matchDistances[offs + 1]; - UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState); - Optimal optimum = _optimum[len]; - if (curAndLenPrice < optimum.Price) - { - optimum.Price = curAndLenPrice; - optimum.PosPrev = 0; - optimum.BackPrev = distance + Base.kNumRepDistances; - optimum.Prev1IsChar = false; - } - if (len == _matchDistances[offs]) - { - offs += 2; - if (offs == numDistancePairs) - break; - } - } - } - - UInt32 cur = 0; - - while (true) - { - cur++; - if (cur == lenEnd) - return Backward(out backRes, cur); - UInt32 newLen; - ReadMatchDistances(out newLen, out numDistancePairs); - if (newLen >= _numFastBytes) - { - _numDistancePairs = numDistancePairs; - _longestMatchLength = newLen; - _longestMatchWasFound = true; - return Backward(out backRes, cur); - } - position++; - UInt32 posPrev = _optimum[cur].PosPrev; - Base.State state; - if (_optimum[cur].Prev1IsChar) - { - posPrev--; - if (_optimum[cur].Prev2) - { - state = _optimum[_optimum[cur].PosPrev2].State; - if (_optimum[cur].BackPrev2 < Base.kNumRepDistances) - state.UpdateRep(); - else - state.UpdateMatch(); - } - else - state = _optimum[posPrev].State; - state.UpdateChar(); - } - else - state = _optimum[posPrev].State; - if (posPrev == cur - 1) - { - if (_optimum[cur].IsShortRep()) - state.UpdateShortRep(); - else - state.UpdateChar(); - } - else - { - UInt32 pos; - if (_optimum[cur].Prev1IsChar && _optimum[cur].Prev2) - { - posPrev = _optimum[cur].PosPrev2; - pos = _optimum[cur].BackPrev2; - state.UpdateRep(); - } - else - { - pos = _optimum[cur].BackPrev; - if (pos < Base.kNumRepDistances) - state.UpdateRep(); - else - state.UpdateMatch(); - } - Optimal opt = _optimum[posPrev]; - if (pos < Base.kNumRepDistances) - { - if (pos == 0) - { - reps[0] = opt.Backs0; - reps[1] = opt.Backs1; - reps[2] = opt.Backs2; - reps[3] = opt.Backs3; - } - else if (pos == 1) - { - reps[0] = opt.Backs1; - reps[1] = opt.Backs0; - reps[2] = opt.Backs2; - reps[3] = opt.Backs3; - } - else if (pos == 2) - { - reps[0] = opt.Backs2; - reps[1] = opt.Backs0; - reps[2] = opt.Backs1; - reps[3] = opt.Backs3; - } - else - { - reps[0] = opt.Backs3; - reps[1] = opt.Backs0; - reps[2] = opt.Backs1; - reps[3] = opt.Backs2; - } - } - else - { - reps[0] = (pos - Base.kNumRepDistances); - reps[1] = opt.Backs0; - reps[2] = opt.Backs1; - reps[3] = opt.Backs2; - } - } - _optimum[cur].State = state; - _optimum[cur].Backs0 = reps[0]; - _optimum[cur].Backs1 = reps[1]; - _optimum[cur].Backs2 = reps[2]; - _optimum[cur].Backs3 = reps[3]; - UInt32 curPrice = _optimum[cur].Price; - - currentByte = _matchFinder.GetIndexByte(0 - 1); - matchByte = _matchFinder.GetIndexByte((Int32)(0 - reps[0] - 1 - 1)); - - posState = (position & _posStateMask); - - UInt32 curAnd1Price = curPrice + - _isMatch[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0() + - _literalEncoder.GetSubCoder(position, _matchFinder.GetIndexByte(0 - 2)). - GetPrice(!state.IsCharState(), matchByte, currentByte); - - Optimal nextOptimum = _optimum[cur + 1]; - - bool nextIsChar = false; - if (curAnd1Price < nextOptimum.Price) - { - nextOptimum.Price = curAnd1Price; - nextOptimum.PosPrev = cur; - nextOptimum.MakeAsChar(); - nextIsChar = true; - } - - matchPrice = curPrice + _isMatch[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice1(); - repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1(); - - if (matchByte == currentByte && - !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0)) - { - UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState); - if (shortRepPrice <= nextOptimum.Price) - { - nextOptimum.Price = shortRepPrice; - nextOptimum.PosPrev = cur; - nextOptimum.MakeAsShortRep(); - nextIsChar = true; - } - } - - UInt32 numAvailableBytesFull = _matchFinder.GetNumAvailableBytes() + 1; - numAvailableBytesFull = Math.Min(kNumOpts - 1 - cur, numAvailableBytesFull); - numAvailableBytes = numAvailableBytesFull; - - if (numAvailableBytes < 2) - continue; - if (numAvailableBytes > _numFastBytes) - numAvailableBytes = _numFastBytes; - if (!nextIsChar && matchByte != currentByte) - { - // try Literal + rep0 - UInt32 t = Math.Min(numAvailableBytesFull - 1, _numFastBytes); - UInt32 lenTest2 = _matchFinder.GetMatchLen(0, reps[0], t); - if (lenTest2 >= 2) - { - Base.State state2 = state; - state2.UpdateChar(); - UInt32 posStateNext = (position + 1) & _posStateMask; - UInt32 nextRepMatchPrice = curAnd1Price + - _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1() + - _isRep[state2.Index].GetPrice1(); - { - UInt32 offset = cur + 1 + lenTest2; - while (lenEnd < offset) - _optimum[++lenEnd].Price = kIfinityPrice; - UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice( - 0, lenTest2, state2, posStateNext); - Optimal optimum = _optimum[offset]; - if (curAndLenPrice < optimum.Price) - { - optimum.Price = curAndLenPrice; - optimum.PosPrev = cur + 1; - optimum.BackPrev = 0; - optimum.Prev1IsChar = true; - optimum.Prev2 = false; - } - } - } - } - - UInt32 startLen = 2; // speed optimization - - for (UInt32 repIndex = 0; repIndex < Base.kNumRepDistances; repIndex++) - { - UInt32 lenTest = _matchFinder.GetMatchLen(0 - 1, reps[repIndex], numAvailableBytes); - if (lenTest < 2) - continue; - UInt32 lenTestTemp = lenTest; - do - { - while (lenEnd < cur + lenTest) - _optimum[++lenEnd].Price = kIfinityPrice; - UInt32 curAndLenPrice = repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState); - Optimal optimum = _optimum[cur + lenTest]; - if (curAndLenPrice < optimum.Price) - { - optimum.Price = curAndLenPrice; - optimum.PosPrev = cur; - optimum.BackPrev = repIndex; - optimum.Prev1IsChar = false; - } - } - while(--lenTest >= 2); - lenTest = lenTestTemp; - - if (repIndex == 0) - startLen = lenTest + 1; - - // if (_maxMode) - if (lenTest < numAvailableBytesFull) - { - UInt32 t = Math.Min(numAvailableBytesFull - 1 - lenTest, _numFastBytes); - UInt32 lenTest2 = _matchFinder.GetMatchLen((Int32)lenTest, reps[repIndex], t); - if (lenTest2 >= 2) - { - Base.State state2 = state; - state2.UpdateRep(); - UInt32 posStateNext = (position + lenTest) & _posStateMask; - UInt32 curAndLenCharPrice = - repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState) + - _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice0() + - _literalEncoder.GetSubCoder(position + lenTest, - _matchFinder.GetIndexByte((Int32)lenTest - 1 - 1)).GetPrice(true, - _matchFinder.GetIndexByte((Int32)((Int32)lenTest - 1 - (Int32)(reps[repIndex] + 1))), - _matchFinder.GetIndexByte((Int32)lenTest - 1)); - state2.UpdateChar(); - posStateNext = (position + lenTest + 1) & _posStateMask; - UInt32 nextMatchPrice = curAndLenCharPrice + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1(); - UInt32 nextRepMatchPrice = nextMatchPrice + _isRep[state2.Index].GetPrice1(); - - // for(; lenTest2 >= 2; lenTest2--) - { - UInt32 offset = lenTest + 1 + lenTest2; - while(lenEnd < cur + offset) - _optimum[++lenEnd].Price = kIfinityPrice; - UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext); - Optimal optimum = _optimum[cur + offset]; - if (curAndLenPrice < optimum.Price) - { - optimum.Price = curAndLenPrice; - optimum.PosPrev = cur + lenTest + 1; - optimum.BackPrev = 0; - optimum.Prev1IsChar = true; - optimum.Prev2 = true; - optimum.PosPrev2 = cur; - optimum.BackPrev2 = repIndex; - } - } - } - } - } - - if (newLen > numAvailableBytes) - { - newLen = numAvailableBytes; - for (numDistancePairs = 0; newLen > _matchDistances[numDistancePairs]; numDistancePairs += 2) ; - _matchDistances[numDistancePairs] = newLen; - numDistancePairs += 2; - } - if (newLen >= startLen) - { - normalMatchPrice = matchPrice + _isRep[state.Index].GetPrice0(); - while (lenEnd < cur + newLen) - _optimum[++lenEnd].Price = kIfinityPrice; - - UInt32 offs = 0; - while (startLen > _matchDistances[offs]) - offs += 2; - - for (UInt32 lenTest = startLen; ; lenTest++) - { - UInt32 curBack = _matchDistances[offs + 1]; - UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(curBack, lenTest, posState); - Optimal optimum = _optimum[cur + lenTest]; - if (curAndLenPrice < optimum.Price) - { - optimum.Price = curAndLenPrice; - optimum.PosPrev = cur; - optimum.BackPrev = curBack + Base.kNumRepDistances; - optimum.Prev1IsChar = false; - } - - if (lenTest == _matchDistances[offs]) - { - if (lenTest < numAvailableBytesFull) - { - UInt32 t = Math.Min(numAvailableBytesFull - 1 - lenTest, _numFastBytes); - UInt32 lenTest2 = _matchFinder.GetMatchLen((Int32)lenTest, curBack, t); - if (lenTest2 >= 2) - { - Base.State state2 = state; - state2.UpdateMatch(); - UInt32 posStateNext = (position + lenTest) & _posStateMask; - UInt32 curAndLenCharPrice = curAndLenPrice + - _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice0() + - _literalEncoder.GetSubCoder(position + lenTest, - _matchFinder.GetIndexByte((Int32)lenTest - 1 - 1)). - GetPrice(true, - _matchFinder.GetIndexByte((Int32)lenTest - (Int32)(curBack + 1) - 1), - _matchFinder.GetIndexByte((Int32)lenTest - 1)); - state2.UpdateChar(); - posStateNext = (position + lenTest + 1) & _posStateMask; - UInt32 nextMatchPrice = curAndLenCharPrice + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1(); - UInt32 nextRepMatchPrice = nextMatchPrice + _isRep[state2.Index].GetPrice1(); - - UInt32 offset = lenTest + 1 + lenTest2; - while (lenEnd < cur + offset) - _optimum[++lenEnd].Price = kIfinityPrice; - curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext); - optimum = _optimum[cur + offset]; - if (curAndLenPrice < optimum.Price) - { - optimum.Price = curAndLenPrice; - optimum.PosPrev = cur + lenTest + 1; - optimum.BackPrev = 0; - optimum.Prev1IsChar = true; - optimum.Prev2 = true; - optimum.PosPrev2 = cur; - optimum.BackPrev2 = curBack + Base.kNumRepDistances; - } - } - } - offs += 2; - if (offs == numDistancePairs) - break; - } - } - } - } - } - - bool ChangePair(UInt32 smallDist, UInt32 bigDist) - { - const int kDif = 7; - return (smallDist < ((UInt32)(1) << (32 - kDif)) && bigDist >= (smallDist << kDif)); - } - - void WriteEndMarker(UInt32 posState) - { - if (!_writeEndMark) - return; - - _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].Encode(_rangeEncoder, 1); - _isRep[_state.Index].Encode(_rangeEncoder, 0); - _state.UpdateMatch(); - UInt32 len = Base.kMatchMinLen; - _lenEncoder.Encode(_rangeEncoder, len - Base.kMatchMinLen, posState); - UInt32 posSlot = (1 << Base.kNumPosSlotBits) - 1; - UInt32 lenToPosState = Base.GetLenToPosState(len); - _posSlotEncoder[lenToPosState].Encode(_rangeEncoder, posSlot); - int footerBits = 30; - UInt32 posReduced = (((UInt32)1) << footerBits) - 1; - _rangeEncoder.EncodeDirectBits(posReduced >> Base.kNumAlignBits, footerBits - Base.kNumAlignBits); - _posAlignEncoder.ReverseEncode(_rangeEncoder, posReduced & Base.kAlignMask); - } - - void Flush(UInt32 nowPos) - { - ReleaseMFStream(); - WriteEndMarker(nowPos & _posStateMask); - _rangeEncoder.FlushData(); - _rangeEncoder.FlushStream(); - } - - public void CodeOneBlock(out Int64 inSize, out Int64 outSize, out bool finished) - { - inSize = 0; - outSize = 0; - finished = true; - - if (_inStream != null) - { - _matchFinder.SetStream(_inStream); - _matchFinder.Init(); - _needReleaseMFStream = true; - _inStream = null; - if (_trainSize > 0) - _matchFinder.Skip(_trainSize); - } - - if (_finished) - return; - _finished = true; - - - Int64 progressPosValuePrev = nowPos64; - if (nowPos64 == 0) - { - if (_matchFinder.GetNumAvailableBytes() == 0) - { - Flush((UInt32)nowPos64); - return; - } - UInt32 len, numDistancePairs; // it's not used - ReadMatchDistances(out len, out numDistancePairs); - UInt32 posState = (UInt32)(nowPos64) & _posStateMask; - _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].Encode(_rangeEncoder, 0); - _state.UpdateChar(); - Byte curByte = _matchFinder.GetIndexByte((Int32)(0 - _additionalOffset)); - _literalEncoder.GetSubCoder((UInt32)(nowPos64), _previousByte).Encode(_rangeEncoder, curByte); - _previousByte = curByte; - _additionalOffset--; - nowPos64++; - } - if (_matchFinder.GetNumAvailableBytes() == 0) - { - Flush((UInt32)nowPos64); - return; - } - while (true) - { - UInt32 pos; - UInt32 len = GetOptimum((UInt32)nowPos64, out pos); - - UInt32 posState = ((UInt32)nowPos64) & _posStateMask; - UInt32 complexState = (_state.Index << Base.kNumPosStatesBitsMax) + posState; - if (len == 1 && pos == 0xFFFFFFFF) - { - _isMatch[complexState].Encode(_rangeEncoder, 0); - Byte curByte = _matchFinder.GetIndexByte((Int32)(0 - _additionalOffset)); - LiteralEncoder.Encoder2 subCoder = _literalEncoder.GetSubCoder((UInt32)nowPos64, _previousByte); - if (!_state.IsCharState()) - { - Byte matchByte = _matchFinder.GetIndexByte((Int32)(0 - _repDistances[0] - 1 - _additionalOffset)); - subCoder.EncodeMatched(_rangeEncoder, matchByte, curByte); - } - else - subCoder.Encode(_rangeEncoder, curByte); - _previousByte = curByte; - _state.UpdateChar(); - } - else - { - _isMatch[complexState].Encode(_rangeEncoder, 1); - if (pos < Base.kNumRepDistances) - { - _isRep[_state.Index].Encode(_rangeEncoder, 1); - if (pos == 0) - { - _isRepG0[_state.Index].Encode(_rangeEncoder, 0); - if (len == 1) - _isRep0Long[complexState].Encode(_rangeEncoder, 0); - else - _isRep0Long[complexState].Encode(_rangeEncoder, 1); - } - else - { - _isRepG0[_state.Index].Encode(_rangeEncoder, 1); - if (pos == 1) - _isRepG1[_state.Index].Encode(_rangeEncoder, 0); - else - { - _isRepG1[_state.Index].Encode(_rangeEncoder, 1); - _isRepG2[_state.Index].Encode(_rangeEncoder, pos - 2); - } - } - if (len == 1) - _state.UpdateShortRep(); - else - { - _repMatchLenEncoder.Encode(_rangeEncoder, len - Base.kMatchMinLen, posState); - _state.UpdateRep(); - } - UInt32 distance = _repDistances[pos]; - if (pos != 0) - { - for (UInt32 i = pos; i >= 1; i--) - _repDistances[i] = _repDistances[i - 1]; - _repDistances[0] = distance; - } - } - else - { - _isRep[_state.Index].Encode(_rangeEncoder, 0); - _state.UpdateMatch(); - _lenEncoder.Encode(_rangeEncoder, len - Base.kMatchMinLen, posState); - pos -= Base.kNumRepDistances; - UInt32 posSlot = GetPosSlot(pos); - UInt32 lenToPosState = Base.GetLenToPosState(len); - _posSlotEncoder[lenToPosState].Encode(_rangeEncoder, posSlot); - - if (posSlot >= Base.kStartPosModelIndex) - { - int footerBits = (int)((posSlot >> 1) - 1); - UInt32 baseVal = ((2 | (posSlot & 1)) << footerBits); - UInt32 posReduced = pos - baseVal; - - if (posSlot < Base.kEndPosModelIndex) - RangeCoder.BitTreeEncoder.ReverseEncode(_posEncoders, - baseVal - posSlot - 1, _rangeEncoder, footerBits, posReduced); - else - { - _rangeEncoder.EncodeDirectBits(posReduced >> Base.kNumAlignBits, footerBits - Base.kNumAlignBits); - _posAlignEncoder.ReverseEncode(_rangeEncoder, posReduced & Base.kAlignMask); - _alignPriceCount++; - } - } - UInt32 distance = pos; - for (UInt32 i = Base.kNumRepDistances - 1; i >= 1; i--) - _repDistances[i] = _repDistances[i - 1]; - _repDistances[0] = distance; - _matchPriceCount++; - } - _previousByte = _matchFinder.GetIndexByte((Int32)(len - 1 - _additionalOffset)); - } - _additionalOffset -= len; - nowPos64 += len; - if (_additionalOffset == 0) - { - // if (!_fastMode) - if (_matchPriceCount >= (1 << 7)) - FillDistancesPrices(); - if (_alignPriceCount >= Base.kAlignTableSize) - FillAlignPrices(); - inSize = nowPos64; - outSize = _rangeEncoder.GetProcessedSizeAdd(); - if (_matchFinder.GetNumAvailableBytes() == 0) - { - Flush((UInt32)nowPos64); - return; - } - - if (nowPos64 - progressPosValuePrev >= (1 << 12)) - { - _finished = false; - finished = false; - return; - } - } - } - } - - void ReleaseMFStream() - { - if (_matchFinder != null && _needReleaseMFStream) - { - _matchFinder.ReleaseStream(); - _needReleaseMFStream = false; - } - } - - void SetOutStream(System.IO.Stream outStream) { _rangeEncoder.SetStream(outStream); } - void ReleaseOutStream() { _rangeEncoder.ReleaseStream(); } - - void ReleaseStreams() - { - ReleaseMFStream(); - ReleaseOutStream(); - } - - void SetStreams(System.IO.Stream inStream, System.IO.Stream outStream, - Int64 inSize, Int64 outSize) - { - _inStream = inStream; - _finished = false; - Create(); - SetOutStream(outStream); - Init(); - - // if (!_fastMode) - { - FillDistancesPrices(); - FillAlignPrices(); - } - - _lenEncoder.SetTableSize(_numFastBytes + 1 - Base.kMatchMinLen); - _lenEncoder.UpdateTables((UInt32)1 << _posStateBits); - _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - Base.kMatchMinLen); - _repMatchLenEncoder.UpdateTables((UInt32)1 << _posStateBits); - - nowPos64 = 0; - } - - - public void Code(System.IO.Stream inStream, System.IO.Stream outStream, - Int64 inSize, Int64 outSize, ICodeProgress progress) - { - _needReleaseMFStream = false; - try - { - SetStreams(inStream, outStream, inSize, outSize); - while (true) - { - Int64 processedInSize; - Int64 processedOutSize; - bool finished; - CodeOneBlock(out processedInSize, out processedOutSize, out finished); - if (finished) - return; - if (progress != null) - { - progress.SetProgress(processedInSize, processedOutSize); - } - } - } - finally - { - ReleaseStreams(); - } - } - - const int kPropSize = 5; - Byte[] properties = new Byte[kPropSize]; - - public void WriteCoderProperties(System.IO.Stream outStream) - { - properties[0] = (Byte)((_posStateBits * 5 + _numLiteralPosStateBits) * 9 + _numLiteralContextBits); - for (int i = 0; i < 4; i++) - properties[1 + i] = (Byte)((_dictionarySize >> (8 * i)) & 0xFF); - outStream.Write(properties, 0, kPropSize); - } - - UInt32[] tempPrices = new UInt32[Base.kNumFullDistances]; - UInt32 _matchPriceCount; - - void FillDistancesPrices() - { - for (UInt32 i = Base.kStartPosModelIndex; i < Base.kNumFullDistances; i++) - { - UInt32 posSlot = GetPosSlot(i); - int footerBits = (int)((posSlot >> 1) - 1); - UInt32 baseVal = ((2 | (posSlot & 1)) << footerBits); - tempPrices[i] = BitTreeEncoder.ReverseGetPrice(_posEncoders, - baseVal - posSlot - 1, footerBits, i - baseVal); - } - - for (UInt32 lenToPosState = 0; lenToPosState < Base.kNumLenToPosStates; lenToPosState++) - { - UInt32 posSlot; - RangeCoder.BitTreeEncoder encoder = _posSlotEncoder[lenToPosState]; - - UInt32 st = (lenToPosState << Base.kNumPosSlotBits); - for (posSlot = 0; posSlot < _distTableSize; posSlot++) - _posSlotPrices[st + posSlot] = encoder.GetPrice(posSlot); - for (posSlot = Base.kEndPosModelIndex; posSlot < _distTableSize; posSlot++) - _posSlotPrices[st + posSlot] += ((((posSlot >> 1) - 1) - Base.kNumAlignBits) << RangeCoder.BitEncoder.kNumBitPriceShiftBits); - - UInt32 st2 = lenToPosState * Base.kNumFullDistances; - UInt32 i; - for (i = 0; i < Base.kStartPosModelIndex; i++) - _distancesPrices[st2 + i] = _posSlotPrices[st + i]; - for (; i < Base.kNumFullDistances; i++) - _distancesPrices[st2 + i] = _posSlotPrices[st + GetPosSlot(i)] + tempPrices[i]; - } - _matchPriceCount = 0; - } - - void FillAlignPrices() - { - for (UInt32 i = 0; i < Base.kAlignTableSize; i++) - _alignPrices[i] = _posAlignEncoder.ReverseGetPrice(i); - _alignPriceCount = 0; - } - - - static string[] kMatchFinderIDs = - { - "BT2", - "BT4", - }; - - static int FindMatchFinder(string s) - { - for (int m = 0; m < kMatchFinderIDs.Length; m++) - if (s == kMatchFinderIDs[m]) - return m; - return -1; - } - - public void SetCoderProperties(CoderPropID[] propIDs, object[] properties) - { - for (UInt32 i = 0; i < properties.Length; i++) - { - object prop = properties[i]; - switch (propIDs[i]) - { - case CoderPropID.NumFastBytes: - { - if (!(prop is Int32)) - throw new InvalidParamException(); - Int32 numFastBytes = (Int32)prop; - if (numFastBytes < 5 || numFastBytes > Base.kMatchMaxLen) - throw new InvalidParamException(); - _numFastBytes = (UInt32)numFastBytes; - break; - } - case CoderPropID.Algorithm: - { - /* - if (!(prop is Int32)) - throw new InvalidParamException(); - Int32 maximize = (Int32)prop; - _fastMode = (maximize == 0); - _maxMode = (maximize >= 2); - */ - break; - } - case CoderPropID.MatchFinder: - { - if (!(prop is String)) - throw new InvalidParamException(); - EMatchFinderType matchFinderIndexPrev = _matchFinderType; - int m = FindMatchFinder(((string)prop).ToUpper()); - if (m < 0) - throw new InvalidParamException(); - _matchFinderType = (EMatchFinderType)m; - if (_matchFinder != null && matchFinderIndexPrev != _matchFinderType) - { - _dictionarySizePrev = 0xFFFFFFFF; - _matchFinder = null; - } - break; - } - case CoderPropID.DictionarySize: - { - const int kDicLogSizeMaxCompress = 30; - if (!(prop is Int32)) - throw new InvalidParamException(); ; - Int32 dictionarySize = (Int32)prop; - if (dictionarySize < (UInt32)(1 << Base.kDicLogSizeMin) || - dictionarySize > (UInt32)(1 << kDicLogSizeMaxCompress)) - throw new InvalidParamException(); - _dictionarySize = (UInt32)dictionarySize; - int dicLogSize; - for (dicLogSize = 0; dicLogSize < (UInt32)kDicLogSizeMaxCompress; dicLogSize++) - if (dictionarySize <= ((UInt32)(1) << dicLogSize)) - break; - _distTableSize = (UInt32)dicLogSize * 2; - break; - } - case CoderPropID.PosStateBits: - { - if (!(prop is Int32)) - throw new InvalidParamException(); - Int32 v = (Int32)prop; - if (v < 0 || v > (UInt32)Base.kNumPosStatesBitsEncodingMax) - throw new InvalidParamException(); - _posStateBits = (int)v; - _posStateMask = (((UInt32)1) << (int)_posStateBits) - 1; - break; - } - case CoderPropID.LitPosBits: - { - if (!(prop is Int32)) - throw new InvalidParamException(); - Int32 v = (Int32)prop; - if (v < 0 || v > (UInt32)Base.kNumLitPosStatesBitsEncodingMax) - throw new InvalidParamException(); - _numLiteralPosStateBits = (int)v; - break; - } - case CoderPropID.LitContextBits: - { - if (!(prop is Int32)) - throw new InvalidParamException(); - Int32 v = (Int32)prop; - if (v < 0 || v > (UInt32)Base.kNumLitContextBitsMax) - throw new InvalidParamException(); ; - _numLiteralContextBits = (int)v; - break; - } - case CoderPropID.EndMarker: - { - if (!(prop is Boolean)) - throw new InvalidParamException(); - SetWriteEndMarkerMode((Boolean)prop); - break; - } - default: - throw new InvalidParamException(); - } - } - } - - uint _trainSize = 0; - public void SetTrainSize(uint trainSize) - { - _trainSize = trainSize; - } - - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoder.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoder.cs deleted file mode 100644 index d9c2e30ce0..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoder.cs +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; - -namespace SevenZip.Compression.RangeCoder -{ - class Encoder - { - public const uint kTopValue = (1 << 24); - - System.IO.Stream Stream; - - public UInt64 Low; - public uint Range; - uint _cacheSize; - byte _cache; - - long StartPosition; - - public void SetStream(System.IO.Stream stream) - { - Stream = stream; - } - - public void ReleaseStream() - { - Stream = null; - } - - public void Init() - { - StartPosition = Stream.Position; - - Low = 0; - Range = 0xFFFFFFFF; - _cacheSize = 1; - _cache = 0; - } - - public void FlushData() - { - for (int i = 0; i < 5; i++) - ShiftLow(); - } - - public void FlushStream() - { - Stream.Flush(); - } - - public void CloseStream() - { - Stream.Dispose(); - } - - public void Encode(uint start, uint size, uint total) - { - Low += start * (Range /= total); - Range *= size; - while (Range < kTopValue) - { - Range <<= 8; - ShiftLow(); - } - } - - public void ShiftLow() - { - if ((uint)Low < (uint)0xFF000000 || (uint)(Low >> 32) == 1) - { - byte temp = _cache; - do - { - Stream.WriteByte((byte)(temp + (Low >> 32))); - temp = 0xFF; - } - while (--_cacheSize != 0); - _cache = (byte)(((uint)Low) >> 24); - } - _cacheSize++; - Low = ((uint)Low) << 8; - } - - public void EncodeDirectBits(uint v, int numTotalBits) - { - for (int i = numTotalBits - 1; i >= 0; i--) - { - Range >>= 1; - if (((v >> i) & 1) == 1) - Low += Range; - if (Range < kTopValue) - { - Range <<= 8; - ShiftLow(); - } - } - } - - public void EncodeBit(uint size0, int numTotalBits, uint symbol) - { - uint newBound = (Range >> numTotalBits) * size0; - if (symbol == 0) - Range = newBound; - else - { - Low += newBound; - Range -= newBound; - } - while (Range < kTopValue) - { - Range <<= 8; - ShiftLow(); - } - } - - public long GetProcessedSizeAdd() - { - return _cacheSize + - Stream.Position - StartPosition + 4; - // (long)Stream.GetProcessedSize(); - } - } - - class Decoder - { - public const uint kTopValue = (1 << 24); - public uint Range; - public uint Code; - // public Buffer.InBuffer Stream = new Buffer.InBuffer(1 << 16); - public System.IO.Stream Stream; - - public void Init(System.IO.Stream stream) - { - // Stream.Init(stream); - Stream = stream; - - Code = 0; - Range = 0xFFFFFFFF; - for (int i = 0; i < 5; i++) - Code = (Code << 8) | (byte)Stream.ReadByte(); - } - - public void ReleaseStream() - { - // Stream.ReleaseStream(); - Stream = null; - } - - public void CloseStream() - { - Stream.Dispose(); - } - - public void Normalize() - { - while (Range < kTopValue) - { - Code = (Code << 8) | (byte)Stream.ReadByte(); - Range <<= 8; - } - } - - public void Normalize2() - { - if (Range < kTopValue) - { - Code = (Code << 8) | (byte)Stream.ReadByte(); - Range <<= 8; - } - } - - public uint GetThreshold(uint total) - { - return Code / (Range /= total); - } - - public void Decode(uint start, uint size, uint total) - { - Code -= start * Range; - Range *= size; - Normalize(); - } - - public uint DecodeDirectBits(int numTotalBits) - { - uint range = Range; - uint code = Code; - uint result = 0; - for (int i = numTotalBits; i > 0; i--) - { - range >>= 1; - /* - result <<= 1; - if (code >= range) - { - code -= range; - result |= 1; - } - */ - uint t = (code - range) >> 31; - code -= range & (t - 1); - result = (result << 1) | (1 - t); - - if (range < kTopValue) - { - code = (code << 8) | (byte)Stream.ReadByte(); - range <<= 8; - } - } - Range = range; - Code = code; - return result; - } - - public uint DecodeBit(uint size0, int numTotalBits) - { - uint newBound = (Range >> numTotalBits) * size0; - uint symbol; - if (Code < newBound) - { - symbol = 0; - Range = newBound; - } - else - { - symbol = 1; - Code -= newBound; - Range -= newBound; - } - Normalize(); - return symbol; - } - - // ulong GetProcessedSize() {return Stream.GetProcessedSize(); } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBit.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBit.cs deleted file mode 100644 index 46d27ed0f6..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBit.cs +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; - -namespace SevenZip.Compression.RangeCoder -{ - struct BitEncoder - { - public const int kNumBitModelTotalBits = 11; - public const uint kBitModelTotal = (1 << kNumBitModelTotalBits); - const int kNumMoveBits = 5; - const int kNumMoveReducingBits = 2; - public const int kNumBitPriceShiftBits = 6; - - uint Prob; - - public void Init() { Prob = kBitModelTotal >> 1; } - - public void UpdateModel(uint symbol) - { - if (symbol == 0) - Prob += (kBitModelTotal - Prob) >> kNumMoveBits; - else - Prob -= (Prob) >> kNumMoveBits; - } - - public void Encode(Encoder encoder, uint symbol) - { - // encoder.EncodeBit(Prob, kNumBitModelTotalBits, symbol); - // UpdateModel(symbol); - uint newBound = (encoder.Range >> kNumBitModelTotalBits) * Prob; - if (symbol == 0) - { - encoder.Range = newBound; - Prob += (kBitModelTotal - Prob) >> kNumMoveBits; - } - else - { - encoder.Low += newBound; - encoder.Range -= newBound; - Prob -= (Prob) >> kNumMoveBits; - } - if (encoder.Range < Encoder.kTopValue) - { - encoder.Range <<= 8; - encoder.ShiftLow(); - } - } - - private static UInt32[] ProbPrices = new UInt32[kBitModelTotal >> kNumMoveReducingBits]; - - static BitEncoder() - { - const int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits); - for (int i = kNumBits - 1; i >= 0; i--) - { - UInt32 start = (UInt32)1 << (kNumBits - i - 1); - UInt32 end = (UInt32)1 << (kNumBits - i); - for (UInt32 j = start; j < end; j++) - ProbPrices[j] = ((UInt32)i << kNumBitPriceShiftBits) + - (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1)); - } - } - - public uint GetPrice(uint symbol) - { - return ProbPrices[(((Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits]; - } - public uint GetPrice0() { return ProbPrices[Prob >> kNumMoveReducingBits]; } - public uint GetPrice1() { return ProbPrices[(kBitModelTotal - Prob) >> kNumMoveReducingBits]; } - } - - struct BitDecoder - { - public const int kNumBitModelTotalBits = 11; - public const uint kBitModelTotal = (1 << kNumBitModelTotalBits); - const int kNumMoveBits = 5; - - uint Prob; - - public void UpdateModel(int numMoveBits, uint symbol) - { - if (symbol == 0) - Prob += (kBitModelTotal - Prob) >> numMoveBits; - else - Prob -= (Prob) >> numMoveBits; - } - - public void Init() { Prob = kBitModelTotal >> 1; } - - public uint Decode(RangeCoder.Decoder rangeDecoder) - { - uint newBound = (uint)(rangeDecoder.Range >> kNumBitModelTotalBits) * (uint)Prob; - if (rangeDecoder.Code < newBound) - { - rangeDecoder.Range = newBound; - Prob += (kBitModelTotal - Prob) >> kNumMoveBits; - if (rangeDecoder.Range < Decoder.kTopValue) - { - rangeDecoder.Code = (rangeDecoder.Code << 8) | (byte)rangeDecoder.Stream.ReadByte(); - rangeDecoder.Range <<= 8; - } - return 0; - } - else - { - rangeDecoder.Range -= newBound; - rangeDecoder.Code -= newBound; - Prob -= (Prob) >> kNumMoveBits; - if (rangeDecoder.Range < Decoder.kTopValue) - { - rangeDecoder.Code = (rangeDecoder.Code << 8) | (byte)rangeDecoder.Stream.ReadByte(); - rangeDecoder.Range <<= 8; - } - return 1; - } - } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs b/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs deleted file mode 100644 index f7985c47ba..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; - -namespace SevenZip.Compression.RangeCoder -{ - struct BitTreeEncoder - { - BitEncoder[] Models; - int NumBitLevels; - - public BitTreeEncoder(int numBitLevels) - { - NumBitLevels = numBitLevels; - Models = new BitEncoder[1 << numBitLevels]; - } - - public void Init() - { - for (uint i = 1; i < (1 << NumBitLevels); i++) - Models[i].Init(); - } - - public void Encode(Encoder rangeEncoder, UInt32 symbol) - { - UInt32 m = 1; - for (int bitIndex = NumBitLevels; bitIndex > 0; ) - { - bitIndex--; - UInt32 bit = (symbol >> bitIndex) & 1; - Models[m].Encode(rangeEncoder, bit); - m = (m << 1) | bit; - } - } - - public void ReverseEncode(Encoder rangeEncoder, UInt32 symbol) - { - UInt32 m = 1; - for (UInt32 i = 0; i < NumBitLevels; i++) - { - UInt32 bit = symbol & 1; - Models[m].Encode(rangeEncoder, bit); - m = (m << 1) | bit; - symbol >>= 1; - } - } - - public UInt32 GetPrice(UInt32 symbol) - { - UInt32 price = 0; - UInt32 m = 1; - for (int bitIndex = NumBitLevels; bitIndex > 0; ) - { - bitIndex--; - UInt32 bit = (symbol >> bitIndex) & 1; - price += Models[m].GetPrice(bit); - m = (m << 1) + bit; - } - return price; - } - - public UInt32 ReverseGetPrice(UInt32 symbol) - { - UInt32 price = 0; - UInt32 m = 1; - for (int i = NumBitLevels; i > 0; i--) - { - UInt32 bit = symbol & 1; - symbol >>= 1; - price += Models[m].GetPrice(bit); - m = (m << 1) | bit; - } - return price; - } - - public static UInt32 ReverseGetPrice(BitEncoder[] Models, UInt32 startIndex, - int NumBitLevels, UInt32 symbol) - { - UInt32 price = 0; - UInt32 m = 1; - for (int i = NumBitLevels; i > 0; i--) - { - UInt32 bit = symbol & 1; - symbol >>= 1; - price += Models[startIndex + m].GetPrice(bit); - m = (m << 1) | bit; - } - return price; - } - - public static void ReverseEncode(BitEncoder[] Models, UInt32 startIndex, - Encoder rangeEncoder, int NumBitLevels, UInt32 symbol) - { - UInt32 m = 1; - for (int i = 0; i < NumBitLevels; i++) - { - UInt32 bit = symbol & 1; - Models[startIndex + m].Encode(rangeEncoder, bit); - m = (m << 1) | bit; - symbol >>= 1; - } - } - } - - struct BitTreeDecoder - { - BitDecoder[] Models; - int NumBitLevels; - - public BitTreeDecoder(int numBitLevels) - { - NumBitLevels = numBitLevels; - Models = new BitDecoder[1 << numBitLevels]; - } - - public void Init() - { - for (uint i = 1; i < (1 << NumBitLevels); i++) - Models[i].Init(); - } - - public uint Decode(RangeCoder.Decoder rangeDecoder) - { - uint m = 1; - for (int bitIndex = NumBitLevels; bitIndex > 0; bitIndex--) - m = (m << 1) + Models[m].Decode(rangeDecoder); - return m - ((uint)1 << NumBitLevels); - } - - public uint ReverseDecode(RangeCoder.Decoder rangeDecoder) - { - uint m = 1; - uint symbol = 0; - for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++) - { - uint bit = Models[m].Decode(rangeDecoder); - m <<= 1; - m += bit; - symbol |= (bit << bitIndex); - } - return symbol; - } - - public static uint ReverseDecode(BitDecoder[] Models, UInt32 startIndex, - RangeCoder.Decoder rangeDecoder, int NumBitLevels) - { - uint m = 1; - uint symbol = 0; - for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++) - { - uint bit = Models[startIndex + m].Decode(rangeDecoder); - m <<= 1; - m += bit; - symbol |= (bit << bitIndex); - } - return symbol; - } - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/ICoder.cs b/src/Microsoft.DotNet.Archive/LZMA/ICoder.cs deleted file mode 100644 index 992f6823fb..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/ICoder.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -// ICoder.h - -using System; - -namespace SevenZip -{ - /// - /// The exception that is thrown when an error in input stream occurs during decoding. - /// - class DataErrorException : Exception - { - public DataErrorException(): base("Data Error") { } - } - - /// - /// The exception that is thrown when the value of an argument is outside the allowable range. - /// - class InvalidParamException : Exception - { - public InvalidParamException(): base("Invalid Parameter") { } - } - - public interface ICodeProgress - { - /// - /// Callback progress. - /// - /// - /// input size. -1 if unknown. - /// - /// - /// output size. -1 if unknown. - /// - void SetProgress(Int64 inSize, Int64 outSize); - }; - - public interface ICoder - { - /// - /// Codes streams. - /// - /// - /// input Stream. - /// - /// - /// output Stream. - /// - /// - /// input Size. -1 if unknown. - /// - /// - /// output Size. -1 if unknown. - /// - /// - /// callback progress reference. - /// - /// - /// if input stream is not valid - /// - void Code(System.IO.Stream inStream, System.IO.Stream outStream, - Int64 inSize, Int64 outSize, ICodeProgress progress); - }; - - /* - public interface ICoder2 - { - void Code(ISequentialInStream []inStreams, - const UInt64 []inSizes, - ISequentialOutStream []outStreams, - UInt64 []outSizes, - ICodeProgress progress); - }; - */ - - /// - /// Provides the fields that represent properties idenitifiers for compressing. - /// - public enum CoderPropID - { - /// - /// Specifies default property. - /// - DefaultProp = 0, - /// - /// Specifies size of dictionary. - /// - DictionarySize, - /// - /// Specifies size of memory for PPM*. - /// - UsedMemorySize, - /// - /// Specifies order for PPM methods. - /// - Order, - /// - /// Specifies Block Size. - /// - BlockSize, - /// - /// Specifies number of postion state bits for LZMA (0 <= x <= 4). - /// - PosStateBits, - /// - /// Specifies number of literal context bits for LZMA (0 <= x <= 8). - /// - LitContextBits, - /// - /// Specifies number of literal position bits for LZMA (0 <= x <= 4). - /// - LitPosBits, - /// - /// Specifies number of fast bytes for LZ*. - /// - NumFastBytes, - /// - /// Specifies match finder. LZMA: "BT2", "BT4" or "BT4B". - /// - MatchFinder, - /// - /// Specifies the number of match finder cyckes. - /// - MatchFinderCycles, - /// - /// Specifies number of passes. - /// - NumPasses, - /// - /// Specifies number of algorithm. - /// - Algorithm, - /// - /// Specifies the number of threads. - /// - NumThreads, - /// - /// Specifies mode with end marker. - /// - EndMarker - }; - - - public interface ISetCoderProperties - { - void SetCoderProperties(CoderPropID[] propIDs, object[] properties); - }; - - public interface IWriteCoderProperties - { - void WriteCoderProperties(System.IO.Stream outStream); - } - - public interface ISetDecoderProperties - { - void SetDecoderProperties(byte[] properties); - } -} diff --git a/src/Microsoft.DotNet.Archive/LZMA/README.md b/src/Microsoft.DotNet.Archive/LZMA/README.md deleted file mode 100644 index 74e2758529..0000000000 --- a/src/Microsoft.DotNet.Archive/LZMA/README.md +++ /dev/null @@ -1,10 +0,0 @@ -## LZMA SDK -This source came from the C# implementation of LZMA from the LZMA SDK, version 16.02, from http://www.7-zip.org/sdk.html. - -## License -LZMA SDK is placed in the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original LZMA SDK code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. - -## Thanks! -Thanks goes to Igor Pavlov for making this available. diff --git a/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj b/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj deleted file mode 100644 index 3bd7d6263e..0000000000 --- a/src/Microsoft.DotNet.Archive/Microsoft.DotNet.Archive.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - netcoreapp2.0 - false - - - diff --git a/src/Microsoft.DotNet.Archive/ProgressReport.cs b/src/Microsoft.DotNet.Archive/ProgressReport.cs deleted file mode 100644 index 6eb9555633..0000000000 --- a/src/Microsoft.DotNet.Archive/ProgressReport.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; - -namespace Microsoft.DotNet.Archive -{ - public struct ProgressReport - { - public ProgressReport(string phase, long ticks, long total) - { - Phase = phase; - Ticks = ticks; - Total = total; - } - public string Phase { get; } - public long Ticks { get; } - public long Total { get; } - } - - public static class ProgressReportExtensions - { - public static void Report(this IProgress progress, string phase, long ticks, long total) - { - progress.Report(new ProgressReport(phase, ticks, total)); - } - } - -} diff --git a/src/Microsoft.DotNet.Archive/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.Archive/Properties/AssemblyInfo.cs deleted file mode 100644 index 110018e7fd..0000000000 --- a/src/Microsoft.DotNet.Archive/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Reflection; - -[assembly: AssemblyMetadataAttribute("Serviceable", "True")] diff --git a/src/Microsoft.DotNet.Archive/ThreadLocalZipArchive.cs b/src/Microsoft.DotNet.Archive/ThreadLocalZipArchive.cs deleted file mode 100644 index 7f61207cb5..0000000000 --- a/src/Microsoft.DotNet.Archive/ThreadLocalZipArchive.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.IO; -using System.IO.Compression; -using System.Threading; - -namespace Microsoft.DotNet.Archive -{ - /// - /// Wraps ThreadLocal and exposes Dispose semantics that dispose all archives - /// - internal class ThreadLocalZipArchive : IDisposable - { - private ThreadLocal _archive; - private bool _disposed = false; - - public ThreadLocalZipArchive(string archivePath, ZipArchive local = null) - { - _archive = new ThreadLocal(() => - new ZipArchive(File.Open(archivePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete), ZipArchiveMode.Read), - trackAllValues:true); - - if (local != null) - { - // reuse provided one for current thread - _archive.Value = local; - } - } - - public ZipArchive Archive { get { return _archive.Value; } } - - public void Dispose() - { - if (!_disposed) - { - if (_archive != null) - { - // dispose all archives - if (_archive.Values != null) - { - foreach (var value in _archive.Values) - { - if (value != null) - { - value.Dispose(); - } - } - } - - // dispose ThreadLocal - _archive.Dispose(); - _archive = null; - } - } - } - } -} diff --git a/src/dotnet-archive/CommandLine/CommandArgument.cs b/src/dotnet-archive/CommandLine/CommandArgument.cs deleted file mode 100644 index 045609d79f..0000000000 --- a/src/dotnet-archive/CommandLine/CommandArgument.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.DotNet.Cli.CommandLine -{ - internal class CommandArgument - { - public CommandArgument() - { - Values = new List(); - } - - public string Name { get; set; } - public string Description { get; set; } - public List Values { get; private set; } - public bool MultipleValues { get; set; } - public string Value - { - get - { - return Values.FirstOrDefault(); - } - } - } -} diff --git a/src/dotnet-archive/CommandLine/CommandLineApplication.cs b/src/dotnet-archive/CommandLine/CommandLineApplication.cs deleted file mode 100644 index 64b6b3d17c..0000000000 --- a/src/dotnet-archive/CommandLine/CommandLineApplication.cs +++ /dev/null @@ -1,693 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Microsoft.DotNet.Cli.CommandLine -{ - internal class CommandLineApplication - { - private enum ParseOptionResult - { - Succeeded, - ShowHelp, - ShowVersion, - UnexpectedArgs, - } - - // Indicates whether the parser should throw an exception when it runs into an unexpected argument. - // If this field is set to false, the parser will stop parsing when it sees an unexpected argument, and all - // remaining arguments, including the first unexpected argument, will be stored in RemainingArguments property. - private readonly bool _throwOnUnexpectedArg; - - public CommandLineApplication(bool throwOnUnexpectedArg = true) - { - _throwOnUnexpectedArg = throwOnUnexpectedArg; - Options = new List(); - Arguments = new List(); - Commands = new List(); - RemainingArguments = new List(); - Invoke = () => 0; - } - - public CommandLineApplication Parent { get; set; } - public string Name { get; set; } - public string FullName { get; set; } - public string Syntax { get; set; } - public string Description { get; set; } - public List Options { get; private set; } - public CommandOption OptionHelp { get; private set; } - public CommandOption OptionVersion { get; private set; } - public List Arguments { get; private set; } - public List RemainingArguments { get; private set; } - public bool IsShowingInformation { get; protected set; } // Is showing help or version? - public Func Invoke { get; set; } - public Func LongVersionGetter { get; set; } - public Func ShortVersionGetter { get; set; } - public List Commands { get; private set; } - public bool HandleResponseFiles { get; set; } - public bool AllowArgumentSeparator { get; set; } - public bool HandleRemainingArguments { get; set; } - public string ArgumentSeparatorHelpText { get; set; } - - public CommandLineApplication AddCommand(string name, bool throwOnUnexpectedArg = true) - { - return AddCommand(name, _ => { }, throwOnUnexpectedArg); - } - - public CommandLineApplication AddCommand(string name, Action configuration, - bool throwOnUnexpectedArg = true) - { - var command = new CommandLineApplication(throwOnUnexpectedArg) { Name = name }; - return AddCommand(command, configuration, throwOnUnexpectedArg); - } - - public CommandLineApplication AddCommand(CommandLineApplication command, bool throwOnUnexpectedArg = true) - { - return AddCommand(command, _ => { }, throwOnUnexpectedArg); - } - - public CommandLineApplication AddCommand( - CommandLineApplication command, - Action configuration, - bool throwOnUnexpectedArg = true) - { - if (command == null || configuration == null) - { - throw new NullReferenceException(); - } - - command.Parent = this; - Commands.Add(command); - configuration(command); - return command; - } - - public CommandOption Option(string template, string description, CommandOptionType optionType) - { - return Option(template, description, optionType, _ => { }); - } - - public CommandOption Option(string template, string description, CommandOptionType optionType, Action configuration) - { - var option = new CommandOption(template, optionType) { Description = description }; - Options.Add(option); - configuration(option); - return option; - } - - public CommandArgument Argument(string name, string description, bool multipleValues = false) - { - return Argument(name, description, _ => { }, multipleValues); - } - - public CommandArgument Argument(string name, string description, Action configuration, bool multipleValues = false) - { - var lastArg = Arguments.LastOrDefault(); - if (lastArg != null && lastArg.MultipleValues) - { - var message = string.Format(LocalizableStrings.LastArgumentMultiValueError, - lastArg.Name); - throw new InvalidOperationException(message); - } - - var argument = new CommandArgument { Name = name, Description = description, MultipleValues = multipleValues }; - Arguments.Add(argument); - configuration(argument); - return argument; - } - - public void OnExecute(Func invoke) - { - Invoke = invoke; - } - - public void OnExecute(Func> invoke) - { - Invoke = () => invoke().Result; - } - - public int Execute(params string[] args) - { - CommandLineApplication command = this; - CommandArgumentEnumerator arguments = null; - - if (HandleResponseFiles) - { - args = ExpandResponseFiles(args).ToArray(); - } - - for (var index = 0; index < args.Length; index++) - { - var arg = args[index]; - - bool isLongOption = arg.StartsWith("--"); - if (arg == "-?" || arg == "/?") - { - command.ShowHelp(); - return 0; - } - else if (isLongOption || arg.StartsWith("-")) - { - CommandOption option; - - var result = ParseOption(isLongOption, command, args, ref index, out option); - - - if (result == ParseOptionResult.ShowHelp) - { - command.ShowHelp(); - return 0; - } - else if (result == ParseOptionResult.ShowVersion) - { - command.ShowVersion(); - return 0; - } - else if (result == ParseOptionResult.UnexpectedArgs) - { - break; - } - } - else - { - var subcommand = ParseSubCommand(arg, command); - if (subcommand != null) - { - command = subcommand; - } - else - { - if (arguments == null || arguments.CommandName != command.Name) - { - arguments = new CommandArgumentEnumerator(command.Arguments.GetEnumerator(), command.Name); - } - - if (arguments.MoveNext()) - { - arguments.Current.Values.Add(arg); - } - else - { - HandleUnexpectedArg(command, args, index, argTypeName: "command or argument"); - break; - } - } - } - } - - if (Commands.Count > 0 && command == this) - { - throw new CommandParsingException( - command, - "Required command missing", - isRequiredSubCommandMissing: true); - } - - return command.Invoke(); - } - - private ParseOptionResult ParseOption( - bool isLongOption, - CommandLineApplication command, - string[] args, - ref int index, - out CommandOption option) - { - option = null; - ParseOptionResult result = ParseOptionResult.Succeeded; - var arg = args[index]; - - int optionPrefixLength = isLongOption ? 2 : 1; - string[] optionComponents = arg.Substring(optionPrefixLength).Split(new[] { ':', '=' }, 2); - string optionName = optionComponents[0]; - - if (isLongOption) - { - option = command.Options.SingleOrDefault( - opt => string.Equals(opt.LongName, optionName, StringComparison.Ordinal)); - } - else - { - option = command.Options.SingleOrDefault( - opt => string.Equals(opt.ShortName, optionName, StringComparison.Ordinal)); - - if (option == null) - { - option = command.Options.SingleOrDefault( - opt => string.Equals(opt.SymbolName, optionName, StringComparison.Ordinal)); - } - } - - if (option == null) - { - if (isLongOption && string.IsNullOrEmpty(optionName) && - !command._throwOnUnexpectedArg && AllowArgumentSeparator) - { - // a stand-alone "--" is the argument separator, so skip it and - // handle the rest of the args as unexpected args - index++; - } - - HandleUnexpectedArg(command, args, index, argTypeName: "option"); - result = ParseOptionResult.UnexpectedArgs; - } - else if (command.OptionHelp == option) - { - result = ParseOptionResult.ShowHelp; - } - else if (command.OptionVersion == option) - { - result = ParseOptionResult.ShowVersion; - } - else - { - if (optionComponents.Length == 2) - { - if (!option.TryParse(optionComponents[1])) - { - command.ShowHint(); - throw new CommandParsingException(command, - String.Format(LocalizableStrings.UnexpectedValueForOptionError, optionComponents[1], optionName)); - } - } - else - { - if (option.OptionType == CommandOptionType.NoValue || - option.OptionType == CommandOptionType.BoolValue) - { - // No value is needed for this option - option.TryParse(null); - } - else - { - index++; - - if (index < args.Length) - { - arg = args[index]; - if (!option.TryParse(arg)) - { - command.ShowHint(); - throw new CommandParsingException( - command, - String.Format(LocalizableStrings.UnexpectedValueForOptionError, arg, optionName)); - } - } - else - { - command.ShowHint(); - throw new CommandParsingException( - command, - String.Format(LocalizableStrings.OptionRequiresSingleValueWhichIsMissing, arg, optionName)); - } - } - } - } - - return result; - } - - private CommandLineApplication ParseSubCommand(string arg, CommandLineApplication command) - { - foreach (var subcommand in command.Commands) - { - if (string.Equals(subcommand.Name, arg, StringComparison.OrdinalIgnoreCase)) - { - return subcommand; - } - } - - return null; - } - - // Helper method that adds a help option - public CommandOption HelpOption(string template) - { - // Help option is special because we stop parsing once we see it - // So we store it separately for further use - OptionHelp = Option(template, LocalizableStrings.ShowHelpInfo, CommandOptionType.NoValue); - - return OptionHelp; - } - - public CommandOption VersionOption(string template, - string shortFormVersion, - string longFormVersion = null) - { - if (longFormVersion == null) - { - return VersionOption(template, () => shortFormVersion); - } - else - { - return VersionOption(template, () => shortFormVersion, () => longFormVersion); - } - } - - // Helper method that adds a version option - public CommandOption VersionOption(string template, - Func shortFormVersionGetter, - Func longFormVersionGetter = null) - { - // Version option is special because we stop parsing once we see it - // So we store it separately for further use - OptionVersion = Option(template, LocalizableStrings.ShowVersionInfo, CommandOptionType.NoValue); - ShortVersionGetter = shortFormVersionGetter; - LongVersionGetter = longFormVersionGetter ?? shortFormVersionGetter; - - return OptionVersion; - } - - // Show short hint that reminds users to use help option - public void ShowHint() - { - if (OptionHelp != null) - { - Console.WriteLine(string.Format(LocalizableStrings.ShowHintInfo, OptionHelp.LongName)); - } - } - - // Show full help - public void ShowHelp(string commandName = null) - { - var headerBuilder = new StringBuilder(LocalizableStrings.UsageHeader); - var usagePrefixLength = headerBuilder.Length; - for (var cmd = this; cmd != null; cmd = cmd.Parent) - { - cmd.IsShowingInformation = true; - if (cmd != this && cmd.Arguments.Any()) - { - var args = string.Join(" ", cmd.Arguments.Select(arg => arg.Name)); - headerBuilder.Insert(usagePrefixLength, string.Format(" {0} {1}", cmd.Name, args)); - } - else - { - headerBuilder.Insert(usagePrefixLength, string.Format(" {0}", cmd.Name)); - } - } - - CommandLineApplication target; - - if (commandName == null || string.Equals(Name, commandName, StringComparison.OrdinalIgnoreCase)) - { - target = this; - } - else - { - target = Commands.SingleOrDefault(cmd => string.Equals(cmd.Name, commandName, StringComparison.OrdinalIgnoreCase)); - - if (target != null) - { - headerBuilder.AppendFormat(" {0}", commandName); - } - else - { - // The command name is invalid so don't try to show help for something that doesn't exist - target = this; - } - - } - - var optionsBuilder = new StringBuilder(); - var commandsBuilder = new StringBuilder(); - var argumentsBuilder = new StringBuilder(); - var argumentSeparatorBuilder = new StringBuilder(); - - int maxArgLen = 0; - for (var cmd = target; cmd != null; cmd = cmd.Parent) - { - if (cmd.Arguments.Any()) - { - if (cmd == target) - { - headerBuilder.Append(LocalizableStrings.UsageArgumentsToken); - } - - if (argumentsBuilder.Length == 0) - { - argumentsBuilder.AppendLine(); - argumentsBuilder.AppendLine(LocalizableStrings.UsageArgumentsHeader); - } - - maxArgLen = Math.Max(maxArgLen, MaxArgumentLength(cmd.Arguments)); - } - } - - for (var cmd = target; cmd != null; cmd = cmd.Parent) - { - if (cmd.Arguments.Any()) - { - foreach (var arg in cmd.Arguments) - { - argumentsBuilder.AppendFormat( - " {0}{1}", - arg.Name.PadRight(maxArgLen + 2), - arg.Description); - argumentsBuilder.AppendLine(); - } - } - } - - if (target.Options.Any()) - { - headerBuilder.Append(LocalizableStrings.UsageOptionsToken); - - optionsBuilder.AppendLine(); - optionsBuilder.AppendLine(LocalizableStrings.UsageOptionsHeader); - var maxOptLen = MaxOptionTemplateLength(target.Options); - var outputFormat = string.Format(" {{0, -{0}}}{{1}}", maxOptLen + 2); - foreach (var opt in target.Options) - { - optionsBuilder.AppendFormat(outputFormat, opt.Template, opt.Description); - optionsBuilder.AppendLine(); - } - } - - if (target.Commands.Any()) - { - headerBuilder.Append(LocalizableStrings.UsageCommandToken); - - commandsBuilder.AppendLine(); - commandsBuilder.AppendLine(LocalizableStrings.UsageCommandsHeader); - var maxCmdLen = MaxCommandLength(target.Commands); - var outputFormat = string.Format(" {{0, -{0}}}{{1}}", maxCmdLen + 2); - foreach (var cmd in target.Commands.OrderBy(c => c.Name)) - { - commandsBuilder.AppendFormat(outputFormat, cmd.Name, cmd.Description); - commandsBuilder.AppendLine(); - } - - if (OptionHelp != null) - { - commandsBuilder.AppendLine(); - commandsBuilder.AppendFormat(LocalizableStrings.UsageCommandsDetailHelp, Name); - commandsBuilder.AppendLine(); - } - } - - if (target.AllowArgumentSeparator || target.HandleRemainingArguments) - { - if (target.AllowArgumentSeparator) - { - headerBuilder.Append(LocalizableStrings.UsageCommandAdditionalArgs); - } - else - { - headerBuilder.Append(LocalizableStrings.UsageCommandArgs); - } - - if (!string.IsNullOrEmpty(target.ArgumentSeparatorHelpText)) - { - argumentSeparatorBuilder.AppendLine(); - argumentSeparatorBuilder.AppendLine(LocalizableStrings.UsageCommandsAdditionalArgsHeader); - argumentSeparatorBuilder.AppendLine(String.Format(" {0}", target.ArgumentSeparatorHelpText)); - argumentSeparatorBuilder.AppendLine(); - } - } - - headerBuilder.AppendLine(); - - var nameAndVersion = new StringBuilder(); - nameAndVersion.AppendLine(GetFullNameAndVersion()); - nameAndVersion.AppendLine(); - - Console.Write("{0}{1}{2}{3}{4}{5}", nameAndVersion, headerBuilder, argumentsBuilder, optionsBuilder, commandsBuilder, argumentSeparatorBuilder); - } - - public void ShowVersion() - { - for (var cmd = this; cmd != null; cmd = cmd.Parent) - { - cmd.IsShowingInformation = true; - } - - Console.WriteLine(FullName); - Console.WriteLine(LongVersionGetter()); - } - - public string GetFullNameAndVersion() - { - return ShortVersionGetter == null ? FullName : string.Format("{0} {1}", FullName, ShortVersionGetter()); - } - - public void ShowRootCommandFullNameAndVersion() - { - var rootCmd = this; - while (rootCmd.Parent != null) - { - rootCmd = rootCmd.Parent; - } - - Console.WriteLine(rootCmd.GetFullNameAndVersion()); - Console.WriteLine(); - } - - private int MaxOptionTemplateLength(IEnumerable options) - { - var maxLen = 0; - foreach (var opt in options) - { - maxLen = opt.Template.Length > maxLen ? opt.Template.Length : maxLen; - } - return maxLen; - } - - private int MaxCommandLength(IEnumerable commands) - { - var maxLen = 0; - foreach (var cmd in commands) - { - maxLen = cmd.Name.Length > maxLen ? cmd.Name.Length : maxLen; - } - return maxLen; - } - - private int MaxArgumentLength(IEnumerable arguments) - { - var maxLen = 0; - foreach (var arg in arguments) - { - maxLen = arg.Name.Length > maxLen ? arg.Name.Length : maxLen; - } - return maxLen; - } - - private void HandleUnexpectedArg(CommandLineApplication command, string[] args, int index, string argTypeName) - { - if (command._throwOnUnexpectedArg) - { - command.ShowHint(); - throw new CommandParsingException(command, String.Format(LocalizableStrings.UnexpectedArgumentError, argTypeName, args[index])); - } - else - { - // All remaining arguments are stored for further use - command.RemainingArguments.AddRange(new ArraySegment(args, index, args.Length - index)); - } - } - - private IEnumerable ExpandResponseFiles(IEnumerable args) - { - foreach (var arg in args) - { - if (!arg.StartsWith("@", StringComparison.Ordinal)) - { - yield return arg; - } - else - { - var fileName = arg.Substring(1); - - var responseFileArguments = ParseResponseFile(fileName); - - // ParseResponseFile can suppress expanding this response file by - // returning null. In that case, we'll treat the response - // file token as a regular argument. - - if (responseFileArguments == null) - { - yield return arg; - } - else - { - foreach (var responseFileArgument in responseFileArguments) - yield return responseFileArgument.Trim(); - } - } - } - } - - private IEnumerable ParseResponseFile(string fileName) - { - if (!HandleResponseFiles) - return null; - - if (!File.Exists(fileName)) - { - throw new InvalidOperationException(String.Format(LocalizableStrings.ResponseFileNotFoundError, fileName)); - } - - return File.ReadLines(fileName); - } - - private class CommandArgumentEnumerator : IEnumerator - { - private readonly IEnumerator _enumerator; - - public CommandArgumentEnumerator( - IEnumerator enumerator, - string commandName) - { - CommandName = commandName; - _enumerator = enumerator; - } - - public string CommandName { get; } - - public CommandArgument Current - { - get - { - return _enumerator.Current; - } - } - - object IEnumerator.Current - { - get - { - return Current; - } - } - - public void Dispose() - { - _enumerator.Dispose(); - } - - public bool MoveNext() - { - if (Current == null || !Current.MultipleValues) - { - return _enumerator.MoveNext(); - } - - // If current argument allows multiple values, we don't move forward and - // all later values will be added to current CommandArgument.Values - return true; - } - - public void Reset() - { - _enumerator.Reset(); - } - } - } -} diff --git a/src/dotnet-archive/CommandLine/CommandOption.cs b/src/dotnet-archive/CommandLine/CommandOption.cs deleted file mode 100644 index caed0bd779..0000000000 --- a/src/dotnet-archive/CommandLine/CommandOption.cs +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.DotNet.Cli.CommandLine -{ - internal class CommandOption - { - public CommandOption(string template, CommandOptionType optionType) - { - Template = template; - OptionType = optionType; - Values = new List(); - - foreach (var part in Template.Split(new[] { ' ', '|' }, StringSplitOptions.RemoveEmptyEntries)) - { - if (part.StartsWith("--")) - { - LongName = part.Substring(2); - } - else if (part.StartsWith("-")) - { - var optName = part.Substring(1); - - // If there is only one char and it is not an English letter, it is a symbol option (e.g. "-?") - if (optName.Length == 1 && !IsEnglishLetter(optName[0])) - { - SymbolName = optName; - } - else - { - ShortName = optName; - } - } - else if (part.StartsWith("<") && part.EndsWith(">")) - { - ValueName = part.Substring(1, part.Length - 2); - } - else if (optionType == CommandOptionType.MultipleValue && part.StartsWith("<") && part.EndsWith(">...")) - { - ValueName = part.Substring(1, part.Length - 5); - } - else - { - throw new ArgumentException(String.Format(LocalizableStrings.InvalidTemplateError, nameof(template))); - } - } - - if (string.IsNullOrEmpty(LongName) && string.IsNullOrEmpty(ShortName) && string.IsNullOrEmpty(SymbolName)) - { - throw new ArgumentException(LocalizableStrings.InvalidTemplateError, nameof(template)); - } - } - - public string Template { get; set; } - public string ShortName { get; set; } - public string LongName { get; set; } - public string SymbolName { get; set; } - public string ValueName { get; set; } - public string Description { get; set; } - public List Values { get; private set; } - public bool? BoolValue { get; private set; } - public CommandOptionType OptionType { get; private set; } - - public bool TryParse(string value) - { - switch (OptionType) - { - case CommandOptionType.MultipleValue: - Values.Add(value); - break; - case CommandOptionType.SingleValue: - if (Values.Any()) - { - return false; - } - Values.Add(value); - break; - case CommandOptionType.BoolValue: - if (Values.Any()) - { - return false; - } - - if (value == null) - { - // add null to indicate that the option was present, but had no value - Values.Add(null); - BoolValue = true; - } - else - { - bool boolValue; - if (!bool.TryParse(value, out boolValue)) - { - return false; - } - - Values.Add(value); - BoolValue = boolValue; - } - break; - case CommandOptionType.NoValue: - if (value != null) - { - return false; - } - // Add a value to indicate that this option was specified - Values.Add("on"); - break; - default: - break; - } - return true; - } - - public bool HasValue() - { - return Values.Any(); - } - - public string Value() - { - return HasValue() ? Values[0] : null; - } - - private bool IsEnglishLetter(char c) - { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); - } - } -} diff --git a/src/dotnet-archive/CommandLine/CommandOptionType.cs b/src/dotnet-archive/CommandLine/CommandOptionType.cs deleted file mode 100644 index 6cee7406b7..0000000000 --- a/src/dotnet-archive/CommandLine/CommandOptionType.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - - -namespace Microsoft.DotNet.Cli.CommandLine -{ - internal enum CommandOptionType - { - MultipleValue, - SingleValue, - BoolValue, - NoValue - } -} diff --git a/src/dotnet-archive/CommandLine/CommandParsingException.cs b/src/dotnet-archive/CommandLine/CommandParsingException.cs deleted file mode 100644 index 82c675f4bb..0000000000 --- a/src/dotnet-archive/CommandLine/CommandParsingException.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using Microsoft.DotNet.Tools; - -namespace Microsoft.DotNet.Cli.CommandLine -{ - internal class CommandParsingException : Exception - { - private readonly bool _isRequiredSubCommandMissing; - - public CommandParsingException( - string message, - string helpText = null) : base(message) - { - HelpText = helpText ?? ""; - Data.Add("CLI_User_Displayed_Exception", true); - } - - public CommandParsingException( - CommandLineApplication command, - string message, - bool isRequiredSubCommandMissing = false) - : this(message) - { - Command = command; - _isRequiredSubCommandMissing = isRequiredSubCommandMissing; - } - - public CommandLineApplication Command { get; } - - public string HelpText { get; } = ""; - - public override string Message - { - get - { - return _isRequiredSubCommandMissing - ? CommonLocalizableStrings.RequiredCommandNotPassed - : base.Message; - } - } - } -} \ No newline at end of file diff --git a/src/dotnet-archive/CommandLine/HelpMessageStrings.cs b/src/dotnet-archive/CommandLine/HelpMessageStrings.cs deleted file mode 100644 index 09551d2e66..0000000000 --- a/src/dotnet-archive/CommandLine/HelpMessageStrings.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace Microsoft.DotNet.Cli.CommandLine -{ - internal class HelpMessageStrings - { - internal const string MSBuildAdditionalArgsHelpText = LocalizableStrings.MSBuildAdditionalArgsHelpText; - } -} diff --git a/src/dotnet-archive/CommandLine/LocalizableStrings.cs b/src/dotnet-archive/CommandLine/LocalizableStrings.cs deleted file mode 100644 index ff01edf1be..0000000000 --- a/src/dotnet-archive/CommandLine/LocalizableStrings.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace Microsoft.DotNet.Cli.CommandLine -{ - internal class LocalizableStrings - { - public const string LastArgumentMultiValueError = "The last argument '{0}' accepts multiple values. No more argument can be added."; - - public const string OptionRequiresSingleValueWhichIsMissing = "Required value for option '{0}' was not provided."; - - public const string UnexpectedValueForOptionError = "Unexpected value '{0}' for option '{1}'"; - - public const string UnexpectedArgumentError = "Unrecognized {0} '{1}'"; - - public const string ResponseFileNotFoundError = "Response file '{0}' doesn't exist."; - - public const string ShowHelpInfo = "Show help information"; - - public const string ShowVersionInfo = "Show version information"; - - public const string ShowHintInfo = "Specify --{0} for a list of available options and commands."; - - public const string UsageHeader = "Usage:"; - - public const string UsageArgumentsToken = " [arguments]"; - - public const string UsageArgumentsHeader = "Arguments:"; - - public const string UsageOptionsToken = " [options]"; - - public const string UsageOptionsHeader = "Options:"; - - public const string UsageCommandToken = " [command]"; - - public const string UsageCommandsHeader = "Commands:"; - - public const string UsageCommandsDetailHelp = "Use \"{0} [command] --help\" for more information about a command."; - - public const string UsageCommandArgs = " [args]"; - - public const string UsageCommandAdditionalArgs = " [[--] ...]]"; - - public const string UsageCommandsAdditionalArgsHeader = "Additional Arguments:"; - - public const string InvalidTemplateError = "Invalid template pattern '{0}'"; - - public const string MSBuildAdditionalArgsHelpText = "Any extra options that should be passed to MSBuild. See 'dotnet msbuild -h' for available options."; - } -} diff --git a/src/dotnet-archive/CommonLocalizableStrings.cs b/src/dotnet-archive/CommonLocalizableStrings.cs deleted file mode 100644 index d19b462d55..0000000000 --- a/src/dotnet-archive/CommonLocalizableStrings.cs +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace Microsoft.DotNet.Tools -{ - internal class CommonLocalizableStrings - { - public const string UnsupportedProjectType = "Unsupported project type. Please check with your sdk provider."; - public const string ProjectAlreadyHasAreference = "Project already has a reference to `{0}`."; - public const string ProjectReferenceCouldNotBeFound = "Project reference `{0}` could not be found."; - public const string ProjectReferenceRemoved = "Project reference `{0}` removed."; - - // Project related - public const string Project = "Project"; - public const string ProjectFile = "Project file"; - public const string Reference = "Reference"; - public const string ProjectReference = "Project reference"; - public const string ProjectReferenceOneOrMore = "Project reference(s)"; - public const string PackageReference = "Package reference"; - public const string P2P = "Project to Project"; - public const string P2PReference = "Project to Project reference"; - public const string Package = "Package"; - public const string Solution = "Solution"; - public const string SolutionFile = "Solution file"; - public const string Executable = "Executable"; - public const string Library = "Library"; - public const string Program = "Program"; - public const string Application = "Application"; - public const string ReferenceAddedToTheProject = "Reference `{0}` added to the project."; - - // Verbs - public const string Add = "Add"; - public const string Remove = "Remove"; - public const string Delete = "Delete"; - public const string Update = "Update"; - public const string New = "New"; - public const string List = "List"; - public const string Load = "Load"; - public const string Save = "Save"; - public const string Find = "Find"; - - // Other - public const string Error = "Error"; - public const string Warning = "Warning"; - - public const string File = "File"; - public const string Directory = "Directory"; - - public const string Type = "Type"; - public const string Value = "Value"; - public const string Group = "Group"; - - // General sentences"; - public const string XAddedToY = "{0} added to {1}."; - public const string XRemovedFromY = "{0} removed from {1}."; - public const string XDeletedFromY = "{0} deleted from {1}."; - public const string XSuccessfullyUpdated = "{0} successfully updated."; - - // General errors - /// Invalid - public const string XIsInvalid = "{0} is invalid."; - public const string XYFoundButInvalid = "{0} `{1}` found but is invalid."; - public const string XFoundButInvalid = "`{0}` found but is invalid."; - public const string OperationInvalid = "Operation is invalid."; - public const string OperationXInvalid = "Operation {0} is invalid."; - - /// Not Found - public const string XNotFound = "{0} not found."; - public const string XOrYNotFound = "{0} or {1} not found."; - public const string XOrYNotFoundInZ = "{0} or {1} not found in `{2}`."; - public const string FileNotFound = "File `{0}` not found."; - - /// Does not exist - public const string XDoesNotExist = "{0} does not exist."; - public const string XYDoesNotExist = "{0} `{1}` does not exist."; - - /// Duplicate - public const string MoreThanOneXFound = "More than one {0} found."; - public const string XAlreadyContainsY = "{0} already contains {1}."; - public const string XAlreadyContainsYZ = "{0} already contains {1} `{2}`."; - public const string XAlreadyHasY = "{0} already has {1}."; - public const string XAlreadyHasYZ = "{0} already has {1} `{2}`."; - - /// Other - public const string XWasNotExpected = "{0} was not expected."; - public const string XNotProvided = "{0} not provided."; - public const string SpecifyAtLeastOne = "Please specify at least one {0}."; - public const string CouldNotConnectWithTheServer = "Could not connect with the server."; - - // Command Line Parsing - public const string RequiredArgumentIsInvalid = "Required argument {0} is invalid."; - public const string OptionIsInvalid = "Option {0} is invalid."; - public const string ArgumentIsInvalid = "Argument {0} is invalid."; - public const string RequiredArgumentNotPassed = "Required argument {0} was not provided."; - public const string RequiredCommandNotPassed = "Required command was not provided."; - - // dotnet - /// Project - public const string CouldNotFindAnyProjectInDirectory = "Could not find any project in `{0}`."; - public const string CouldNotFindProjectOrDirectory = "Could not find project or directory `{0}`."; - public const string MoreThanOneProjectInDirectory = "Found more than one project in `{0}`. Please specify which one to use."; - public const string FoundInvalidProject = "Found a project `{0}` but it is invalid."; - public const string InvalidProject = "Invalid project `{0}`."; - - /// Solution - public const string CouldNotFindSolutionIn = "Specified solution file {0} does not exist, or there is no solution file in the directory."; - public const string CouldNotFindSolutionOrDirectory = "Could not find solution or directory `{0}`."; - public const string MoreThanOneSolutionInDirectory = "Found more than one solution file in {0}. Please specify which one to use."; - public const string InvalidSolutionFormatString = "Invalid solution `{0}`. {1}"; // {0} is the solution path, {1} is already localized details on the failure - public const string SolutionDoesNotExist = "Specified solution file {0} does not exist, or there is no solution file in the directory."; - - /// add p2p - public const string ReferenceDoesNotExist = "Reference {0} does not exist."; - public const string ReferenceIsInvalid = "Reference `{0}` is invalid."; - public const string SpecifyAtLeastOneReferenceToAdd = "You must specify at least one reference to add."; - public const string ProjectAlreadyHasAReference = "Project {0} already has a reference `{1}`."; - - /// add package - public const string PackageReferenceDoesNotExist = "Package reference `{0}` does not exist."; - public const string PackageReferenceIsInvalid = "Package reference `{0}` is invalid."; - public const string SpecifyAtLeastOnePackageReferenceToAdd = "You must specify at least one package to add."; - public const string PackageReferenceAddedToTheProject = "Package reference `{0}` added to the project."; - public const string ProjectAlreadyHasAPackageReference = "Project {0} already has a reference `{1}`."; - public const string PleaseSpecifyVersion = "Please specify a version of the package."; - - /// add sln - public const string ProjectDoesNotExist = "Project `{0}` does not exist."; - public const string ProjectIsInvalid = "Project `{0}` is invalid."; - public const string SpecifyAtLeastOneProjectToAdd = "You must specify at least one project to add."; - public const string ProjectAddedToTheSolution = "Project `{0}` added to the solution."; - public const string SolutionAlreadyContainsProject = "Solution {0} already contains project {1}."; - - /// del p2p - public const string ReferenceNotFoundInTheProject = "Specified reference {0} does not exist in project {1}."; - public const string ReferenceRemoved = "Reference `{0}` deleted from the project."; - public const string SpecifyAtLeastOneReferenceToRemove = "You must specify at least one reference to remove."; - public const string ReferenceDeleted = "Reference `{0}` deleted."; - - /// del pkg - public const string PackageReferenceNotFoundInTheProject = "Package reference `{0}` could not be found in the project."; - public const string PackageReferenceRemoved = "Reference `{0}` deleted from the project."; - public const string SpecifyAtLeastOnePackageReferenceToRemove = "You must specify at least one package reference to remove."; - public const string PackageReferenceDeleted = "Package reference `{0}` deleted."; - - /// del sln - public const string ProjectNotFoundInTheSolution = "Project `{0}` could not be found in the solution."; - public const string ProjectRemoved = "Project `{0}` removed from solution."; - public const string SpecifyAtLeastOneProjectToRemove = "You must specify at least one project to remove."; - public const string ProjectDeleted = "Project `{0}` deleted from solution."; - - /// list - public const string NoReferencesFound = "There are no {0} references in project {1}. ;; {0} is the type of the item being requested (project, package, p2p) and {1} is the object operated on (a project file or a solution file). "; - public const string NoProjectsFound = "No projects found in the solution."; - - /// arguments - public const string ArgumentsProjectOrSolutionDescription = "The project or solution to operation on. If a file is not specified, the current directory is searched."; - - /// sln - public const string ArgumentsProjectDescription = "The project file to operate on. If a file is not specified, the command will search the current directory for one."; - public const string ArgumentsSolutionDescription = "Solution file to operate on. If not specified, the command will search the current directory for one."; - public const string CmdSlnFile = "SLN_FILE"; - public const string CmdProjectFile = "PROJECT"; - - /// commands - public const string CmdFramework = "FRAMEWORK"; - - /// update pkg - public const string PleaseSpecifyNewVersion = "Please specify new version of the package."; - public const string PleaseSpecifyWhichPackageToUpdate = "Please specify which package to update."; - public const string NothingToUpdate = "Nothing to update."; - public const string EverythingUpToDate = "Everything is already up-to-date."; - public const string PackageVersionUpdatedTo = "Version of package `{0}` updated to `{1}`."; - public const string PackageVersionUpdated = "Version of package `{0}` updated."; - public const string CouldNotUpdateTheVersion = "Could not update the version of the package `{0}`."; - - /// new - public const string TemplateCreatedSuccessfully = "The template {0} created successfully. Please run \"dotnet restore\" to get started!"; - public const string TemplateInstalledSuccesfully = "The template {0} installed successfully. You can use \"dotnet new {0}\" to get started with the new template."; - public const string TemplateCreateError = "Template {0} could not be created. Error returned was: {1}."; - public const string TemplateInstallError = "Template {0} could not be installed. Error returned was: {1}."; - public const string SpecifiedNameExists = "Specified name {0} already exists. Please specify a different name."; - public const string SpecifiedAliasExists = "Specified alias {0} already exists. Please specify a different alias."; - public const string MandatoryParameterMissing = "Mandatory parameter {0} missing for template {1}. "; - - public const string ProjectNotCompatibleWithFrameworks = "Project `{0}` cannot be added due to incompatible targeted frameworks between the two projects. Please review the project you are trying to add and verify that is compatible with the following targets:"; - public const string ProjectDoesNotTargetFramework = "Project `{0}` does not target framework `{1}`."; - public const string ProjectCouldNotBeEvaluated = "Project `{0}` could not be evaluated. Evaluation failed with following error:\n{1}"; - } -} diff --git a/src/dotnet-archive/Program.cs b/src/dotnet-archive/Program.cs deleted file mode 100644 index c73f5f41af..0000000000 --- a/src/dotnet-archive/Program.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.DotNet.Cli.CommandLine; -//using Microsoft.DotNet.Cli.Utils; -using Microsoft.DotNet.Archive; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; - -namespace Microsoft.DotNet.Tools.Archive -{ - - public partial class ArchiveCommand - { - public static int Main(string[] args) - { - //DebugHelper.HandleDebugSwitch(ref args); - - var app = new CommandLineApplication(); - app.Name = "archive"; - app.FullName = ".NET archiver"; - app.Description = "Archives and expands sets of files"; - app.HelpOption("-h|--help"); - - var extract = app.Option("-x|--extract ", "Directory to extract to", CommandOptionType.SingleValue); - var archiveFile = app.Option("-a|--archive ", "Archive to operate on", CommandOptionType.SingleValue); - var externals = app.Option("--external ...", "External files and directories to consider for extraction", CommandOptionType.MultipleValue); - var sources = app.Argument("...", "Files & directory to include in the archive", multipleValues: true); - - app.OnExecute(() => - { - - if (extract.HasValue() && sources.Values.Any()) - { - Console.WriteLine("Extract '-x' can only be specified when no '' are specified to add to the archive."); - return 1; - } - else if (!extract.HasValue() && !sources.Values.Any()) - { - Console.WriteLine("Either extract '-x' or '' must be specified."); - return 1; - } - - if (!archiveFile.HasValue()) - { - Console.WriteLine("Archive '-a' must be specified."); - return 1; - } - - var progress = new ConsoleProgressReport(); - - var archive = new IndexedArchive(); - foreach (var external in externals.Values) - { - if (Directory.Exists(external)) - { - archive.AddExternalDirectory(external); - } - else - { - archive.AddExternalFile(external); - } - } - - if (sources.Values.Any()) - { - foreach (var source in sources.Values) - { - if (Directory.Exists(source)) - { - archive.AddDirectory(source, progress); - } - else - { - archive.AddFile(source, Path.GetFileName(source)); - } - } - - archive.Save(archiveFile.Value(), progress); - } - else // sources not specified, extract must have been specified - { - archive.Extract(archiveFile.Value(), extract.Value(), progress); - - } - - return 0; - }); - - return app.Execute(args); - } - } -} diff --git a/src/dotnet-archive/dotnet-archive.csproj b/src/dotnet-archive/dotnet-archive.csproj deleted file mode 100644 index 3d41a55f58..0000000000 --- a/src/dotnet-archive/dotnet-archive.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - netcoreapp2.0 - Exe - false - win7-x64;linux-x64 - - - - - - - From 05f6f9d656805b41f6eb14544c30d35150eaf9bc Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Fri, 23 Jun 2017 16:40:07 -0700 Subject: [PATCH 194/361] React to Testing#280. --- .../HttpClientSlim.cs | 130 ------------------ 1 file changed, 130 deletions(-) delete mode 100644 test/Microsoft.AspNetCore.FunctionalTests/HttpClientSlim.cs diff --git a/test/Microsoft.AspNetCore.FunctionalTests/HttpClientSlim.cs b/test/Microsoft.AspNetCore.FunctionalTests/HttpClientSlim.cs deleted file mode 100644 index a85b03aa40..0000000000 --- a/test/Microsoft.AspNetCore.FunctionalTests/HttpClientSlim.cs +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Security; -using System.Net.Sockets; -using System.Security.Authentication; -using System.Text; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Testing -{ - // Lightweight version of HttpClient implemented using Socket and SslStream - public static class HttpClientSlim - { - public static async Task GetStringAsync(string requestUri, bool validateCertificate = true) - => await GetStringAsync(new Uri(requestUri), validateCertificate).ConfigureAwait(false); - - public static async Task GetStringAsync(Uri requestUri, bool validateCertificate = true) - { - using (var stream = await GetStream(requestUri, validateCertificate).ConfigureAwait(false)) - { - using (var writer = new StreamWriter(stream, Encoding.ASCII, bufferSize: 1024, leaveOpen: true)) - { - await writer.WriteAsync($"GET {requestUri.PathAndQuery} HTTP/1.0\r\n").ConfigureAwait(false); - await writer.WriteAsync($"Host: {requestUri.Authority}\r\n").ConfigureAwait(false); - await writer.WriteAsync("\r\n").ConfigureAwait(false); - } - - return await ReadResponse(stream).ConfigureAwait(false); - } - } - - public static async Task PostAsync(string requestUri, HttpContent content, bool validateCertificate = true) - => await PostAsync(new Uri(requestUri), content, validateCertificate).ConfigureAwait(false); - - public static async Task PostAsync(Uri requestUri, HttpContent content, bool validateCertificate = true) - { - using (var stream = await GetStream(requestUri, validateCertificate)) - { - using (var writer = new StreamWriter(stream, Encoding.ASCII, bufferSize: 1024, leaveOpen: true)) - { - await writer.WriteAsync($"POST {requestUri.PathAndQuery} HTTP/1.0\r\n").ConfigureAwait(false); - await writer.WriteAsync($"Host: {requestUri.Authority}\r\n").ConfigureAwait(false); - await writer.WriteAsync($"Content-Type: {content.Headers.ContentType}\r\n").ConfigureAwait(false); - await writer.WriteAsync($"Content-Length: {content.Headers.ContentLength}\r\n").ConfigureAwait(false); - await writer.WriteAsync("\r\n").ConfigureAwait(false); - } - - await content.CopyToAsync(stream).ConfigureAwait(false); - - return await ReadResponse(stream).ConfigureAwait(false); - } - } - - private static async Task ReadResponse(Stream stream) - { - using (var reader = new StreamReader(stream, Encoding.ASCII, detectEncodingFromByteOrderMarks: true, - bufferSize: 1024, leaveOpen: true)) - { - var response = await reader.ReadToEndAsync().ConfigureAwait(false); - - var status = GetStatus(response); - new HttpResponseMessage(status).EnsureSuccessStatusCode(); - - var body = response.Substring(response.IndexOf("\r\n\r\n") + 4); - return body; - } - - } - - private static HttpStatusCode GetStatus(string response) - { - var statusStart = response.IndexOf(' ') + 1; - var statusEnd = response.IndexOf(' ', statusStart) - 1; - var statusLength = statusEnd - statusStart + 1; - return (HttpStatusCode)int.Parse(response.Substring(statusStart, statusLength)); - } - - private static async Task GetStream(Uri requestUri, bool validateCertificate) - { - var socket = await GetSocket(requestUri); - var stream = new NetworkStream(socket, ownsSocket: true); - - if (requestUri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) - { - var sslStream = new SslStream(stream, leaveInnerStreamOpen: false, userCertificateValidationCallback: - validateCertificate ? null : (RemoteCertificateValidationCallback)((a, b, c, d) => true)); - - await sslStream.AuthenticateAsClientAsync(requestUri.Host, clientCertificates: null, - enabledSslProtocols: SslProtocols.Tls11 | SslProtocols.Tls12, - checkCertificateRevocation: validateCertificate).ConfigureAwait(false); - return sslStream; - } - else - { - return stream; - } - } - - public static async Task GetSocket(Uri requestUri) - { - var tcs = new TaskCompletionSource(); - - var socketArgs = new SocketAsyncEventArgs(); - socketArgs.RemoteEndPoint = new DnsEndPoint(requestUri.DnsSafeHost, requestUri.Port); - socketArgs.Completed += (s, e) => tcs.TrySetResult(e.ConnectSocket); - - // Must use static ConnectAsync(), since instance Connect() does not support DNS names on OSX/Linux. - if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, socketArgs)) - { - await tcs.Task.ConfigureAwait(false); - } - - var socket = socketArgs.ConnectSocket; - - if (socket == null) - { - throw new SocketException((int)socketArgs.SocketError); - } - else - { - return socket; - } - } - } -} From 6f762fe478e01a05c7f508de64f3be8eadfb2c7d Mon Sep 17 00:00:00 2001 From: = Date: Fri, 23 Jun 2017 17:18:08 -0700 Subject: [PATCH 195/361] Update RPM installation directory --- build/repo.targets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index d6c44d2375..f95f730550 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -368,8 +368,8 @@ - - + + @@ -384,7 +384,7 @@ Apache-2.0 1 https://www.asp.net/ - /usr/share/dotnet + /opt/rh/rh-dotnet20/root/usr/lib64/dotnet @@ -440,7 +440,7 @@ --license "$(InstallerLicense)" --iteration $(InstallerPackageRevision) --url "$(InstallerHomepage)" - $(DockerRootDirectory)artifacts/inLayout/package_root/=$(InstallerInstallRoot)" /> + $(DockerRootDirectory)artifacts/inLayout/package_root/="$(InstallerInstallRoot)"" /> From 7b2825a40bb7931d320275fe6d9a6b3da6fe5e53 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 26 Jun 2017 09:39:18 -0700 Subject: [PATCH 196/361] Adding libunwind8 to .travis.yml [skip appveyor] --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 27c93bcd6f..6c59666f3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ os: - linux - osx osx_image: xcode8.2 +addons: + apt: + packages: + - libunwind8 branches: only: - master From 584b36318ea98c8b7d59e69229369a184d078946 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 26 Jun 2017 19:07:36 -0700 Subject: [PATCH 197/361] Workaround issue caused by importing Internal.AspNetCore.Sdk into KoreBuild (#178) --- build/repo.targets | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/repo.targets b/build/repo.targets index b1c6ee764e..eb36e6580a 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -1,6 +1,11 @@ + + + + + $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ From a408be3eb578eb5b2ea66324c8d98a185ca487c4 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 27 Jun 2017 12:39:11 -0700 Subject: [PATCH 198/361] Remove NetStandard.Library.NETFramework --- build/common.props | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build/common.props b/build/common.props index c54c649a59..7d60736fd9 100644 --- a/build/common.props +++ b/build/common.props @@ -21,10 +21,6 @@ - - - - From f3ed8129f33d79c9b6175703f668efe112657abf Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 28 Jun 2017 10:21:55 -0700 Subject: [PATCH 199/361] Ensure Microsoft.AspNetCore.All is only compatible with netcoreapp2.0 (#180) --- src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 1 + src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ | 0 2 files changed, 1 insertion(+) create mode 100644 src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index b3fc5e5d5d..a0eee67264 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -20,6 +20,7 @@ + diff --git a/src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ b/src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ new file mode 100644 index 0000000000..e69de29bb2 From 812495f32d8ee7dc58a97a6f626c11b5ed3481ce Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 28 Jun 2017 15:02:42 -0700 Subject: [PATCH 200/361] Remove SQLitePCLRaw workaround --- build/common.props | 5 ----- build/dependencies.props | 1 - 2 files changed, 6 deletions(-) diff --git a/build/common.props b/build/common.props index 7d60736fd9..261ff87677 100644 --- a/build/common.props +++ b/build/common.props @@ -147,11 +147,6 @@ - - - - - diff --git a/build/dependencies.props b/build/dependencies.props index 276b624d11..51062901bd 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -9,7 +9,6 @@ 2.0.0-* 10.0.1 2.0.0-* - 1.1.3 15.3.0-* 2.3.0-beta2-* From 9b0943efdde1c0753a623c1f61cb769c7d8acc68 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 29 Jun 2017 08:35:47 -0700 Subject: [PATCH 201/361] Update dependencies.props * Update Moq to 4.7.49. * Add NETStandardImplicitPackageVersion --- build/dependencies.props | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 51062901bd..c1023b8a5e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,11 +1,12 @@ - + 0.4.0-* 2.0.0-* 4.4.0-* 2.0.0-preview2-* 2.1.0-* - 4.7.1 + 4.7.49 + 2.0.0-* 2.0.0-* 10.0.1 2.0.0-* From b1ddd62f45e85f1dd3ff2690b7d57bce8878fe82 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 28 Jun 2017 16:51:07 -0700 Subject: [PATCH 202/361] Remove NETStandard.Library.NETFramework and update Moq --- samples/SampleApp/SampleApp.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index db4fc54254..620cf71def 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -15,8 +15,4 @@ - - - - From cb246ae45b25a73c53ea5e19162669d00ecac407 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 23 Jun 2017 12:25:11 -0700 Subject: [PATCH 203/361] Use specified signed runtime store archives when available for installers --- build/repo.targets | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index eb36e6580a..13930d99c6 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -322,11 +322,17 @@ - + + + + + $(RUNTIMESTORE_SIGNED_ARTIFACTS_PATH) + $(RuntimeStoreArchiveDirectory) + - - + + From d7533529f93737bbbdf869247e577cf4442d06cf Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 29 Jun 2017 12:39:48 -0700 Subject: [PATCH 204/361] Fix restore warnings for Microsoft.NETCore.App --- .../CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj | 2 ++ .../DependencyInjectionApp/DependencyInjectionApp.csproj | 2 ++ .../StartRequestDelegateUrlApp.csproj | 2 ++ .../StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj | 2 ++ .../StartWithIApplicationBuilderUrlApp.csproj | 2 ++ 5 files changed, 10 insertions(+) diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj index 0956c47f07..65c45e2363 100644 --- a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj +++ b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj @@ -1,5 +1,7 @@  + + Exe netcoreapp2.0 diff --git a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj index 04691e82ed..2124775352 100644 --- a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj +++ b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj @@ -1,5 +1,7 @@  + + Exe netcoreapp2.0 diff --git a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj index 0c089dbc33..d960839e9f 100644 --- a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj +++ b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj @@ -1,5 +1,7 @@  + + Exe netcoreapp2.0 diff --git a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj index 0c089dbc33..d960839e9f 100644 --- a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj +++ b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj @@ -1,5 +1,7 @@  + + Exe netcoreapp2.0 diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj index 0c089dbc33..d960839e9f 100644 --- a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj +++ b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj @@ -1,5 +1,7 @@  + + Exe netcoreapp2.0 From 64ed5bb4fff1fb055e49478f8c7bbe538f4ca660 Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 23 Jun 2017 17:59:26 -0700 Subject: [PATCH 205/361] Use new SelfContained property --- .../build/PublishWithAspNetCoreTargetManifest.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets index f49dc6ad79..a590cf01f1 100644 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets @@ -1,6 +1,6 @@ - true + true - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + + @(_InstallerSummary) + @(_InstallerDescription) + @(_InstallerLicense) + @(_InstallerPackageRevision) + @(_InstallerHomepage) + @(_InstallerMaintainerName) + @(_InstallerMaintainerEmail) + @(_InstallerChangelogMessage) + + + + + + + @@ -378,17 +430,12 @@ + $(RuntimeStoreTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm $(RuntimeStoreNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm @(RPMDirectories->' --directories "%(FullPath)"', ' ') - Microsoft ASP.NET Core Runtime Package Store 2.0.0 - Preview 2 - Runtime package store for Microsoft ASP.NET Core. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs. - Microsoft - nugetaspnet@microsoft.com + $(InstallerMaintainerName) <$(InstallerMaintainerEmail)> .NET Foundation - Apache-2.0 - 1 - https://www.asp.net/ /opt/rh/rh-dotnet20/root/usr/lib64/dotnet @@ -416,14 +463,14 @@ $(RPMDirectoriesArguments) --rpm-changelog $(DockerRootDirectory)artifacts/itLayout/templates/changelog --rpm-summary "$(InstallerSummary)" - --description "$(InstalerDescription)" - --maintainer "$(InstallerMaintainerName) <$(InstallerMaintainerEmail)>" + --description "$(InstallerDescription)" + --maintainer "$(InstallerMaintainer)" --vendor "$(InstallerVendor)" -p $(DockerRootDirectory)artifacts/itOutput/$(RuntimeStoreTimestampRPMFileName) --license "$(InstallerLicense)" --iteration $(InstallerPackageRevision) --url "$(InstallerHomepage)" - $(DockerRootDirectory)artifacts/itLayout/package_root/=$(InstallerInstallRoot)" /> + $(DockerRootDirectory)artifacts/itLayout/package_root/="$(InstallerInstallRoot)"" /> Date: Thu, 29 Jun 2017 16:57:02 -0700 Subject: [PATCH 207/361] Remove AssetTargetFallback --- src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj | 1 - src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj index a3e6e316d6..607ed3c861 100644 --- a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj +++ b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj @@ -4,7 +4,6 @@ netcoreapp2.0 - $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false netcoreapp2.0 diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index a0eee67264..b97348f7db 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -8,7 +8,6 @@ aspnetcore Microsoft.AspNetCore.All false - $(AssetTargetFallback);portable-net45+win8+wp8+wpa81 From 7162fe2371a26c6e038f39c4c972a9830304909f Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 30 Jun 2017 16:34:40 -0700 Subject: [PATCH 208/361] Clarify installer error message --- build/repo.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 0d9b993068..2f1445bea8 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -335,8 +335,8 @@ - - + + From 368883b39b31364af0d1704935f56e49aede8967 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 3 Jul 2017 14:06:54 -0700 Subject: [PATCH 209/361] Update LICENSE.txt text --- LICENSE.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 0bdc1962b6..7b2956ecee 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,10 +1,12 @@ -Copyright (c) .NET Foundation. All rights reserved. +Copyright (c) .NET Foundation and Contributors + +All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the +this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR From bb1d80be2af8230834040aa3e2828a89d74a2919 Mon Sep 17 00:00:00 2001 From: John Luo Date: Sun, 2 Jul 2017 04:44:10 -0700 Subject: [PATCH 210/361] Create common manifest file This will trim additional packages such as runtime.win-arm64.runtime.native.system.data.sqlclient.sni --- build/repo.targets | 20 +++++- build/tasks/CreateCommonManifest.cs | 67 +++++++++++++++++++ build/tasks/RepoTasks.csproj | 9 +++ build/tasks/RepoTasks.tasks | 3 + .../Build.RuntimeStore.References.csproj | 11 ++- 5 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 build/tasks/CreateCommonManifest.cs create mode 100644 build/tasks/RepoTasks.csproj create mode 100644 build/tasks/RepoTasks.tasks diff --git a/build/repo.targets b/build/repo.targets index 2f1445bea8..d9d83f6045 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -175,8 +175,24 @@ - - + + + + + + + aspnetcore-store-$(TimestampVersion)-common.xml + + + + + + + + + + + diff --git a/build/tasks/CreateCommonManifest.cs b/build/tasks/CreateCommonManifest.cs new file mode 100644 index 0000000000..4125bbccae --- /dev/null +++ b/build/tasks/CreateCommonManifest.cs @@ -0,0 +1,67 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Xml; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace RepoTasks +{ + /// + /// Creates a common manifest file used for trimming publish output given a list of packages and package definitions containing their versions. + /// + public class CreateCommonManifest : Task + { + /// + /// The path for the common manifest file to be created. + /// + /// + [Required] + public string DestinationFilePath { get; set; } + + /// + /// The packages to include in the common manifest file. + /// + /// + [Required] + public ITaskItem[] Packages { get; set; } + + /// + /// The package definitions used for resolving package versions. + /// + /// + [Required] + public ITaskItem[] PackageDefinitions { get; set; } + + public override bool Execute() + { + var xmlDoc = new XmlDocument(); + var packagesElement = xmlDoc.CreateElement("StoreArtifacts"); + + foreach (var package in Packages) + { + var packageName = package.ItemSpec; + var packageElement = xmlDoc.CreateElement("Package"); + + var idAttribute = xmlDoc.CreateAttribute("Id"); + idAttribute.Value = packageName; + packageElement.Attributes.Append(idAttribute); + + var versionAttribute = xmlDoc.CreateAttribute("Version"); + versionAttribute.Value = PackageDefinitions + .Where(p => string.Equals(p.GetMetadata("Name"), packageName, StringComparison.OrdinalIgnoreCase)) + .Select(p => p.GetMetadata("Version")).Single(); + packageElement.Attributes.Append(versionAttribute); + + packagesElement.AppendChild(packageElement); + } + + xmlDoc.AppendChild(packagesElement); + xmlDoc.Save(DestinationFilePath); + + return true; + } + } +} diff --git a/build/tasks/RepoTasks.csproj b/build/tasks/RepoTasks.csproj new file mode 100644 index 0000000000..f18ec7a1ff --- /dev/null +++ b/build/tasks/RepoTasks.csproj @@ -0,0 +1,9 @@ + + + + + netcoreapp2.0 + + + + diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks new file mode 100644 index 0000000000..5de9828888 --- /dev/null +++ b/build/tasks/RepoTasks.tasks @@ -0,0 +1,3 @@ + + + diff --git a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj index 4a3a2eaaec..cb2a84480e 100644 --- a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj +++ b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj @@ -1,5 +1,7 @@  + + @@ -8,6 +10,13 @@ - + + + + + + + + From 78e57397a06a0b540fa8c356efb639ad06df1fc3 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 6 Jul 2017 10:38:25 -0700 Subject: [PATCH 211/361] React to aspnet/BuildTools#293 [ci skip] --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index c1023b8a5e..518d7acf5c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 2.0.0-* 4.4.0-* 2.0.0-preview2-* - 2.1.0-* + 2.0.1-* 4.7.49 2.0.0-* 2.0.0-* From 49869df2f82aa809c8f9e77d6fad3fc944eca6c7 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 6 Jul 2017 12:19:56 -0700 Subject: [PATCH 212/361] Set "TreatWarningsAsErrors" before NuGet restore * Ensures our build stays clean of NuGet warnings --- build/common.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.props b/build/common.props index 261ff87677..ffa2e90528 100644 --- a/build/common.props +++ b/build/common.props @@ -12,6 +12,7 @@ true $(VersionSuffix) $(VersionSuffix)-$(BuildNumber) + true 2.0.0-$(VersionSuffix) From 3bbf3c69328c67ec39de3ba6edf1b65d6c544479 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 6 Jul 2017 15:08:34 -0700 Subject: [PATCH 213/361] Update version suffix for 2.0.0 RTM release --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 193a5999d8..eba6b16756 100644 --- a/version.props +++ b/version.props @@ -2,6 +2,6 @@ 2.0.0 - preview3 + rtm From 19f814b7c5d7fccc77d73040130a0f860ddadb33 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:44:23 -0700 Subject: [PATCH 214/361] Branching for 2.0.0 rtm --- NuGet.config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NuGet.config b/NuGet.config index 8a937d9f50..37f0d27ea0 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,9 +2,8 @@ - + - From 791219f8898fcabd7c1cd599e76fe6a2802f9c35 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 10 Jul 2017 11:57:59 -0700 Subject: [PATCH 215/361] Updating KoreBuild branch --- build.ps1 | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..1785334385 100644 --- a/build.ps1 +++ b/build.ps1 @@ -33,7 +33,7 @@ cd $PSScriptRoot $repoFolder = $PSScriptRoot $env:REPO_FOLDER = $repoFolder -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if ($env:KOREBUILD_ZIP) { $koreBuildZip=$env:KOREBUILD_ZIP diff --git a/build.sh b/build.sh index b0bcadb579..5e27ed8efb 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" +koreBuildZip="https://github.com/aspnet/KoreBuild/archive/rel/2.0.0.zip" if [ ! -z $KOREBUILD_ZIP ]; then koreBuildZip=$KOREBUILD_ZIP fi From bd97bf08645091e3a57005cf6820c4eb88ecc68a Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 7 Jul 2017 14:56:42 -0700 Subject: [PATCH 216/361] Skip first time experience on Appveyor --- appveyor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 04dfabcb0b..4f85bae466 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true branches: only: @@ -10,6 +10,10 @@ branches: build_script: - ps: .\build.ps1 clone_depth: 1 +environment: + global: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 test: off deploy: off os: Visual Studio 2017 From 1d2b560dfac124a36bf8e80ed78eb26da0b9a988 Mon Sep 17 00:00:00 2001 From: John Luo Date: Tue, 11 Jul 2017 15:40:50 -0700 Subject: [PATCH 217/361] Update no-timestamp versions --- build/repo.targets | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index d9d83f6045..1b6267d0da 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -23,6 +23,7 @@ final $(VersionPrefix)-$(OriginalVersionSuffix)-$(NoTimestampSuffix) + $(VersionPrefix) $(VersionPrefix)-$(OriginalVersionSuffix)-$(BuildNumber) aspnetcore-store-$(TimestampVersion) @@ -132,11 +133,11 @@ <_RuntimeStoreFiles Include="$(RuntimeStoreOutputPath)**\*" Exclude="$(RuntimeStoreOutputPath)**\artifact.xml;$(RuntimeStoreOutputPath)symbols\**\*" /> - $([System.String]::new('%(RecursiveDir)').Replace('-$(BuildNumber)', '-final')) + $([System.String]::new('%(RecursiveDir)').Replace('$(TimestampVersion)', '$(NoTimestampVersion)')) <_RuntimeStoreSymbolFiles Include="$(RuntimeStoreOutputPath)symbols\**\*" /> - $([System.String]::new('%(RecursiveDir)').Replace('-$(BuildNumber)', '-final')) + $([System.String]::new('%(RecursiveDir)').Replace('$(TimestampVersion)', '$(NoTimestampVersion)')) @@ -241,9 +242,9 @@ - - - + + + From 80d8e8a7cdf5f3e7e6bd492ee20a1da0bc6f4bae Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 13 Jul 2017 12:15:53 -0700 Subject: [PATCH 218/361] Adding RuntimeFrameworkVersion to the RepoTasks.csproj --- build/tasks/RepoTasks.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/build/tasks/RepoTasks.csproj b/build/tasks/RepoTasks.csproj index f18ec7a1ff..8457d61d39 100644 --- a/build/tasks/RepoTasks.csproj +++ b/build/tasks/RepoTasks.csproj @@ -3,6 +3,7 @@ netcoreapp2.0 + 2.0.0-* From 459f453cd41043f7612a5495e7e811673d6b45fa Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 14 Jul 2017 19:10:58 -0700 Subject: [PATCH 219/361] Pin runtime version for generated deps files --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index 518d7acf5c..00425fd6f5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,6 +3,7 @@ 0.4.0-* 2.0.0-* 4.4.0-* + 2.0.0-preview3-25514-02 2.0.0-preview2-* 2.0.1-* 4.7.49 From 8dfc6a00e5c7aee744bae9ff36502f98a14b5278 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 17 Jul 2017 13:58:49 -0700 Subject: [PATCH 220/361] Use installed shared framework version during deps file generation instead of the shared framework version bundled with the SDK --- build/dependencies.props | 1 - build/repo.targets | 9 ++++++--- tools/GetSharedFrameworkVersion.sh | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100755 tools/GetSharedFrameworkVersion.sh diff --git a/build/dependencies.props b/build/dependencies.props index 00425fd6f5..518d7acf5c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,7 +3,6 @@ 0.4.0-* 2.0.0-* 4.4.0-* - 2.0.0-preview3-25514-02 2.0.0-preview2-* 2.0.1-* 4.7.49 diff --git a/build/repo.targets b/build/repo.targets index 1b6267d0da..d9f6d219b1 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -75,7 +75,7 @@ Condition="Exists('$(DependencyBuildDirectory)')" /> - + @@ -125,7 +125,7 @@ - + @@ -205,7 +205,10 @@ - + + + + diff --git a/tools/GetSharedFrameworkVersion.sh b/tools/GetSharedFrameworkVersion.sh new file mode 100755 index 0000000000..1b6e0b4bb0 --- /dev/null +++ b/tools/GetSharedFrameworkVersion.sh @@ -0,0 +1,2 @@ +#!/bin/bash +dotnet --info | grep -i version | tail -1 | cut -f 2 -d ":" | tr -d ' ' \ No newline at end of file From dfd63fe2cbf1130bfa493d0a66b0769bd0b57529 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Wed, 19 Jul 2017 09:38:50 -0700 Subject: [PATCH 221/361] Rename property to JsonNetVersion (#197) - Matches other repos --- build/dependencies.props | 2 +- tools/TrimDeps/TrimDeps.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 518d7acf5c..3b0f7e6cff 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,10 +5,10 @@ 4.4.0-* 2.0.0-preview2-* 2.0.1-* + 10.0.1 4.7.49 2.0.0-* 2.0.0-* - 10.0.1 2.0.0-* 15.3.0-* 2.3.0-beta2-* diff --git a/tools/TrimDeps/TrimDeps.csproj b/tools/TrimDeps/TrimDeps.csproj index 2c7bcd5e41..4ae54603b3 100644 --- a/tools/TrimDeps/TrimDeps.csproj +++ b/tools/TrimDeps/TrimDeps.csproj @@ -9,7 +9,7 @@ - + From 819ee5faafc5c6c258d683bbb9bed6aebcfb717a Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 19 Jul 2017 12:01:23 -0700 Subject: [PATCH 222/361] Add M.Dotnet.Watcher.Tools and M.E.Caching.SqlConfig.Tools to lzma --- src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj index 607ed3c861..3d1b205678 100644 --- a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj +++ b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj @@ -16,7 +16,9 @@ + + From 5a0847338ffe2651377a8ff197498030207ecc2e Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 21 Jul 2017 13:00:54 -0700 Subject: [PATCH 223/361] 2.0.0-rtm to 2.1.0-preview1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index eba6b16756..1ea46af42a 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.0.0 - rtm + 2.1.0 + preview1 From 0e38a9fdd89418e0b462dcf86f836edab97f1fac Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 24 Jul 2017 13:50:55 -0700 Subject: [PATCH 224/361] Fix VersionPrefix --- build/common.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/common.props b/build/common.props index ffa2e90528..6475bd27ed 100644 --- a/build/common.props +++ b/build/common.props @@ -15,7 +15,7 @@ true - 2.0.0-$(VersionSuffix) + $(VersionPrefix)-$(VersionSuffix) From 5ee18f0eccc0232e5838e999f9ecb3a6a40edee0 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 24 Jul 2017 17:57:23 -0700 Subject: [PATCH 225/361] Set AspNetCoreVersion --- build/dependencies.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3b0f7e6cff..254e315ac1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,7 @@ - + 0.4.0-* - 2.0.0-* + 2.1.0-* 4.4.0-* 2.0.0-preview2-* 2.0.1-* From 60a6281b92d70e951105449d2ea31bb91039810d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 25 Jul 2017 15:14:01 -0700 Subject: [PATCH 226/361] Updating to InternalAspNetCoreSdkVersion 2.1.1-* --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 254e315ac1..1dedc92dbb 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,7 +4,7 @@ 2.1.0-* 4.4.0-* 2.0.0-preview2-* - 2.0.1-* + 2.1.1-* 10.0.1 4.7.49 2.0.0-* From 6a129bd67d469e0d674d4d0a74d7e72d3919aa0b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 25 Jul 2017 16:33:23 -0700 Subject: [PATCH 227/361] Update bootstrappers to use the compiled version of KoreBuild [ci skip] --- .gitignore | 1 + MetaPackages.sln | 2 +- build.cmd | 2 +- build.ps1 | 218 +++++++++++++++++++++++++--------- build.sh | 224 +++++++++++++++++++++++++++++------ build/common.props | 2 +- version.props => version.xml | 3 +- 7 files changed, 357 insertions(+), 95 deletions(-) rename version.props => version.xml (55%) diff --git a/.gitignore b/.gitignore index 3af0091ea3..e8cd589251 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ global.json .deps/ .rw/ .ro/ +korebuild-lock.txt diff --git a/MetaPackages.sln b/MetaPackages.sln index ba7c6ada0a..b7897ad663 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -11,7 +11,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97D53BEB-A511-4FBE-B784-AB407D9A219F}" ProjectSection(SolutionItems) = preProject NuGet.config = NuGet.config - version.props = version.props + version.xml = version.xml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1-C38E-408C-A7EC-A5C040D041E1}" diff --git a/build.cmd b/build.cmd index 7d4894cb4a..b6c8d24864 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" \ No newline at end of file +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/build.ps1 index 5bf0e2c113..d5eb4d5cf2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,67 +1,177 @@ -$ErrorActionPreference = "Stop" +#!/usr/bin/env powershell +#requires -version 4 -function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries) -{ - while($true) - { - try - { - Invoke-WebRequest $url -OutFile $downloadLocation - break - } - catch - { - $exceptionMessage = $_.Exception.Message - Write-Host "Failed to download '$url': $exceptionMessage" - if ($retries -gt 0) { - $retries-- - Write-Host "Waiting 10 seconds before retrying. Retries left: $retries" - Start-Sleep -Seconds 10 +<# +.SYNOPSIS +Build this repository +.DESCRIPTION +Downloads korebuild if required. Then builds the repository. + +.PARAMETER Path +The folder to build. Defaults to the folder containing this script. + +.PARAMETER Channel +The channel of KoreBuild to download. Overrides the value from the config file. + +.PARAMETER DotNetHome +The directory where .NET Core tools will be stored. + +.PARAMETER ToolsSource +The base url where build tools can be downloaded. Overrides the value from the config file. + +.PARAMETER Update +Updates KoreBuild to the latest version even if a lock file is present. + +.PARAMETER ConfigFile +The path to the configuration file that stores values. Defaults to version.xml. + +.PARAMETER MSBuildArgs +Arguments to be passed to MSBuild + +.NOTES +This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. +When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. + +The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. + +.EXAMPLE +Example config file: +```xml + + + + dev + https://aspnetcore.blob.core.windows.net/buildtools + + +``` +#> +[CmdletBinding(PositionalBinding = $false)] +param( + [string]$Path = $PSScriptRoot, + [Alias('c')] + [string]$Channel, + [Alias('d')] + [string]$DotNetHome, + [Alias('s')] + [string]$ToolsSource, + [Alias('u')] + [switch]$Update, + [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$MSBuildArgs +) + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + +# +# Functions +# + +function Get-KoreBuild { + + $lockFile = Join-Path $Path 'korebuild-lock.txt' + + if (!(Test-Path $lockFile) -or $Update) { + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + } + + $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 + if (!$version) { + Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" + } + $version = $version.TrimStart('version:').Trim() + $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + + if (!(Test-Path $korebuildPath)) { + Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" + New-Item -ItemType Directory -Path $korebuildPath | Out-Null + $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" + + try { + $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" + Get-RemoteFile $remotePath $tmpfile + if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + # Use built-in commands where possible as they are cross-plat compatible + Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } - else - { - $exception = $_.Exception - throw $exception + else { + # Fallback to old approach for old installations of PowerShell + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) } } + catch { + Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore + throw + } + finally { + Remove-Item $tmpfile -ErrorAction Ignore + } } + + return $korebuildPath } -cd $PSScriptRoot - -$repoFolder = $PSScriptRoot -$env:REPO_FOLDER = $repoFolder - -$koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if ($env:KOREBUILD_ZIP) -{ - $koreBuildZip=$env:KOREBUILD_ZIP +function Join-Paths([string]$path, [string[]]$childPaths) { + $childPaths | ForEach-Object { $path = Join-Path $path $_ } + return $path } -$buildFolder = ".build" -$buildFile="$buildFolder\KoreBuild.ps1" - -if (!(Test-Path $buildFolder)) { - Write-Host "Downloading KoreBuild from $koreBuildZip" - - $tempFolder=$env:TEMP + "\KoreBuild-" + [guid]::NewGuid() - New-Item -Path "$tempFolder" -Type directory | Out-Null - - $localZipFile="$tempFolder\korebuild.zip" - - DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6 - - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder) - - New-Item -Path "$buildFolder" -Type directory | Out-Null - copy-item "$tempFolder\**\build\*" $buildFolder -Recurse - - # Cleanup - if (Test-Path $tempFolder) { - Remove-Item -Recurse -Force $tempFolder +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { + if ($RemotePath -notlike 'http*') { + Copy-Item $RemotePath $LocalPath + return } + + $retries = 10 + while ($retries -gt 0) { + $retries -= 1 + try { + Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + return + } + catch { + Write-Verbose "Request failed. $retries retries remaining" + } + } + + Write-Error "Download failed: '$RemotePath'." } -&"$buildFile" @args +# +# Main +# + +# Load configuration or set defaults + +if (Test-Path $ConfigFile) { + [xml] $config = Get-Content $ConfigFile + if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } + if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } +} + +if (!$DotNetHome) { + $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` + elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` + elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` + else { Join-Path $PSScriptRoot '.dotnet'} +} + +if (!$Channel) { $Channel = 'dev' } +if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } + +# Execute + +$korebuildPath = Get-KoreBuild +Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') + +try { + Install-Tools $ToolsSource $DotNetHome + Invoke-RepositoryBuild $Path @MSBuildArgs +} +finally { + Remove-Module 'KoreBuild' -ErrorAction Ignore +} diff --git a/build.sh b/build.sh index b0bcadb579..ab590e62f1 100755 --- a/build.sh +++ b/build.sh @@ -1,46 +1,196 @@ #!/usr/bin/env bash -repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $repoFolder -koreBuildZip="https://github.com/aspnet/KoreBuild/archive/dev.zip" -if [ ! -z $KOREBUILD_ZIP ]; then - koreBuildZip=$KOREBUILD_ZIP -fi +set -euo pipefail -buildFolder=".build" -buildFile="$buildFolder/KoreBuild.sh" +# +# variables +# -if test ! -d $buildFolder; then - echo "Downloading KoreBuild from $koreBuildZip" +RESET="\033[0m" +RED="\033[0;31m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +config_file="$DIR/version.xml" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' - tempFolder="/tmp/KoreBuild-$(uuidgen)" - mkdir $tempFolder +# +# Functions +# +__usage() { + echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + 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." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - localZipFile="$tempFolder/korebuild.zip" - - retries=6 - until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null) - do - echo "Failed to download '$koreBuildZip'" - if [ "$retries" -le 0 ]; then - exit 1 - fi - retries=$((retries - 1)) - echo "Waiting 10 seconds before retrying. Retries left: $retries" - sleep 10s - done - - unzip -q -d $tempFolder $localZipFile - - mkdir $buildFolder - cp -r $tempFolder/**/build/** $buildFolder - - chmod +x $buildFile - - # Cleanup - if test -d $tempFolder; then - rm -rf $tempFolder + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 fi +} + +get_korebuild() { + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f $lock_file ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + fi + local version="$(grep 'version:*' -m 1 $lock_file)" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file $remote_path $tmpfile; then + unzip -q -d "$korebuild_path" $tmpfile + fi + rm $tmpfile || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}$@${RESET}" 1>&2 +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp $remote_path $local_path + return 0 + fi + + failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O $local_path $remote_path || failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} + +# +# main +# + +while [[ $# > 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel=${1:-} + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME=${1:-} + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 fi -$buildFile -r $repoFolder "$@" +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +if [ -f $config_file ]; then + comment=false + while __read_dom; do + if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi + if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi + if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi + if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi + done < $config_file +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +install_tools "$tools_source" "$DOTNET_HOME" +invoke_repository_build "$repo_path" $@ diff --git a/build/common.props b/build/common.props index 6475bd27ed..6203de218d 100644 --- a/build/common.props +++ b/build/common.props @@ -1,6 +1,6 @@ - + Microsoft ASP.NET Core diff --git a/version.props b/version.xml similarity index 55% rename from version.props rename to version.xml index 1ea46af42a..3c05022b7d 100644 --- a/version.props +++ b/version.xml @@ -1,6 +1,7 @@ - + + dev 2.1.0 preview1 From 27dd5cb4f29d9226b918d04f55fe6787bb62b187 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 26 Jul 2017 10:28:17 -0700 Subject: [PATCH 228/361] Fix syntax warning when running build.sh on older versions of bash [ci skip] --- build.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/build.sh b/build.sh index ab590e62f1..5568c6182a 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ RESET="\033[0m" RED="\033[0;31m" MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}"] && DOTNET_HOME="$HOME/.dotnet" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" config_file="$DIR/version.xml" verbose=false update=false @@ -22,7 +22,7 @@ tools_source='' # Functions # __usage() { - echo "Usage: $(basename ${BASH_SOURCE[0]}) [options] [[--] ...]" + echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" echo "" echo "Arguments:" echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." @@ -46,16 +46,17 @@ __usage() { } get_korebuild() { + local version local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f $lock_file ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" $lock_file + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" fi - local version="$(grep 'version:*' -m 1 $lock_file)" + version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" return 1 fi - version="$(echo ${version#version:} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" { @@ -64,10 +65,10 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file $remote_path $tmpfile; then - unzip -q -d "$korebuild_path" $tmpfile + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" fi - rm $tmpfile || true + rm "$tmpfile" || true fi source "$korebuild_path/KoreBuild.sh" @@ -81,7 +82,7 @@ get_korebuild() { } __error() { - echo -e "${RED}$@${RESET}" 1>&2 + echo -e "${RED}$*${RESET}" 1>&2 } __machine_has() { @@ -94,18 +95,18 @@ __get_remote_file() { local local_path=$2 if [[ "$remote_path" != 'http'* ]]; then - cp $remote_path $local_path + cp "$remote_path" "$local_path" return 0 fi failed=false if __machine_has wget; then - wget --tries 10 --quiet -O $local_path $remote_path || failed=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o $local_path $remote_path || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi if [ "$failed" = true ]; then @@ -114,13 +115,13 @@ __get_remote_file() { fi } -__read_dom () { local IFS=\> ; read -d \< ENTITY CONTENT ;} +__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} # # main # -while [[ $# > 0 ]]; do +while [[ $# -gt 0 ]]; do case $1 in -\?|-h|--help) __usage --no-exit @@ -128,7 +129,7 @@ while [[ $# > 0 ]]; do ;; -c|--channel|-Channel) shift - channel=${1:-} + channel="${1:-}" [ -z "$channel" ] && __usage ;; --config-file|-ConfigFile) @@ -138,7 +139,7 @@ while [[ $# > 0 ]]; do ;; -d|--dotnet-home|-DotNetHome) shift - DOTNET_HOME=${1:-} + DOTNET_HOME="${1:-}" [ -z "$DOTNET_HOME" ] && __usage ;; --path|-Path) @@ -178,14 +179,14 @@ if ! __machine_has curl && ! __machine_has wget; then exit 1 fi -if [ -f $config_file ]; then +if [ -f "$config_file" ]; then comment=false while __read_dom; do if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < $config_file + done < "$config_file" fi [ -z "$channel" ] && channel='dev' @@ -193,4 +194,4 @@ fi get_korebuild install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" $@ +invoke_repository_build "$repo_path" "$@" From c473800042e2ea611124fe7c35dec966b56b120b Mon Sep 17 00:00:00 2001 From: = Date: Thu, 20 Jul 2017 14:43:58 -0700 Subject: [PATCH 229/361] Installer generation updates Produce dotnet hosting bundle installers .deb, .rpm, .tar.gz test generated installers after building --- build/repo.targets | 639 ++++++++++++++---- tools/RestoreRuntimeStore/NuGet.config | 7 - .../RestoreRuntimeStore.csproj | 13 - tools/docker/{debian => debian.8}/Dockerfile | 0 tools/docker/{rhel => rhel.7}/Dockerfile | 0 tools/{ => packaging}/changelog | 0 tools/packaging/hosting_debian_config.json | 35 + .../store_debian_config.json} | 6 +- .../GetSharedFrameworkVersion.ps1 | 0 .../GetSharedFrameworkVersion.sh | 0 .../InstallSharedFrameworkx86.ps1 | 0 tools/scripts/TestInstallers.sh | 77 +++ tools/{ => scripts}/zip2tgz.sh | 0 13 files changed, 622 insertions(+), 155 deletions(-) delete mode 100644 tools/RestoreRuntimeStore/NuGet.config delete mode 100644 tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj rename tools/docker/{debian => debian.8}/Dockerfile (100%) rename tools/docker/{rhel => rhel.7}/Dockerfile (100%) rename tools/{ => packaging}/changelog (100%) create mode 100644 tools/packaging/hosting_debian_config.json rename tools/{debian_config.json => packaging/store_debian_config.json} (89%) rename tools/{ => scripts}/GetSharedFrameworkVersion.ps1 (100%) rename tools/{ => scripts}/GetSharedFrameworkVersion.sh (100%) rename tools/{ => scripts}/InstallSharedFrameworkx86.ps1 (100%) create mode 100755 tools/scripts/TestInstallers.sh rename tools/{ => scripts}/zip2tgz.sh (100%) diff --git a/build/repo.targets b/build/repo.targets index d9f6d219b1..18e4610c8b 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -28,10 +28,13 @@ aspnetcore-store-$(TimestampVersion) aspnetcore-store-$(NoTimestampVersion) + dotnet-hosting-$(TimestampVersion) + dotnet-hosting-$(NoTimestampVersion) $(RepositoryRoot).rw\ $(RepositoryRoot).ro\ $(RepositoryRoot)artifacts\ + $(ArtifactsDir)dotnetInstallers\ $(ArtifactsDir)zip\ $(ArtifactsDir)deps\ $(ArtifactsZipDir)t\ @@ -40,31 +43,34 @@ $(ArtifactsZipDir)sn\ $(ArtifactsDir)installers\ $(ArtifactsDir)rsArchive\ - $(ArtifactsDir)itLayout\ + $(ArtifactsDir)StoreTimestampLayout\ $(RuntimeStoreInstallerLayoutTimestampDirectory)package_root\ - $(ArtifactsDir)inLayout\ + $(ArtifactsDir)StoreTimestampOutput\ + $(ArtifactsDir)StoreNoTimestampLayout\ $(RuntimeStoreInstallerLayoutNoTimestampDirectory)package_root\ - $(ArtifactsDir)itOutput\ - $(ArtifactsDir)inOutput\ + $(ArtifactsDir)StoreNoTimestampOutput\ + $(ArtifactsDir)HostingTimestampLayout\ + $(HostingBundleInstallerLayoutTimestampDirectory)package_root\ + $(ArtifactsDir)HostingTimestampOutput\ + $(ArtifactsDir)HostingNoTimestampLayout\ + $(HostingBundleInstallerLayoutNoTimestampDirectory)package_root\ + $(ArtifactsDir)HostingNoTimestampOutput\ $(ArtifactsDir)temp\ $(RepositoryRoot)tools\ + $(ToolsDir)packaging\ + $(ToolsDir)scripts\ $(ToolsDir)docker\ $(RepositoryRoot).deps\build\ $(ToolsDir)Build.RuntimeStore.References\ $(RuntimeStoreReferenceDirectory)bin\Release\ - $(ToolsDir)debian_config.json - $(ToolsDir)changelog + $(PackagingDir)store_debian_config.json + $(PackagingDir)hosting_debian_config.json + $(PackagingDir)changelog $(ToolsDir)dotnet-deb-tool-consumer\ - $(ToolsDir)RestoreRuntimeStore\ $(RepositoryRoot).build\ $(BuildDirectory)temp\ $(BuildDirectory)dotnet\ /opt/code/ - - - $(PrepareDependsOn); - UpdateNuGetConfig - @@ -197,7 +203,7 @@ - + @@ -205,10 +211,10 @@ - + - + @@ -228,7 +234,7 @@ - + $(BuildTempDirectory)shared\Microsoft.NETCore.App\$(SharedFrameworkVersion) @@ -331,9 +337,9 @@ - + - + @@ -345,27 +351,63 @@ + + + + + + + + + - $(RUNTIMESTORE_SIGNED_ARTIFACTS_PATH) - $(RuntimeStoreArchiveDirectory) + http://dotnetcli.azureedge.net/dotnet/Runtime/$(SharedFrameworkVersion)/dotnet-host-$(SharedFrameworkVersion) + http://dotnetcli.azureedge.net/dotnet/Runtime/$(SharedFrameworkVersion)/dotnet-hostfxr-$(SharedFrameworkVersion) + http://dotnetcli.azureedge.net/dotnet/Runtime/$(SharedFrameworkVersion)/dotnet-runtime-$(SharedFrameworkVersion) + http://dotnetcli.azureedge.net/dotnet/Runtime/$(SharedFrameworkVersion)/dotnet-runtime-$(SharedFrameworkVersion)-linux-x64.tar.gz - - + - - + + + + + + + + + + + + + + + + + + $(HostingBundleTimestampInstallerPackageName)-linux-$(PACKAGE_CACHE_PLATFORM).tar.gz + $(HostingBundleNoTimestampInstallerPackageName)-linux-$(PACKAGE_CACHE_PLATFORM).tar.gz + + + + + + + + + + + - - + + - - @@ -381,98 +423,208 @@ OverwriteReadOnlyFiles="True" SkipUnchangedFiles="False" UseHardlinksIfPossible="False" /> + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @(_InstallerSummary) - @(_InstallerDescription) - @(_InstallerLicense) - @(_InstallerPackageRevision) - @(_InstallerHomepage) - @(_InstallerMaintainerName) - @(_InstallerMaintainerEmail) - @(_InstallerChangelogMessage) + @(_StoreInstallerSummary) + @(_StoreInstallerDescription) + @(_StoreInstallerLicense) + @(_StoreInstallerPackageRevision) + @(_StoreInstallerHomepage) + @(_StoreInstallerMaintainerName) + @(_StoreInstallerMaintainerEmail) + @(_StoreInstallerChangelogMessage) + @(_HostingInstallerSummary) + @(_HostingInstallerDescription) + @(_HostingInstallerLicense) + @(_HostingInstallerPackageRevision) + @(_HostingInstallerHomepage) + @(_HostingInstallerMaintainerName) + @(_HostingInstallerMaintainerEmail) + @(_HostingInstallerChangelogMessage) + /opt/rh/rh-dotnet20/root/usr/lib64/dotnet/ + @(RHStoreDirectories->' --directories "%(FullPath)"', ' ') + /usr/share/dotnet/ + @(GeneralStoreDirectories->' --directories "%(FullPath)"', ' ') + + + Targets="BuildStoreAndHostingRPM" + Properties="DockerImage=rhel.7; + InstallerPlatform=rh.rhel.7; + InstallerInstallRoot=$(RHInstallerInstallRoot); + BuildNumber=$(BuildNumber); + SharedFrameworkVersion=$(SharedFrameworkVersion); + StoreDirectoriesArguments=$(RHStoreDirectoriesArguments); + StoreInstallerSummary=$(StoreInstallerSummary); + StoreInstallerDescription=$(StoreInstallerDescription); + StoreInstallerLicense=$(StoreInstallerLicense); + StoreInstallerPackageRevision=$(StoreInstallerPackageRevision); + StoreInstallerHomepage=$(StoreInstallerHomepage); + StoreInstallerMaintainerName=$(StoreInstallerMaintainerName); + StoreInstallerMaintainerEmail=$(StoreInstallerMaintainerEmail); + HostingInstallerSummary=$(HostingInstallerSummary); + HostingInstallerDescription=$(HostingInstallerDescription); + HostingInstallerLicense=$(HostingInstallerLicense); + HostingInstallerPackageRevision=$(HostingInstallerPackageRevision); + HostingInstallerHomepage=$(HostingInstallerHomepage); + HostingInstallerMaintainerName=$(HostingInstallerMaintainerName); + HostingInstallerMaintainerEmail=$(HostingInstallerMaintainerEmail); + SkipInstallerTests=true" /> + - - - - - - + $(RuntimeStoreTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm $(RuntimeStoreNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm - @(RPMDirectories->' --directories "%(FullPath)"', ' ') - $(InstallerMaintainerName) <$(InstallerMaintainerEmail)> + $(HostingBundleTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm + $(HostingBundleNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm + $(StoreInstallerMaintainerName) <$(StoreInstallerMaintainerEmail)> + $(HostingInstallerMaintainerName) <$(HostingInstallerMaintainerEmail)> .NET Foundation - /opt/rh/rh-dotnet20/root/usr/lib64/dotnet - - + + - + + -p $(DockerRootDirectory)artifacts/StoreTimestampOutput/$(RuntimeStoreTimestampRPMFileName) + --license "$(StoreInstallerLicense)" + --iteration $(StoreInstallerPackageRevision) + --url "$(StoreInstallerHomepage)" + $(DockerRootDirectory)artifacts/StoreTimestampLayout/package_root/="$(InstallerInstallRoot)"" /> + -p $(DockerRootDirectory)artifacts/StoreNoTimestampOutput/$(RuntimeStoreNoTimestampRPMFileName) + --license "$(StoreInstallerLicense)" + --iteration $(StoreInstallerPackageRevision) + --url "$(StoreInstallerHomepage)" + $(DockerRootDirectory)artifacts/StoreNoTimestampLayout/package_root/="$(InstallerInstallRoot)"" /> - - + + + + $(TimestampVersion) + + + $(SharedFrameworkVersion) + + + $(NoTimestampVersion) + + + $(SharedFrameworkVersion) + + + + + @(HostingBundleTimestampDependencies->' -d "%(Identity) >= %(Version)"', ' ') + @(HostingBundleNoTimestampDependencies->' -d "%(Identity) >= %(Version)"', ' ') + + + + - - + + + + - - + + + + + + + + + + + + + + + + + + - - + + - - + + - - - - + + + + + + + + + - - + $(RuntimeStoreTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb $(RuntimeStoreNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb + $(HostingBundleTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb + $(HostingBundleNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb - - - - + + - + - - - - + - - + + + + - - + + + + + + + + + + + + + @@ -656,5 +1013,23 @@ -n $(RUNTIMESTORE_NOTIMESTAMP_INSTALLERNAME) -v $(NoTimestampVersion)" WorkingDirectory="$(DotnetDebToolDirectory)" /> + + + + + + diff --git a/tools/RestoreRuntimeStore/NuGet.config b/tools/RestoreRuntimeStore/NuGet.config deleted file mode 100644 index e17aed4552..0000000000 --- a/tools/RestoreRuntimeStore/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj b/tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj deleted file mode 100644 index a0392260c4..0000000000 --- a/tools/RestoreRuntimeStore/RestoreRuntimeStore.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - netcoreapp2.0 - - - - - - - diff --git a/tools/docker/debian/Dockerfile b/tools/docker/debian.8/Dockerfile similarity index 100% rename from tools/docker/debian/Dockerfile rename to tools/docker/debian.8/Dockerfile diff --git a/tools/docker/rhel/Dockerfile b/tools/docker/rhel.7/Dockerfile similarity index 100% rename from tools/docker/rhel/Dockerfile rename to tools/docker/rhel.7/Dockerfile diff --git a/tools/changelog b/tools/packaging/changelog similarity index 100% rename from tools/changelog rename to tools/packaging/changelog diff --git a/tools/packaging/hosting_debian_config.json b/tools/packaging/hosting_debian_config.json new file mode 100644 index 0000000000..a01cf5cafc --- /dev/null +++ b/tools/packaging/hosting_debian_config.json @@ -0,0 +1,35 @@ +{ + "maintainer_name": "Microsoft", + "maintainer_email": "nugetaspnet@microsoft.com", + + "package_name": "dotnet-hosting", + "install_root": "/usr/share/dotnet", + + "short_description": "Microsoft .NET Core 2.0.0 Linux Server Hosting", + "long_description": "Microsoft .NET Core 2.0.0 Linux Server Hosting enables hosting of ASP.NET Core applications and contains the ASP.NET Core Runtime Package Store and .NET Core Runtime. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs.", + "homepage": "https://www.asp.net/", + + "release":{ + "package_version":"0.0.0.0", + "package_revision":"1", + "urgency" : "low", + "changelog_message" : "" + }, + + "control": { + "priority":"standard", + "section":"devel", + "architecture":"any" + }, + + "copyright": "Microsoft", + "license": { + "type": "Apache-2.0", + "full_text": "Copyright (c) .NET Foundation. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthese files except in compliance with the License. You may obtain a copy of the\nLicense at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License." + }, + + "debian_dependencies": { + "dotnet-runtime-DOTNET_RUNTIME_VERSION": {}, + "aspnetcore-store-ASPNETCORE_STORE_VERSION": {} + } +} \ No newline at end of file diff --git a/tools/debian_config.json b/tools/packaging/store_debian_config.json similarity index 89% rename from tools/debian_config.json rename to tools/packaging/store_debian_config.json index 90be44d183..dfd9d9b499 100644 --- a/tools/debian_config.json +++ b/tools/packaging/store_debian_config.json @@ -1,11 +1,11 @@ { - "maintainer_name":"Microsoft", + "maintainer_name": "Microsoft", "maintainer_email": "nugetaspnet@microsoft.com", "package_name": "aspnetcore-store", "install_root": "/usr/share/dotnet", - "short_description": "Microsoft ASP.NET Core Runtime Package Store 2.0.0", + "short_description": "Microsoft ASP.NET Core 2.0.0 Runtime Package Store", "long_description": "Runtime package store for Microsoft ASP.NET Core. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs.", "homepage": "https://www.asp.net/", @@ -13,7 +13,7 @@ "package_version":"0.0.0.0", "package_revision":"1", "urgency" : "low", - "changelog_message" : "Bootstrap loop package" + "changelog_message" : "" }, "control": { diff --git a/tools/GetSharedFrameworkVersion.ps1 b/tools/scripts/GetSharedFrameworkVersion.ps1 similarity index 100% rename from tools/GetSharedFrameworkVersion.ps1 rename to tools/scripts/GetSharedFrameworkVersion.ps1 diff --git a/tools/GetSharedFrameworkVersion.sh b/tools/scripts/GetSharedFrameworkVersion.sh similarity index 100% rename from tools/GetSharedFrameworkVersion.sh rename to tools/scripts/GetSharedFrameworkVersion.sh diff --git a/tools/InstallSharedFrameworkx86.ps1 b/tools/scripts/InstallSharedFrameworkx86.ps1 similarity index 100% rename from tools/InstallSharedFrameworkx86.ps1 rename to tools/scripts/InstallSharedFrameworkx86.ps1 diff --git a/tools/scripts/TestInstallers.sh b/tools/scripts/TestInstallers.sh new file mode 100755 index 0000000000..dbda428443 --- /dev/null +++ b/tools/scripts/TestInstallers.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +set -e +set -o pipefail + +artifactsDir="artifacts/" +installersDir=$artifactsDir"installers/" +dotnetInstallersDir=$artifactsDir"dotnetInstallers/" +installerTestDir=$artifactsDir"installerTest/" + +# clean up test directory +if [ -d $installerTestDir ]; then + rm -r $installerTestDir +fi +mkdir $installerTestDir + +# copy dotnet installers +cp $dotnetInstallersDir*$DotnetInstallerSuffix $installerTestDir + +# copy store and hosting installers +cp $installersDir$StoreInstallerFile $installerTestDir +cp $installersDir$HostingInstallerFile $installerTestDir + +# test store install +(cd $installerTestDir && $InstallCommand $StoreInstallerFile) + +if [ ! -d $InstallRoot"additionalDeps" ]; then + echo $InstallRoot"additionalDeps missing after installing the runtime store." + exit 1 +fi +if [ ! -d $InstallRoot"store" ]; then + echo $InstallRoot"store missing after installing the runtime store." + exit 1 +fi + +# test store uninstall +$UninstallCommand $StoreInstallerPackageName + +if [ -d $InstallRoot"additionalDeps" ]; then + echo $InstallRoot"additionalDeps remains after uninstalling the runtime store." + exit 1 +fi +if [ -d $InstallRoot"store" ]; then + echo $InstallRoot"store remains after uninstalling the runtime store." + exit 1 +fi + +# test hosting install +(cd $installerTestDir && $InstallCommand *$InstallerExtension) + +if [ ! -d $InstallRoot"additionalDeps" ]; then + echo $InstallRoot"additionalDeps missing after installing the hosting bundle." + exit 1 +fi +if [ ! -d $InstallRoot"shared" ]; then + echo $InstallRoot"shared missing after installing the hosting bundle." + exit 1 +fi +if [ ! -d $InstallRoot"store" ]; then + echo $InstallRoot"store missing after installing the hosting bundle." + exit 1 +fi + +# test hosting uninstall +$UninstallCommand $HostingInstallerPackageName + +if [ ! -d $InstallRoot"additionalDeps" ]; then + echo $InstallRoot"additionalDeps missing after installing the hosting bundle." + exit 1 +fi +if [ ! -d $InstallRoot"shared" ]; then + echo $InstallRoot"shared missing after installing the hosting bundle." + exit 1 +fi +if [ ! -d $InstallRoot"store" ]; then + echo $InstallRoot"store missing after installing the hosting bundle." + exit 1 +fi diff --git a/tools/zip2tgz.sh b/tools/scripts/zip2tgz.sh similarity index 100% rename from tools/zip2tgz.sh rename to tools/scripts/zip2tgz.sh From a79dafebaf2d42a1a0a70c3169a07cf1ed87ccc3 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 26 Jul 2017 11:39:31 -0700 Subject: [PATCH 230/361] Remove changelog message from rpm generation --- build/repo.targets | 40 ++++++++++++++------------------------- tools/packaging/changelog | 2 +- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index 18e4610c8b..a9ce29cf08 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -458,9 +458,6 @@ - - - @@ -482,9 +479,6 @@ - - - @@ -501,7 +495,6 @@ @(_StoreInstallerHomepage) @(_StoreInstallerMaintainerName) @(_StoreInstallerMaintainerEmail) - @(_StoreInstallerChangelogMessage) @(_HostingInstallerSummary) @(_HostingInstallerDescription) @(_HostingInstallerLicense) @@ -509,7 +502,6 @@ @(_HostingInstallerHomepage) @(_HostingInstallerMaintainerName) @(_HostingInstallerMaintainerEmail) - @(_HostingInstallerChangelogMessage) /opt/rh/rh-dotnet20/root/usr/lib64/dotnet/ @(RHStoreDirectories->' --directories "%(FullPath)"', ' ') /usr/share/dotnet/ @@ -523,7 +515,6 @@ -e 's/MAINTAINER_EMAIL/$(StoreInstallerMaintainerEmail)/' -e 's/PACKAGE_VERSION/$(TimestampVersion)/' -e 's/PACKAGE_REVISION/$(StoreInstallerPackageRevision)/' - -e 's/CHANGELOG_MESSAGE/$(StoreInstallerChangelogMessage)/' $(RuntimeStoreInstallerLayoutTimestampDirectory)templates/changelog" /> @@ -851,27 +839,27 @@ -e 's/ASPNETCORE_STORE_VERSION/$(NoTimestampVersion)/' $(HostingBundleInstallerLayoutNoTimestampDirectory)debian_config.json" /> - - - - diff --git a/tools/packaging/changelog b/tools/packaging/changelog index 862c3f42d7..f28d88ed10 100644 --- a/tools/packaging/changelog +++ b/tools/packaging/changelog @@ -1,2 +1,2 @@ * DATE MAINTAINER_NAME - PACKAGE_VERSION-PACKAGE_REVISION -- CHANGELOG_MESSAGE \ No newline at end of file +- \ No newline at end of file From f6231c7eba5aa97c1eb3fb1d147c8fa4f27d5e86 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 27 Jul 2017 10:06:08 -0700 Subject: [PATCH 231/361] Remove NETStandardLibraryNETFrameworkVersion --- build/dependencies.props | 1 - 1 file changed, 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 1dedc92dbb..5996baf3f6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,6 @@ 10.0.1 4.7.49 2.0.0-* - 2.0.0-* 2.0.0-* 15.3.0-* 2.3.0-beta2-* From b32ad7e7316bf67ff3057629774fa60b90b1b1d4 Mon Sep 17 00:00:00 2001 From: Jun Tao Luo Date: Thu, 27 Jul 2017 12:39:10 -0700 Subject: [PATCH 232/361] ProjectPath is no longer set, use MSBuildProjectFullPath instead --- build/repo.targets | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index a9ce29cf08..4fd6ebe9c8 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -161,7 +161,7 @@ - + @@ -175,15 +175,15 @@ - - + + - + @@ -246,14 +246,8 @@ - - - - - - - - + + @@ -306,8 +300,8 @@ - - + + @@ -539,7 +533,7 @@ $(HostingBundleInstallerLayoutNoTimestampDirectory)templates/changelog" /> &2 return 1 fi From bc8eebf67aad6b5fae51c10b11b3df02e3c8378c Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 2 Aug 2017 14:32:50 -0700 Subject: [PATCH 234/361] Ensure fallback to curl after failed wget --- build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 8eace4c20d..11cdbe5504 100755 --- a/build.sh +++ b/build.sh @@ -99,16 +99,19 @@ __get_remote_file() { return 0 fi - local succeeded=false + local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" && succeeded=true + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true fi - if [ "$succeeded" = false ] && __machine_has curl; then - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" && succeeded=true + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true fi - if [ "$succeeded" = false ]; then + if [ "$failed" = true ]; then __error "Download failed: $remote_path" 1>&2 return 1 fi From 90503c097d79572b3c374419aa14d88b93710ee1 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 2 Aug 2017 17:11:24 -0700 Subject: [PATCH 235/361] Remove KoreBuild dependent build steps - remove references to .build directory - dotnet cli is not automatically installed on docker images - install x86 dotnet cli using environment variable --- build/repo.targets | 42 ++------------------- tools/scripts/InstallSharedFrameworkx86.ps1 | 28 -------------- 2 files changed, 3 insertions(+), 67 deletions(-) delete mode 100644 tools/scripts/InstallSharedFrameworkx86.ps1 diff --git a/build/repo.targets b/build/repo.targets index 4fd6ebe9c8..f02ea34b4c 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -67,9 +67,6 @@ $(PackagingDir)hosting_debian_config.json $(PackagingDir)changelog $(ToolsDir)dotnet-deb-tool-consumer\ - $(RepositoryRoot).build\ - $(BuildDirectory)temp\ - $(BuildDirectory)dotnet\ /opt/code/ @@ -207,8 +204,6 @@ - - @@ -219,7 +214,7 @@ - + @@ -233,18 +228,6 @@ - - - - - $(BuildTempDirectory)shared\Microsoft.NETCore.App\$(SharedFrameworkVersion) - - - - - - - @@ -341,9 +324,7 @@ - - - + @@ -748,11 +729,6 @@ OverwriteReadOnlyFiles="true" SkipUnchangedFiles="false" /> - - - - - - - - - - diff --git a/tools/scripts/InstallSharedFrameworkx86.ps1 b/tools/scripts/InstallSharedFrameworkx86.ps1 deleted file mode 100644 index 9931660110..0000000000 --- a/tools/scripts/InstallSharedFrameworkx86.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -param ( - [string]$sharedRuntimeVersion, - [string]$installationDirectory -) - -$sharedRuntimeChannel = "master" -if ($env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL) -{ - $sharedRuntimeChannel = $env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL -} - -function InstallSharedRuntime([string] $version, [string] $channel, [string] $installDir) -{ - $sharedRuntimePath = [IO.Path]::Combine($installDir, 'shared', 'Microsoft.NETCore.App', $version) - # Avoid redownloading the CLI if it's already installed. - if (!(Test-Path $sharedRuntimePath)) - { - & "$PSScriptRoot\..\.build\dotnet\dotnet-install.ps1" ` - -Channel $channel ` - -SharedRuntime ` - -Version $version ` - -Architecture 'x86' ` - -InstallDir $installDir ` - -NoPath - } -} - -InstallSharedRuntime -version $sharedRuntimeVersion -channel $sharedRuntimeChannel -installDir $installationDirectory From cbad7fad7a7a54ca79fd11992dab11c931595ca8 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 3 Aug 2017 17:39:26 -0700 Subject: [PATCH 236/361] Add API baseline for Microsoft.AspNetCore --- .../baseline.netcore.json | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 src/Microsoft.AspNetCore/baseline.netcore.json diff --git a/src/Microsoft.AspNetCore/baseline.netcore.json b/src/Microsoft.AspNetCore/baseline.netcore.json new file mode 100644 index 0000000000..482a58e908 --- /dev/null +++ b/src/Microsoft.AspNetCore/baseline.netcore.json @@ -0,0 +1,136 @@ +{ + "AssemblyIdentity": "Microsoft.AspNetCore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "Types": [ + { + "Name": "Microsoft.AspNetCore.WebHost", + "Visibility": "Public", + "Kind": "Class", + "Abstract": true, + "Static": true, + "Sealed": true, + "ImplementedInterfaces": [], + "Members": [ + { + "Kind": "Method", + "Name": "Start", + "Parameters": [ + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + } + ], + "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Start", + "Parameters": [ + { + "Name": "url", + "Type": "System.String" + }, + { + "Name": "app", + "Type": "Microsoft.AspNetCore.Http.RequestDelegate" + } + ], + "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Start", + "Parameters": [ + { + "Name": "routeBuilder", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "Start", + "Parameters": [ + { + "Name": "url", + "Type": "System.String" + }, + { + "Name": "routeBuilder", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "StartWith", + "Parameters": [ + { + "Name": "app", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "StartWith", + "Parameters": [ + { + "Name": "url", + "Type": "System.String" + }, + { + "Name": "app", + "Type": "System.Action" + } + ], + "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHost", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateDefaultBuilder", + "Parameters": [], + "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHostBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + }, + { + "Kind": "Method", + "Name": "CreateDefaultBuilder", + "Parameters": [ + { + "Name": "args", + "Type": "System.String[]" + } + ], + "ReturnType": "Microsoft.AspNetCore.Hosting.IWebHostBuilder", + "Static": true, + "Visibility": "Public", + "GenericParameter": [] + } + ], + "GenericParameters": [] + } + ] +} \ No newline at end of file From c77f362da5f567a7a4b663b0b1f564ee07365e89 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 7 Aug 2017 17:06:58 -0700 Subject: [PATCH 237/361] Update Microsoft.AspNetCore.Server.IntegrationTesting package version --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5996baf3f6..be4e425678 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,6 +1,6 @@ - 0.4.0-* + 0.5.0-* 2.1.0-* 4.4.0-* 2.0.0-preview2-* From 508501a5732429c598835346bd9b646b2b664cf0 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 7 Aug 2017 16:06:50 -0700 Subject: [PATCH 238/361] Skip installing 1.0.5 and 1.1.2 shared runtime for debian installer builds --- build/repo.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/build/repo.targets b/build/repo.targets index f02ea34b4c..6caa557275 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -857,6 +857,7 @@ --rm -v $(RepositoryRoot):$(DockerRootDirectory) -e DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true + -e KOREBUILD_SKIP_OLD_RUNTIME_INSTALL=true -e BuildNumber=$(BuildNumber) -e RUNTIMESTORE_TIMESTAMP_INSTALLERNAME=$(RuntimeStoreTimestampInstallerPackageName) -e RUNTIMESTORE_NOTIMESTAMP_INSTALLERNAME=$(RuntimeStoreNoTimestampInstallerPackageName) From e9e7baf3f19f0e3bb74cd3dcc4fba578c2de9a0a Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 26 Jul 2017 14:52:56 -0700 Subject: [PATCH 239/361] Rename store zip and lzma filename --- build/Build.RS.nuspec | 13 ------------- build/repo.targets | 31 +++++++++++++------------------ 2 files changed, 13 insertions(+), 31 deletions(-) delete mode 100644 build/Build.RS.nuspec diff --git a/build/Build.RS.nuspec b/build/Build.RS.nuspec deleted file mode 100644 index fee5984b47..0000000000 --- a/build/Build.RS.nuspec +++ /dev/null @@ -1,13 +0,0 @@ - - - - Build.RS - $version$ - Microsoft - Runtime Package Store for ASP.NET Core, for internal builds - - - - - - diff --git a/build/repo.targets b/build/repo.targets index 6caa557275..34806e9878 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -90,19 +90,16 @@ - win$(PACKAGE_CACHE_PLATFORM) - linux - osx win7-$(PACKAGE_CACHE_PLATFORM) linux-$(PACKAGE_CACHE_PLATFORM) osx-$(PACKAGE_CACHE_PLATFORM) - $(ArtifactsDir)Build.RS.$(OutputZipSufix)-$(VersionSuffix).zip - $(ArtifactsDir)Build.RS.$(OutputZipSufix).zip - $(ArtifactsDir)Build.Symbols.RS.$(OutputZipSufix)-$(VersionSuffix).zip - $(ArtifactsDir)Build.Symbols.RS.$(OutputZipSufix).zip - $(ArtifactsDir)Build.Symbols.RS.$(OutputZipSufix)-$(VersionSuffix).tar.gz - $(ArtifactsDir)Build.Symbols.RS.$(OutputZipSufix).tar.gz + $(ArtifactsDir)aspnetcore-store-$(TimestampVersion)-$(RID).zip + $(ArtifactsDir)aspnetcore-store-$(NoTimestampVersion)-$(RID).zip + $(ArtifactsDir)aspnetcore-symbols-$(TimestampVersion)-$(RID).zip + $(ArtifactsDir)aspnetcore-symbols-$(NoTimestampVersion)-$(RID).zip + $(ArtifactsDir)aspnetcore-symbols-$(TimestampVersion)-$(RID).tar.gz + $(ArtifactsDir)aspnetcore-symbols-$(NoTimestampVersion)-$(RID).tar.gz @@ -175,10 +172,6 @@ - - - - @@ -278,19 +271,21 @@ $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages-NoTimeStamp $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages + nuGetPackagesArchive-$(NoTimestampVersion) + nuGetPackagesArchive-$(TimestampVersion) - - + + $(PublishShare)\fallbackArchives - + @@ -327,8 +322,8 @@ - - + + From 3e0ece99360aec175912f4ec9adb11693989a362 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 9 Aug 2017 13:05:42 -0700 Subject: [PATCH 240/361] Fix package archive name typo --- build/repo.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/repo.targets b/build/repo.targets index 34806e9878..c8a7b7723b 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -285,7 +285,7 @@ $(PublishShare)\fallbackArchives - + From b5e81bd4a06bc21615d6be6c863f45bde1c4dd8e Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 9 Aug 2017 14:27:04 -0700 Subject: [PATCH 241/361] Use linux specific runtime identifier when gathering installer prerequisites --- build/repo.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/repo.targets b/build/repo.targets index c8a7b7723b..51ed667d7c 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -322,8 +322,8 @@ - - + + From 653272600fb755a84178cad98cdf031484d05b80 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 10 Aug 2017 08:11:57 -0700 Subject: [PATCH 242/361] Add site extension generation code (#217) --- MetaPackages.sln | 12 ++++- build/SiteExtension.targets | 27 ++++++++++ build/repo.targets | 21 +++++++- .../Microsoft.AspNetCore.SiteExtension.csproj | 53 +++++++++++++++++++ .../applicationHost.xdt | 15 ++++++ 5 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 build/SiteExtension.targets create mode 100644 src/Microsoft.AspNetCore.SiteExtension/Microsoft.AspNetCore.SiteExtension.csproj create mode 100644 src/Microsoft.AspNetCore.SiteExtension/applicationHost.xdt diff --git a/MetaPackages.sln b/MetaPackages.sln index b7897ad663..0402c256f9 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26510.0 +VisualStudioVersion = 15.0.26727.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" EndProject @@ -43,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SiteExtension", "src\Microsoft.AspNetCore.SiteExtension\Microsoft.AspNetCore.SiteExtension.csproj", "{A27ACBA8-25A6-4527-95D4-5B8D0537AF52}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -89,6 +91,10 @@ Global {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.Build.0 = Release|Any CPU + {A27ACBA8-25A6-4527-95D4-5B8D0537AF52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A27ACBA8-25A6-4527-95D4-5B8D0537AF52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A27ACBA8-25A6-4527-95D4-5B8D0537AF52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A27ACBA8-25A6-4527-95D4-5B8D0537AF52}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -106,5 +112,9 @@ Global {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + {A27ACBA8-25A6-4527-95D4-5B8D0537AF52} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {500600F2-E434-4372-B04D-39CAAADFF973} EndGlobalSection EndGlobal diff --git a/build/SiteExtension.targets b/build/SiteExtension.targets new file mode 100644 index 0000000000..ce4eb73822 --- /dev/null +++ b/build/SiteExtension.targets @@ -0,0 +1,27 @@ + + + + + + + + + + $(COHERENCE_SIGNED_DROP_LOCATION)\fallbackArchives\nuGetPackagesArchive-$(TimestampVersion).zip + $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\PackageCache\aspnetcore-store-$(TimestampVersion)-win7-x86.zip + + + + $(TempDir)FallbackArchive + $(TempDir)RuntimeStore + + + + + + + + + \ No newline at end of file diff --git a/build/repo.targets b/build/repo.targets index 51ed667d7c..aa664ebd15 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -70,6 +70,8 @@ /opt/code/ + + $(FallbackArchiveDir)obj/$(OutputPackageName) $(RepositoryRoot)artifacts\$(OutputPackageName).lzma + $(RepositoryRoot)artifacts\$(OutputPackageName).zip $(FallbackArchiveDir)\obj\$(OutputPackageName).NuGet.config @@ -257,7 +260,13 @@ - + + + + + + + @@ -285,7 +294,15 @@ $(PublishShare)\fallbackArchives - + + diff --git a/src/Microsoft.AspNetCore.SiteExtension/Microsoft.AspNetCore.SiteExtension.csproj b/src/Microsoft.AspNetCore.SiteExtension/Microsoft.AspNetCore.SiteExtension.csproj new file mode 100644 index 0000000000..e8e11b68d6 --- /dev/null +++ b/src/Microsoft.AspNetCore.SiteExtension/Microsoft.AspNetCore.SiteExtension.csproj @@ -0,0 +1,53 @@ + + + + + + ASP.NET Core Extensions + This extension enables additional functionality for ASP.NET Core on Azure WebSites, such as enabling Azure logging. + net461 + false + aspnet;logging;aspnetcore;AzureSiteExtension + AzureSiteExtension + false + false + content + + https://github.com/aspnet/AzureIntegration/blob/rel/2.0.0-preview1/LICENSE.txt + https://go.microsoft.com/fwlink/?LinkID=288859 + https://www.asp.net/ + + + + + + + + + + + + + <_PackageFiles Include="$(DotnetHomeDirectory)\**\*.*" Exclude="$(DotnetHomeDirectory)\sdk\NuGetFallbackFolder\**\*.*;$(DotnetHomeDirectory)\store\**\*.*;$(DotnetHomeDirectory)\additionalDeps\**\*.*" Condition="$(DotnetHomeDirectory) != ''"> + tools\ + false + Content + + + <_PackageFiles Include="$(FallbackArchiveDestination)\**\*.*" Condition="$(FallbackArchiveDestination) != ''"> + tools\sdk\NuGetFallbackFolder\ + false + Content + + + <_PackageFiles Include="$(RuntimeStoreDestination)\**\*.*" Condition="$(RuntimeStoreDestination) != ''"> + tools\ + false + Content + + + + + + + diff --git a/src/Microsoft.AspNetCore.SiteExtension/applicationHost.xdt b/src/Microsoft.AspNetCore.SiteExtension/applicationHost.xdt new file mode 100644 index 0000000000..3cb633cdf6 --- /dev/null +++ b/src/Microsoft.AspNetCore.SiteExtension/applicationHost.xdt @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file From 396f413b389f5983e413be465f917cbfdbda26c9 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 10 Aug 2017 09:38:19 -0700 Subject: [PATCH 243/361] Rename testing metapackage (#218) --- MetaPackages.sln | 12 ++++++------ build/SiteExtension.targets | 2 +- build/repo.props | 1 + ...ft.AspNetCore.AzureAppServices.TestBundle.csproj} | 0 .../applicationHost.xdt | 0 5 files changed, 8 insertions(+), 7 deletions(-) rename src/{Microsoft.AspNetCore.SiteExtension/Microsoft.AspNetCore.SiteExtension.csproj => Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj} (100%) rename src/{Microsoft.AspNetCore.SiteExtension => Microsoft.AspNetCore.AzureAppServices.TestBundle}/applicationHost.xdt (100%) diff --git a/MetaPackages.sln b/MetaPackages.sln index 0402c256f9..2957cc0c6d 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -43,7 +43,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SiteExtension", "src\Microsoft.AspNetCore.SiteExtension\Microsoft.AspNetCore.SiteExtension.csproj", "{A27ACBA8-25A6-4527-95D4-5B8D0537AF52}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.AzureAppServices.TestBundle", "src\Microsoft.AspNetCore.AzureAppServices.TestBundle\Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj", "{AE5CCCE0-9AD7-4AB3-B732-FC049766331C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -91,10 +91,10 @@ Global {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.Build.0 = Release|Any CPU - {A27ACBA8-25A6-4527-95D4-5B8D0537AF52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A27ACBA8-25A6-4527-95D4-5B8D0537AF52}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A27ACBA8-25A6-4527-95D4-5B8D0537AF52}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A27ACBA8-25A6-4527-95D4-5B8D0537AF52}.Release|Any CPU.Build.0 = Release|Any CPU + {AE5CCCE0-9AD7-4AB3-B732-FC049766331C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE5CCCE0-9AD7-4AB3-B732-FC049766331C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE5CCCE0-9AD7-4AB3-B732-FC049766331C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE5CCCE0-9AD7-4AB3-B732-FC049766331C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -112,7 +112,7 @@ Global {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} - {A27ACBA8-25A6-4527-95D4-5B8D0537AF52} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} + {AE5CCCE0-9AD7-4AB3-B732-FC049766331C} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {500600F2-E434-4372-B04D-39CAAADFF973} diff --git a/build/SiteExtension.targets b/build/SiteExtension.targets index ce4eb73822..0a40c9ca56 100644 --- a/build/SiteExtension.targets +++ b/build/SiteExtension.targets @@ -19,7 +19,7 @@ - diff --git a/build/repo.props b/build/repo.props index eab8b85f3b..2e89e8f97a 100644 --- a/build/repo.props +++ b/build/repo.props @@ -2,5 +2,6 @@ + diff --git a/src/Microsoft.AspNetCore.SiteExtension/Microsoft.AspNetCore.SiteExtension.csproj b/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj similarity index 100% rename from src/Microsoft.AspNetCore.SiteExtension/Microsoft.AspNetCore.SiteExtension.csproj rename to src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj diff --git a/src/Microsoft.AspNetCore.SiteExtension/applicationHost.xdt b/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/applicationHost.xdt similarity index 100% rename from src/Microsoft.AspNetCore.SiteExtension/applicationHost.xdt rename to src/Microsoft.AspNetCore.AzureAppServices.TestBundle/applicationHost.xdt From a0b303be0f47fe32b93b77a9231a96aa9c06609f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 22 Aug 2017 17:32:24 -0700 Subject: [PATCH 244/361] Upgrade to xunit 2.3.0-beta4 --- build/dependencies.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index be4e425678..20950edc8f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -9,7 +9,7 @@ 4.7.49 2.0.0-* 2.0.0-* - 15.3.0-* - 2.3.0-beta2-* + 15.3.0 + 2.3.0-beta4-build3742 From 5a3ce9fd5d3ae7f6cf117d8f203a4242db6baece Mon Sep 17 00:00:00 2001 From: John Luo Date: Fri, 25 Aug 2017 12:13:57 -0700 Subject: [PATCH 245/361] Update doc comments --- src/Microsoft.AspNetCore/WebHost.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 5833404e30..9b576a70fa 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -8,11 +8,9 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; -using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore { @@ -124,8 +122,7 @@ namespace Microsoft.AspNetCore /// load from environment variables, /// configures the to log to the console and debug output, /// enables IIS integration, - /// enables the ability for frameworks to bind their options to their default configuration sections, - /// and adds the developer exception page when is 'Development' + /// and enables the ability for frameworks to bind their options to their default configuration sections. /// /// The initialized . public static IWebHostBuilder CreateDefaultBuilder() => @@ -144,8 +141,7 @@ namespace Microsoft.AspNetCore /// load from supplied command line args, /// configures the to log to the console and debug output, /// enables IIS integration, - /// enables the ability for frameworks to bind their options to their default configuration sections, - /// and adds the developer exception page when is 'Development' + /// and enables the ability for frameworks to bind their options to their default configuration sections. /// /// The command line args. /// The initialized . From 5589365cac44044a97d1f40164f7c0ede770f215 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 30 Aug 2017 12:58:16 -0700 Subject: [PATCH 246/361] Use Directory.Build.props/targets (#227) --- appveyor.yml => .appveyor.yml | 0 Directory.Build.props | 16 ++ Directory.Build.targets | 2 + MetaPackages.sln | 11 +- build/BuildArchive.proj | 8 +- build/common.props | 203 ------------------ build/dependencies.props | 183 +++++++++++++++- build/repo.targets | 11 +- samples/SampleApp/SampleApp.csproj | 2 - .../Archive.AspNetCore.All.csproj | 4 +- src/Directory.Build.props | 7 + .../Microsoft.AspNetCore.All.csproj | 2 - ...NetCore.AzureAppServices.TestBundle.csproj | 2 - .../Microsoft.AspNetCore.RuntimeStore.csproj | 2 - .../Microsoft.AspNetCore.csproj | 2 - test/Directory.Build.props | 7 + ...icrosoft.AspNetCore.FunctionalTests.csproj | 2 - .../CreateDefaultBuilderApp.csproj | 2 - .../DependencyInjectionApp.csproj | 2 - .../StartRequestDelegateUrlApp.csproj | 2 - .../StartRouteBuilderUrlApp.csproj | 2 - .../StartWithIApplicationBuilderUrlApp.csproj | 2 - .../Build.RuntimeStore.References.csproj | 4 +- ....AspNetCore.HostingStartup.Template.csproj | 7 +- tools/TrimDeps/TrimDeps.csproj | 5 +- .../dotnet-deb-tool-consumer.csproj | 4 +- 26 files changed, 235 insertions(+), 259 deletions(-) rename appveyor.yml => .appveyor.yml (100%) create mode 100644 Directory.Build.props create mode 100644 Directory.Build.targets delete mode 100644 build/common.props create mode 100644 src/Directory.Build.props create mode 100644 test/Directory.Build.props diff --git a/appveyor.yml b/.appveyor.yml similarity index 100% rename from appveyor.yml rename to .appveyor.yml diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000000..91758478ee --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,16 @@ + + + + + + Microsoft ASP.NET Core + https://github.com/aspnet/MetaPackages + git + false + $(MSBuildThisFileDirectory)build\Key.snk + true + true + $(VersionSuffix)-$(BuildNumber) + true + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000000..f75adf7e4d --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/MetaPackages.sln b/MetaPackages.sln index 2957cc0c6d..838833a98c 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,8 +1,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26727.1 +VisualStudioVersion = 15.0.26730.10 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" + ProjectSection(SolutionItems) = preProject + src\Directory.Build.props = src\Directory.Build.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" EndProject @@ -10,13 +13,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.All", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97D53BEB-A511-4FBE-B784-AB407D9A219F}" ProjectSection(SolutionItems) = preProject + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets NuGet.config = NuGet.config version.xml = version.xml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F92CB7A1-C38E-408C-A7EC-A5C040D041E1}" ProjectSection(SolutionItems) = preProject - build\common.props = build\common.props build\dependencies.props = build\dependencies.props build\repo.targets = build\repo.targets EndProjectSection @@ -26,6 +30,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}" + ProjectSection(SolutionItems) = preProject + test\Directory.Build.props = test\Directory.Build.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.FunctionalTests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}" EndProject diff --git a/build/BuildArchive.proj b/build/BuildArchive.proj index eadad66b41..3d2110bddc 100644 --- a/build/BuildArchive.proj +++ b/build/BuildArchive.proj @@ -1,10 +1,4 @@ - - - - - - - + diff --git a/build/common.props b/build/common.props deleted file mode 100644 index 6203de218d..0000000000 --- a/build/common.props +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - Microsoft ASP.NET Core - https://github.com/aspnet/MetaPackages - git - false - ..\..\build\Key.snk - true - true - $(VersionSuffix) - $(VersionSuffix)-$(BuildNumber) - true - - - $(VersionPrefix)-$(VersionSuffix) - - - - - - - - - - - $(AspNetCoreVersion) - None - - - $(AspNetCoreVersion) - None - - - $(AspNetCoreVersion) - Compile - - - $(AspNetCoreVersion) - None - - - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/dependencies.props b/build/dependencies.props index 20950edc8f..0cb948e13a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,7 +1,9 @@ - + 0.5.0-* 2.1.0-* + + $(VersionPrefix)-$(VersionSuffix) 4.4.0-* 2.0.0-preview2-* 2.1.1-* @@ -12,4 +14,183 @@ 15.3.0 2.3.0-beta4-build3742 + + + + + + $(AspNetCoreVersion) + None + + + $(AspNetCoreVersion) + None + + + $(AspNetCoreVersion) + Compile + + + $(AspNetCoreVersion) + None + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/repo.targets b/build/repo.targets index aa664ebd15..1e11e3a619 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -1,12 +1,11 @@ - - - - - - + + + $(VersionSuffix) + $(VersionSuffix)-$(BuildNumber) + $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ $(MetaPackagePath)Microsoft.AspNetCore.RuntimeStore.csproj diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index 620cf71def..35b28c8284 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 aspnetcore-MetaPackagesSampleApp-20170406180413 diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj index 3d1b205678..5315e09987 100644 --- a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj +++ b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj @@ -1,6 +1,4 @@ - - - + netcoreapp2.0 diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000000..d704a37df9 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index b97348f7db..4b702d4b73 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -1,7 +1,5 @@  - - false netcoreapp2.0 diff --git a/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj b/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj index e8e11b68d6..25dee0572c 100644 --- a/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj +++ b/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj @@ -1,7 +1,5 @@  - - ASP.NET Core Extensions This extension enables additional functionality for ASP.NET Core on Azure WebSites, such as enabling Azure logging. diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj index 0e7105f770..e05f4dba2f 100644 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0 diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index cf888d57ca..508e334cb7 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -1,7 +1,5 @@  - - netstandard2.0 aspnetcore diff --git a/test/Directory.Build.props b/test/Directory.Build.props new file mode 100644 index 0000000000..d704a37df9 --- /dev/null +++ b/test/Directory.Build.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index c8e3826622..131e2ee181 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -1,7 +1,5 @@  - - netcoreapp2.0;net461 netcoreapp2.0 diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj index 65c45e2363..0956c47f07 100644 --- a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj +++ b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj @@ -1,7 +1,5 @@  - - Exe netcoreapp2.0 diff --git a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj index 2124775352..04691e82ed 100644 --- a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj +++ b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj @@ -1,7 +1,5 @@  - - Exe netcoreapp2.0 diff --git a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj index d960839e9f..0c089dbc33 100644 --- a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj +++ b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj @@ -1,7 +1,5 @@  - - Exe netcoreapp2.0 diff --git a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj index d960839e9f..0c089dbc33 100644 --- a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj +++ b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj @@ -1,7 +1,5 @@  - - Exe netcoreapp2.0 diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj index d960839e9f..0c089dbc33 100644 --- a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj +++ b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj @@ -1,7 +1,5 @@  - - Exe netcoreapp2.0 diff --git a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj index cb2a84480e..76f439edf3 100644 --- a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj +++ b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj @@ -2,8 +2,6 @@ - - false netcoreapp2.0 @@ -14,7 +12,7 @@ - + diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj index 021bb290c5..284a46c5ab 100644 --- a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj +++ b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj @@ -1,7 +1,4 @@ - - - - + netcoreapp2.0 @@ -19,6 +16,6 @@ - + diff --git a/tools/TrimDeps/TrimDeps.csproj b/tools/TrimDeps/TrimDeps.csproj index 4ae54603b3..7a4e82dded 100644 --- a/tools/TrimDeps/TrimDeps.csproj +++ b/tools/TrimDeps/TrimDeps.csproj @@ -1,7 +1,4 @@ - - - - + netcoreapp2.0 diff --git a/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj b/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj index 3512a7a21c..db3987ea48 100644 --- a/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj +++ b/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj @@ -1,6 +1,4 @@ - - - + netcoreapp1.0 From ac49fcb7fd9c1301b9dd0268bc4524b240d22555 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 30 Aug 2017 15:15:57 -0700 Subject: [PATCH 247/361] Ensure version information is passed properly into the package cache build --- Directory.Build.props | 2 -- build/dependencies.props | 2 ++ build/repo.props | 2 ++ build/repo.targets | 6 ------ version.xml | 4 ++++ 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 91758478ee..80a2c6569e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,4 @@  - @@ -10,7 +9,6 @@ $(MSBuildThisFileDirectory)build\Key.snk true true - $(VersionSuffix)-$(BuildNumber) true diff --git a/build/dependencies.props b/build/dependencies.props index 0cb948e13a..7a15023f19 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,6 @@  + + 0.5.0-* 2.1.0-* diff --git a/build/repo.props b/build/repo.props index 2e89e8f97a..0f3c67c012 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,6 @@ + + diff --git a/build/repo.targets b/build/repo.targets index 1e11e3a619..4eb7caedd4 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -1,11 +1,5 @@ - - - - $(VersionSuffix) - $(VersionSuffix)-$(BuildNumber) - $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ $(MetaPackagePath)Microsoft.AspNetCore.RuntimeStore.csproj diff --git a/version.xml b/version.xml index 3c05022b7d..88464f4cc3 100644 --- a/version.xml +++ b/version.xml @@ -4,5 +4,9 @@ dev 2.1.0 preview1 + $(VersionSuffix) + $(VersionSuffix)-$(BuildNumber) + $(VersionPrefix) + $(Version)-$(VersionSuffix) From 6c4c13a454e205fb1e484f00dd1069eb263e2f84 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Tue, 5 Sep 2017 14:41:53 -0700 Subject: [PATCH 248/361] Add back Identity service packages to the meta package --- build/dependencies.props | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build/dependencies.props b/build/dependencies.props index 7a15023f19..f0769660d8 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -92,6 +92,7 @@ + @@ -102,6 +103,13 @@ + + + + + + + From 35a714635161e537143a5bebf045913c83b595be Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Thu, 14 Sep 2017 16:24:29 -0700 Subject: [PATCH 249/361] Add Microsoft.Extensions.Hosting (#233) --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index f0769660d8..2621eac410 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -177,6 +177,7 @@ + From d1d934e990145ecc553812e85a656157f562ce40 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 15 Sep 2017 14:27:00 -0700 Subject: [PATCH 250/361] Add Microsoft.AspNetCore.DataProtection.AzureKeyVault package (#234) --- build/dependencies.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.props b/build/dependencies.props index 2621eac410..5b29628c1d 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -88,6 +88,7 @@ + From f8ee044efa885136580b0b80f3db54132620dad3 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 18 Sep 2017 11:01:10 -0700 Subject: [PATCH 251/361] Revert Antares test bundle changes (#220) --- MetaPackages.sln | 12 +---- build/SiteExtension.targets | 27 ---------- build/repo.props | 1 - build/repo.targets | 21 +------- ...NetCore.AzureAppServices.TestBundle.csproj | 51 ------------------- .../applicationHost.xdt | 15 ------ 6 files changed, 3 insertions(+), 124 deletions(-) delete mode 100644 build/SiteExtension.targets delete mode 100644 src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj delete mode 100644 src/Microsoft.AspNetCore.AzureAppServices.TestBundle/applicationHost.xdt diff --git a/MetaPackages.sln b/MetaPackages.sln index 838833a98c..c095b7b5d9 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.10 +VisualStudioVersion = 15.0.26510.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" ProjectSection(SolutionItems) = preProject @@ -50,8 +50,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.AzureAppServices.TestBundle", "src\Microsoft.AspNetCore.AzureAppServices.TestBundle\Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj", "{AE5CCCE0-9AD7-4AB3-B732-FC049766331C}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -98,10 +96,6 @@ Global {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.Build.0 = Release|Any CPU - {AE5CCCE0-9AD7-4AB3-B732-FC049766331C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE5CCCE0-9AD7-4AB3-B732-FC049766331C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE5CCCE0-9AD7-4AB3-B732-FC049766331C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE5CCCE0-9AD7-4AB3-B732-FC049766331C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -119,9 +113,5 @@ Global {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} - {AE5CCCE0-9AD7-4AB3-B732-FC049766331C} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {500600F2-E434-4372-B04D-39CAAADFF973} EndGlobalSection EndGlobal diff --git a/build/SiteExtension.targets b/build/SiteExtension.targets deleted file mode 100644 index 0a40c9ca56..0000000000 --- a/build/SiteExtension.targets +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - $(COHERENCE_SIGNED_DROP_LOCATION)\fallbackArchives\nuGetPackagesArchive-$(TimestampVersion).zip - $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\PackageCache\aspnetcore-store-$(TimestampVersion)-win7-x86.zip - - - - $(TempDir)FallbackArchive - $(TempDir)RuntimeStore - - - - - - - - - \ No newline at end of file diff --git a/build/repo.props b/build/repo.props index 0f3c67c012..c5d1122efe 100644 --- a/build/repo.props +++ b/build/repo.props @@ -4,6 +4,5 @@ - diff --git a/build/repo.targets b/build/repo.targets index 4eb7caedd4..3837b8f554 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -63,8 +63,6 @@ /opt/code/ - - $(FallbackArchiveDir)obj/$(OutputPackageName) $(RepositoryRoot)artifacts\$(OutputPackageName).lzma - $(RepositoryRoot)artifacts\$(OutputPackageName).zip $(FallbackArchiveDir)\obj\$(OutputPackageName).NuGet.config @@ -253,13 +250,7 @@ - - - - - - - + @@ -287,15 +278,7 @@ $(PublishShare)\fallbackArchives - - + diff --git a/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj b/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj deleted file mode 100644 index 25dee0572c..0000000000 --- a/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/Microsoft.AspNetCore.AzureAppServices.TestBundle.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - - ASP.NET Core Extensions - This extension enables additional functionality for ASP.NET Core on Azure WebSites, such as enabling Azure logging. - net461 - false - aspnet;logging;aspnetcore;AzureSiteExtension - AzureSiteExtension - false - false - content - - https://github.com/aspnet/AzureIntegration/blob/rel/2.0.0-preview1/LICENSE.txt - https://go.microsoft.com/fwlink/?LinkID=288859 - https://www.asp.net/ - - - - - - - - - - - - - <_PackageFiles Include="$(DotnetHomeDirectory)\**\*.*" Exclude="$(DotnetHomeDirectory)\sdk\NuGetFallbackFolder\**\*.*;$(DotnetHomeDirectory)\store\**\*.*;$(DotnetHomeDirectory)\additionalDeps\**\*.*" Condition="$(DotnetHomeDirectory) != ''"> - tools\ - false - Content - - - <_PackageFiles Include="$(FallbackArchiveDestination)\**\*.*" Condition="$(FallbackArchiveDestination) != ''"> - tools\sdk\NuGetFallbackFolder\ - false - Content - - - <_PackageFiles Include="$(RuntimeStoreDestination)\**\*.*" Condition="$(RuntimeStoreDestination) != ''"> - tools\ - false - Content - - - - - - - diff --git a/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/applicationHost.xdt b/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/applicationHost.xdt deleted file mode 100644 index 3cb633cdf6..0000000000 --- a/src/Microsoft.AspNetCore.AzureAppServices.TestBundle/applicationHost.xdt +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file From 1d6d6d57c0c0d904875da4f17ca99b8743290c93 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Thu, 21 Sep 2017 17:55:24 -0700 Subject: [PATCH 252/361] Increase Minimum Version of Visual Studio to 15.3.0 --- MetaPackages.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MetaPackages.sln b/MetaPackages.sln index c095b7b5d9..92d267d75c 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26510.0 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" ProjectSection(SolutionItems) = preProject src\Directory.Build.props = src\Directory.Build.props From 07bf8d02a054e37461c8ccf50dc95ee594556c62 Mon Sep 17 00:00:00 2001 From: Fanie Reynders Date: Sun, 11 Jun 2017 19:51:51 +0200 Subject: [PATCH 253/361] Added support for allowing a shorthand notation to build and run a Webhost with the default configuration including a typed Startup class --- src/Microsoft.AspNetCore/WebHost.cs | 35 +++++++++++++++++++ .../CreateDefaultBuilderApp/Program.cs | 5 +++ .../CreateDefaultBuilderApp/Startup.cs | 18 ++++++++++ 3 files changed, 58 insertions(+) create mode 100644 test/TestSites/CreateDefaultBuilderApp/Startup.cs diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 9b576a70fa..99b414104d 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -187,5 +187,40 @@ namespace Microsoft.AspNetCore return builder; } + + /// + /// Initializes a new instance of the class with pre-configured defaults using typed Startup + /// + /// Specify the startup type to be used by the web host. + /// The command line args. + /// + /// The following defaults are applied to the returned : + /// use Kestrel as the web server, + /// set the to the result of , + /// load from 'appsettings.json' and 'appsettings.[].json', + /// load from User Secrets when is 'Development' using the entry assembly, + /// load from environment variables, + /// configures the to log to the console and debug output, + /// enables IIS integration, + /// enables the ability for frameworks to bind their options to their default configuration sections, + /// adds the developer exception page when is 'Development' + /// and sets the startup class as the typed defined in T. + /// + /// The initialized . + public static IWebHostBuilder CreateDefaultBuilder(string[] args) where T : class + { + return WebHost.CreateDefaultBuilder(args) + .UseStartup(); + } + + /// + /// Builds an Microsoft.AspNetCore.Hosting.IWebHost which hosts a web application and + /// runs a web application and block the calling thread until host shutdown. + /// + /// The + public static void BuildAndRun(this IWebHostBuilder builder) + { + builder.Build().Run(); + } } } diff --git a/test/TestSites/CreateDefaultBuilderApp/Program.cs b/test/TestSites/CreateDefaultBuilderApp/Program.cs index ab302e8f96..1585086319 100644 --- a/test/TestSites/CreateDefaultBuilderApp/Program.cs +++ b/test/TestSites/CreateDefaultBuilderApp/Program.cs @@ -36,6 +36,11 @@ namespace CreateDefaultBuilderApp }); }) .Build().Run(); + + Console.ReadKey(); + WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) + .BuildAndRun(); + } private static string GetResponseMessage(WebHostBuilderContext context, IServiceCollection services) diff --git a/test/TestSites/CreateDefaultBuilderApp/Startup.cs b/test/TestSites/CreateDefaultBuilderApp/Startup.cs new file mode 100644 index 0000000000..c44a15ee8c --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderApp/Startup.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; + +namespace CreateDefaultBuilderApp +{ + public class Startup + { + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + app.Run(async (context) => + { + await context.Response.WriteAsync("Hello World!"); + }); + } + } +} From 7ec8cc5fadd14fbe755fb978eedec933f674f887 Mon Sep 17 00:00:00 2001 From: John Luo Date: Thu, 28 Sep 2017 15:58:14 -0700 Subject: [PATCH 254/361] Cleanup and add test for CreateDefaultBuilderOfT --- MetaPackages.sln | 12 +++- src/Microsoft.AspNetCore/WebHost.cs | 27 +++----- .../WebHostFunctionalTests.cs | 27 +++++++- .../CreateDefaultBuilderApp/Program.cs | 11 ---- .../CreateDefaultBuilderApp/Startup.cs | 18 ------ .../CreateDefaultBuilderOfTApp.csproj | 13 ++++ .../CreateDefaultBuilderOfTApp/Program.cs | 14 +++++ .../CreateDefaultBuilderOfTApp/Startup.cs | 63 +++++++++++++++++++ .../appsettings.Development.json | 3 + .../appsettings.json | 3 + 10 files changed, 141 insertions(+), 50 deletions(-) delete mode 100644 test/TestSites/CreateDefaultBuilderApp/Startup.cs create mode 100644 test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj create mode 100644 test/TestSites/CreateDefaultBuilderOfTApp/Program.cs create mode 100644 test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs create mode 100644 test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json create mode 100644 test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json diff --git a/MetaPackages.sln b/MetaPackages.sln index 92d267d75c..cb1e84eea6 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26510.0 +VisualStudioVersion = 15.0.26923.0 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" ProjectSection(SolutionItems) = preProject @@ -50,6 +50,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateDefaultBuilderOfTApp", "test\TestSites\CreateDefaultBuilderOfTApp\CreateDefaultBuilderOfTApp.csproj", "{A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -96,6 +98,10 @@ Global {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.Build.0 = Release|Any CPU + {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -113,5 +119,9 @@ Global {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A666E9B0-125B-4975-B35B-09A6D68A5047} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 99b414104d..8af02eb9ea 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -189,10 +189,8 @@ namespace Microsoft.AspNetCore } /// - /// Initializes a new instance of the class with pre-configured defaults using typed Startup + /// Initializes a new instance of the class with pre-configured defaults using typed Startup. /// - /// Specify the startup type to be used by the web host. - /// The command line args. /// /// The following defaults are applied to the returned : /// use Kestrel as the web server, @@ -200,27 +198,18 @@ namespace Microsoft.AspNetCore /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, + /// load from supplied command line args, /// configures the to log to the console and debug output, /// enables IIS integration, - /// enables the ability for frameworks to bind their options to their default configuration sections, - /// adds the developer exception page when is 'Development' - /// and sets the startup class as the typed defined in T. + /// enables the ability for frameworks to bind their options to their default configuration sections. /// + /// The type containing the startup methods for the application. + /// The command line args. /// The initialized . - public static IWebHostBuilder CreateDefaultBuilder(string[] args) where T : class + public static IWebHostBuilder CreateDefaultBuilder(string[] args) where TStartup : class { - return WebHost.CreateDefaultBuilder(args) - .UseStartup(); - } - - /// - /// Builds an Microsoft.AspNetCore.Hosting.IWebHost which hosts a web application and - /// runs a web application and block the calling thread until host shutdown. - /// - /// The - public static void BuildAndRun(this IWebHostBuilder builder) - { - builder.Build().Run(); + return CreateDefaultBuilder(args) + .UseStartup(); } } } diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index c769193014..385ce19cd4 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Server.IntegrationTesting; -using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; using Xunit; @@ -73,6 +72,32 @@ namespace Microsoft.AspNetCore.Tests }, setTestEnvVars: true); } + [Fact] + public async Task CreateDefaultBuilderOfT_InitializeWithDefaults() + { + var applicationName = "CreateDefaultBuilderOfTApp"; + await ExecuteTestApp(applicationName, async (deploymentResult, logger) => + { + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + + var responseText = await response.Content.ReadAsStringAsync(); + try + { + // Assert server is Kestrel + Assert.Equal("Kestrel", response.Headers.Server.ToString()); + + // The application name will be sent in response when all asserts succeed in the test app. + Assert.Equal(applicationName, responseText); + } + catch (XunitException) + { + logger.LogWarning(response.ToString()); + logger.LogWarning(responseText); + throw; + } + }, setTestEnvVars: true); + } + [Theory] [InlineData("Development", "InvalidOperationException: Cannot consume scoped service")] [InlineData("Production", "Success")] diff --git a/test/TestSites/CreateDefaultBuilderApp/Program.cs b/test/TestSites/CreateDefaultBuilderApp/Program.cs index 1585086319..e8b91c67c0 100644 --- a/test/TestSites/CreateDefaultBuilderApp/Program.cs +++ b/test/TestSites/CreateDefaultBuilderApp/Program.cs @@ -2,18 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Logging.Console; -using Microsoft.Extensions.Logging.Debug; namespace CreateDefaultBuilderApp { @@ -36,11 +30,6 @@ namespace CreateDefaultBuilderApp }); }) .Build().Run(); - - Console.ReadKey(); - WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) - .BuildAndRun(); - } private static string GetResponseMessage(WebHostBuilderContext context, IServiceCollection services) diff --git a/test/TestSites/CreateDefaultBuilderApp/Startup.cs b/test/TestSites/CreateDefaultBuilderApp/Startup.cs deleted file mode 100644 index c44a15ee8c..0000000000 --- a/test/TestSites/CreateDefaultBuilderApp/Startup.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; - -namespace CreateDefaultBuilderApp -{ - public class Startup - { - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) - { - app.Run(async (context) => - { - await context.Response.WriteAsync("Hello World!"); - }); - } - } -} diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj b/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj new file mode 100644 index 0000000000..c73ee499ff --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp2.0 + aspnetcore-CreateDefaultBuilderOfT-20170424224131 + + + + + + + diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs b/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs new file mode 100644 index 0000000000..fbdc90efee --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs @@ -0,0 +1,14 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; + +namespace CreateDefaultBuilderOfTApp +{ + public class Program + { + static void Main(string[] args) => WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) .Build().Run(); + } +} \ No newline at end of file diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs b/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs new file mode 100644 index 0000000000..eb82a20357 --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs @@ -0,0 +1,63 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; + +namespace CreateDefaultBuilderOfTApp +{ + class Startup + { + public void Configure(IApplicationBuilder app, WebHostBuilderContext webHostBuilderContext) + { + app.Run(context => + { + return context.Response.WriteAsync(GetResponseMessage(webHostBuilderContext)); + }); + } + + private static string GetResponseMessage(WebHostBuilderContext context) + { + // Verify ContentRootPath set + if (!string.Equals(Directory.GetCurrentDirectory(), context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) + { + return $"Current directory incorrect. Expected: {Directory.GetCurrentDirectory()} Actual: {context.HostingEnvironment.ContentRootPath}"; + } + + // Verify appsettings.json loaded + if (!string.Equals("settingsValue", context.Configuration["settingsKey"], StringComparison.Ordinal)) + { + return $"appsettings.json not loaded into Configuration."; + } + + // Verify appsettings.environment.json loaded + if (!string.Equals("devSettingsValue", context.Configuration["devSettingsKey"], StringComparison.Ordinal)) + { + return $"appsettings.{context.HostingEnvironment.EnvironmentName}.json not loaded into Configuration."; + } + + // TODO: Verify UserSecrets loaded + + // Verify environment variables loaded + if (!string.Equals("envValue", context.Configuration["envKey"], StringComparison.Ordinal)) + { + return $"Environment variables not loaded into Configuration."; + } + + // Verify command line arguments loaded + if (!string.Equals("cliValue", context.Configuration["cliKey"], StringComparison.Ordinal)) + { + return $"Command line arguments not loaded into Configuration."; + } + + // TODO: Verify AddConsole called + // TODO: Verify AddDebug called + // TODO: Verify UseIISIntegration called + + return context.HostingEnvironment.ApplicationName; + } + } +} diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json new file mode 100644 index 0000000000..d2ccc50d64 --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json @@ -0,0 +1,3 @@ +{ + "devSettingsKey": "devSettingsValue" +} diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json new file mode 100644 index 0000000000..bc5ff92c67 --- /dev/null +++ b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json @@ -0,0 +1,3 @@ +{ + "settingsKey": "settingsValue" +} From 991a3091f6f08242bcd87bdc3843ed174e4d2702 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 5 Oct 2017 15:54:41 -0700 Subject: [PATCH 255/361] Upgrade to xunit 2.3.0-rc3 --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5b29628c1d..85053999f7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -14,7 +14,7 @@ 2.0.0-* 2.0.0-* 15.3.0 - 2.3.0-beta4-build3742 + 2.3.0-rc3-build3818 From a697a68925de8fd80ca714bd4bd253e3dd535576 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 9 Oct 2017 11:40:58 -0700 Subject: [PATCH 256/361] Upgrade xunit to 2.3.0 rtm --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 85053999f7..64bc851be2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -14,7 +14,7 @@ 2.0.0-* 2.0.0-* 15.3.0 - 2.3.0-rc3-build3818 + 2.3.0 From 2d85ae775bff1f02f27984df39ed84ac7b4d30e5 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Wed, 20 Sep 2017 13:21:51 -0700 Subject: [PATCH 257/361] Update bootstrappers --- .appveyor.yml | 4 +- build.cmd | 2 +- build.sh | 197 +------------------------------------- run.cmd | 2 + build.ps1 => run.ps1 | 56 +++++++---- run.sh | 223 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 266 insertions(+), 218 deletions(-) create mode 100644 run.cmd rename build.ps1 => run.ps1 (73%) create mode 100755 run.sh diff --git a/.appveyor.yml b/.appveyor.yml index 4f85bae466..c7b6e34316 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -init: +init: - git config --global core.autocrlf true branches: only: @@ -8,7 +8,7 @@ branches: - /^(.*\/)?ci-.*$/ - /^rel\/.*/ build_script: - - ps: .\build.ps1 + - ps: .\run.ps1 default-build clone_depth: 1 environment: global: diff --git a/build.cmd b/build.cmd index b6c8d24864..c0050bda12 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ @ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE" +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh index 11cdbe5504..98a4b22765 100755 --- a/build.sh +++ b/build.sh @@ -1,199 +1,8 @@ #!/usr/bin/env bash set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -MAGENTA="\033[0;95m" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -config_file="$DIR/version.xml" -verbose=false -update=false -repo_path="$DIR" -channel='' -tools_source='' -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " ... Arguments passed to MSBuild. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file TThe path to the configuration file that stores values. Defaults to version.xml." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo "" - echo "Description:" - 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." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}$*${RESET}" 1>&2 -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;} - -# -# main -# - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -if [ -f "$config_file" ]; then - comment=false - while __read_dom; do - if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi - if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi - if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi - if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi - done < "$config_file" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -install_tools "$tools_source" "$DOTNET_HOME" -invoke_repository_build "$repo_path" "$@" +# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) +chmod +x "$DIR/run.sh"; sync +"$DIR/run.sh" default-build "$@" diff --git a/run.cmd b/run.cmd new file mode 100644 index 0000000000..d52d5c7e68 --- /dev/null +++ b/run.cmd @@ -0,0 +1,2 @@ +@ECHO OFF +PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/build.ps1 b/run.ps1 similarity index 73% rename from build.ps1 rename to run.ps1 index d5eb4d5cf2..49c2899856 100644 --- a/build.ps1 +++ b/run.ps1 @@ -3,10 +3,13 @@ <# .SYNOPSIS -Build this repository +Executes KoreBuild commands. .DESCRIPTION -Downloads korebuild if required. Then builds the repository. +Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. + +.PARAMETER Command +The KoreBuild command to run. .PARAMETER Path The folder to build. Defaults to the folder containing this script. @@ -24,31 +27,32 @@ The base url where build tools can be downloaded. Overrides the value from the c Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to version.xml. +The path to the configuration file that stores values. Defaults to korebuild.json. -.PARAMETER MSBuildArgs -Arguments to be passed to MSBuild +.PARAMETER Arguments +Arguments to be passed to the command .NOTES This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. -The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well. +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 +in the file are overridden by command line parameters. .EXAMPLE Example config file: -```xml - - - - dev - https://aspnetcore.blob.core.windows.net/buildtools - - +```json +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev", + "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" +} ``` #> [CmdletBinding(PositionalBinding = $false)] param( + [Parameter(Mandatory=$true, Position = 0)] + [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] [string]$Channel, @@ -58,9 +62,9 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'), + [string]$ConfigFile, [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$MSBuildArgs + [string[]]$Arguments ) Set-StrictMode -Version 2 @@ -147,10 +151,20 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { # Load configuration or set defaults +$Path = Resolve-Path $Path +if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } + if (Test-Path $ConfigFile) { - [xml] $config = Get-Content $ConfigFile - if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' } - if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' } + try { + $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json + if ($config) { + if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } + if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} + } + } catch { + Write-Warning "$ConfigFile could not be read. Its settings will be ignored." + Write-Warning $Error[0] + } } if (!$DotNetHome) { @@ -169,8 +183,8 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Install-Tools $ToolsSource $DotNetHome - Invoke-RepositoryBuild $Path @MSBuildArgs + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Invoke-KoreBuildCommand $Command @Arguments } finally { Remove-Module 'KoreBuild' -ErrorAction Ignore diff --git a/run.sh b/run.sh new file mode 100755 index 0000000000..c278423acc --- /dev/null +++ b/run.sh @@ -0,0 +1,223 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# +# variables +# + +RESET="\033[0m" +RED="\033[0;31m" +YELLOW="\033[0;33m" +MAGENTA="\033[0;95m" +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" +verbose=false +update=false +repo_path="$DIR" +channel='' +tools_source='' + +# +# Functions +# +__usage() { + echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" + echo "" + echo "Arguments:" + echo " command The command to be run." + echo " ... Arguments passed to the command. Variable number of arguments allowed." + echo "" + echo "Options:" + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo "" + echo "Description:" + 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." + echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." + + if [[ "${1:-}" != '--no-exit' ]]; then + exit 2 + fi +} + +get_korebuild() { + local version + local lock_file="$repo_path/korebuild-lock.txt" + if [ ! -f "$lock_file" ] || [ "$update" = true ]; then + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + fi + version="$(grep 'version:*' -m 1 "$lock_file")" + if [[ "$version" == '' ]]; then + __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" + return 1 + fi + version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + + { + if [ ! -d "$korebuild_path" ]; then + mkdir -p "$korebuild_path" + local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" + tmpfile="$(mktemp)" + echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" + if __get_remote_file "$remote_path" "$tmpfile"; then + unzip -q -d "$korebuild_path" "$tmpfile" + fi + rm "$tmpfile" || true + fi + + source "$korebuild_path/KoreBuild.sh" + } || { + if [ -d "$korebuild_path" ]; then + echo "Cleaning up after failed installation" + rm -rf "$korebuild_path" || true + fi + return 1 + } +} + +__error() { + echo -e "${RED}error: $*${RESET}" 1>&2 +} + +__warn() { + echo -e "${YELLOW}warning: $*${RESET}" +} + +__machine_has() { + hash "$1" > /dev/null 2>&1 + return $? +} + +__get_remote_file() { + local remote_path=$1 + local local_path=$2 + + if [[ "$remote_path" != 'http'* ]]; then + cp "$remote_path" "$local_path" + return 0 + fi + + local failed=false + if __machine_has wget; then + wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + else + failed=true + fi + + if [ "$failed" = true ] && __machine_has curl; then + failed=false + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + fi + + if [ "$failed" = true ]; then + __error "Download failed: $remote_path" 1>&2 + return 1 + fi +} + +# +# main +# + +command="${1:-}" +shift + +while [[ $# -gt 0 ]]; do + case $1 in + -\?|-h|--help) + __usage --no-exit + exit 0 + ;; + -c|--channel|-Channel) + shift + channel="${1:-}" + [ -z "$channel" ] && __usage + ;; + --config-file|-ConfigFile) + shift + config_file="${1:-}" + [ -z "$config_file" ] && __usage + if [ ! -f "$config_file" ]; then + __error "Invalid value for --config-file. $config_file does not exist." + exit 1 + fi + ;; + -d|--dotnet-home|-DotNetHome) + shift + DOTNET_HOME="${1:-}" + [ -z "$DOTNET_HOME" ] && __usage + ;; + --path|-Path) + shift + repo_path="${1:-}" + [ -z "$repo_path" ] && __usage + ;; + -s|--tools-source|-ToolsSource) + shift + tools_source="${1:-}" + [ -z "$tools_source" ] && __usage + ;; + -u|--update|-Update) + update=true + ;; + --verbose|-Verbose) + verbose=true + ;; + --) + shift + break + ;; + *) + break + ;; + esac + shift +done + +if ! __machine_has unzip; then + __error 'Missing required command: unzip' + exit 1 +fi + +if ! __machine_has curl && ! __machine_has wget; then + __error 'Missing required command. Either wget or curl is required.' + exit 1 +fi + +[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" +if [ -f "$config_file" ]; then + if __machine_has jq ; then + if jq '.' "$config_file" >/dev/null ; then + config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" + config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + elif __machine_has python ; then + if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + 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 '')")" + 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 '')")" + else + __warn "$config_file is invalid JSON. Its settings will be ignored." + fi + else + __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + fi + + [ ! -z "${config_channel:-}" ] && channel="$config_channel" + [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" +fi + +[ -z "$channel" ] && channel='dev' +[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' + +get_korebuild +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +invoke_korebuild_command "$command" "$@" From 633cb681493c0958a9d215624c173db29e20c23d Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 9 Oct 2017 11:03:48 -0700 Subject: [PATCH 258/361] Populate WebHost configuration with command line arguments if provided --- MetaPackages.sln | 12 ++++++++---- samples/SampleApp/Program.cs | 1 - src/Microsoft.AspNetCore/WebHost.cs | 12 +++++++----- .../Microsoft.AspNetCore.Tests.csproj | 16 ++++++++++++++++ .../Microsoft.AspNetCore.Tests/WebHostTests.cs | 18 ++++++++++++++++++ 5 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj create mode 100644 test/Microsoft.AspNetCore.Tests/WebHostTests.cs diff --git a/MetaPackages.sln b/MetaPackages.sln index cb1e84eea6..3a53e49bdd 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26923.0 +VisualStudioVersion = 15.0.27005.2 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C3-4ADE-ACC8-6BA6D4207C09}" ProjectSection(SolutionItems) = preProject @@ -30,9 +30,6 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "samples\SampleApp\SampleApp.csproj", "{AF5BB04E-92F7-4737-8B98-F86F6244FAB2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C}" - ProjectSection(SolutionItems) = preProject - test\Directory.Build.props = test\Directory.Build.props - EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.FunctionalTests", "test\Microsoft.AspNetCore.FunctionalTests\Microsoft.AspNetCore.FunctionalTests.csproj", "{C72A756A-D29D-44C7-83D4-821DBE82DBCA}" EndProject @@ -52,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "t EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateDefaultBuilderOfTApp", "test\TestSites\CreateDefaultBuilderOfTApp\CreateDefaultBuilderOfTApp.csproj", "{A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Tests", "test\Microsoft.AspNetCore.Tests\Microsoft.AspNetCore.Tests.csproj", "{BD08F027-3BB9-427B-9367-19534B7376B3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -102,6 +101,10 @@ Global {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Release|Any CPU.ActiveCfg = Release|Any CPU {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}.Release|Any CPU.Build.0 = Release|Any CPU + {BD08F027-3BB9-427B-9367-19534B7376B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD08F027-3BB9-427B-9367-19534B7376B3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD08F027-3BB9-427B-9367-19534B7376B3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD08F027-3BB9-427B-9367-19534B7376B3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -120,6 +123,7 @@ Global {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} + {BD08F027-3BB9-427B-9367-19534B7376B3} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A666E9B0-125B-4975-B35B-09A6D68A5047} diff --git a/samples/SampleApp/Program.cs b/samples/SampleApp/Program.cs index 9e3da42b41..b5eb900273 100644 --- a/samples/SampleApp/Program.cs +++ b/samples/SampleApp/Program.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 8af02eb9ea..df3b91d75b 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -185,6 +185,11 @@ namespace Microsoft.AspNetCore options.ValidateScopes = context.HostingEnvironment.IsDevelopment(); }); + if (args != null) + { + builder.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build()); + } + return builder; } @@ -206,10 +211,7 @@ namespace Microsoft.AspNetCore /// The type containing the startup methods for the application. /// The command line args. /// The initialized . - public static IWebHostBuilder CreateDefaultBuilder(string[] args) where TStartup : class - { - return CreateDefaultBuilder(args) - .UseStartup(); - } + public static IWebHostBuilder CreateDefaultBuilder(string[] args) where TStartup : class => + CreateDefaultBuilder(args).UseStartup(); } } diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj new file mode 100644 index 0000000000..7da44ee745 --- /dev/null +++ b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj @@ -0,0 +1,16 @@ + + + + netcoreapp2.0;net461 + netcoreapp2.0 + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Tests/WebHostTests.cs b/test/Microsoft.AspNetCore.Tests/WebHostTests.cs new file mode 100644 index 0000000000..27f98263f5 --- /dev/null +++ b/test/Microsoft.AspNetCore.Tests/WebHostTests.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNetCore.Hosting; +using Xunit; + +namespace Microsoft.AspNetCore.Tests +{ + public class WebHostTests + { + [Fact] + public void WebHostConfiguration_IncludesCommandLineArguments() + { + var builder = WebHost.CreateDefaultBuilder(new string[] { "--urls", "http://localhost:5001" }); + Assert.Equal("http://localhost:5001", builder.GetSetting(WebHostDefaults.ServerUrlsKey)); + } + } +} From fcdd25635c8174a0c8a7a0853a6f3d8620448839 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Oct 2017 12:51:10 -0700 Subject: [PATCH 259/361] Add RepositoryRoot --- Directory.Build.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 80a2c6569e..787f9a83f8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,11 @@ - + Microsoft ASP.NET Core https://github.com/aspnet/MetaPackages git + $(MSBuildThisFileDirectory) false $(MSBuildThisFileDirectory)build\Key.snk true From b49ffc9e9e05d0eead4a5220375dd3ca76040e24 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 25 Oct 2017 17:39:32 -0700 Subject: [PATCH 260/361] Remove All metapackage and runtime store infrastructure (#244) --- MetaPackages.sln | 15 - build/BuildArchive.proj | 13 - build/dependencies.props | 189 ---- build/repo.props | 5 - build/repo.targets | 970 ------------------ build/tasks/CreateCommonManifest.cs | 67 -- build/tasks/RepoTasks.csproj | 10 - build/tasks/RepoTasks.tasks | 3 - .../Archive.AspNetCore.All.csproj | 24 - .../Microsoft.AspNetCore.All.csproj | 23 - ...ublishWithAspNetCoreTargetManifest.targets | 29 - .../Microsoft.AspNetCore.All.targets | 3 - .../lib/netcoreapp2.0/_._ | 0 .../Microsoft.AspNetCore.RuntimeStore.csproj | 10 - .../Microsoft.AspNetCore.csproj | 16 +- .../Build.RuntimeStore.References.csproj | 20 - ....AspNetCore.HostingStartup.Template.csproj | 21 - .../Program.cs | 7 - tools/TrimDeps/Program.cs | 47 - tools/TrimDeps/TrimDeps.csproj | 12 - tools/docker/debian.8/Dockerfile | 51 - tools/docker/rhel.7/Dockerfile | 27 - tools/docker/ubuntu.14.04/Dockerfile | 52 - tools/docker/ubuntu.16.04/Dockerfile | 48 - tools/docker/ubuntu.16.10/Dockerfile | 52 - tools/dotnet-deb-tool-consumer/NuGet.config | 6 - .../dotnet-deb-tool-consumer.csproj | 11 - tools/packaging/changelog | 2 - tools/packaging/hosting_debian_config.json | 35 - tools/packaging/store_debian_config.json | 30 - tools/scripts/GetSharedFrameworkVersion.ps1 | 6 - tools/scripts/GetSharedFrameworkVersion.sh | 2 - tools/scripts/TestInstallers.sh | 77 -- tools/scripts/zip2tgz.sh | 31 - 34 files changed, 15 insertions(+), 1899 deletions(-) delete mode 100644 build/BuildArchive.proj delete mode 100644 build/repo.targets delete mode 100644 build/tasks/CreateCommonManifest.cs delete mode 100644 build/tasks/RepoTasks.csproj delete mode 100644 build/tasks/RepoTasks.tasks delete mode 100644 src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj delete mode 100644 src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj delete mode 100644 src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets delete mode 100644 src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets delete mode 100644 src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ delete mode 100644 src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj delete mode 100644 tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj delete mode 100644 tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj delete mode 100644 tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs delete mode 100644 tools/TrimDeps/Program.cs delete mode 100644 tools/TrimDeps/TrimDeps.csproj delete mode 100644 tools/docker/debian.8/Dockerfile delete mode 100644 tools/docker/rhel.7/Dockerfile delete mode 100644 tools/docker/ubuntu.14.04/Dockerfile delete mode 100644 tools/docker/ubuntu.16.04/Dockerfile delete mode 100644 tools/docker/ubuntu.16.10/Dockerfile delete mode 100644 tools/dotnet-deb-tool-consumer/NuGet.config delete mode 100644 tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj delete mode 100644 tools/packaging/changelog delete mode 100644 tools/packaging/hosting_debian_config.json delete mode 100644 tools/packaging/store_debian_config.json delete mode 100644 tools/scripts/GetSharedFrameworkVersion.ps1 delete mode 100755 tools/scripts/GetSharedFrameworkVersion.sh delete mode 100755 tools/scripts/TestInstallers.sh delete mode 100755 tools/scripts/zip2tgz.sh diff --git a/MetaPackages.sln b/MetaPackages.sln index 3a53e49bdd..659427dfcb 100644 --- a/MetaPackages.sln +++ b/MetaPackages.sln @@ -9,8 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{ED834E68-51C EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore", "src\Microsoft.AspNetCore\Microsoft.AspNetCore.csproj", "{6F3D43F7-9546-4B41-AF04-CF4708B62051}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.All", "src\Microsoft.AspNetCore.All\Microsoft.AspNetCore.All.csproj", "{CC8F551E-213A-45E8-AECA-507C4DB4F164}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{97D53BEB-A511-4FBE-B784-AB407D9A219F}" ProjectSection(SolutionItems) = preProject Directory.Build.props = Directory.Build.props @@ -43,8 +41,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartRequestDelegateUrlApp" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateDefaultBuilderApp", "test\TestSites\CreateDefaultBuilderApp\CreateDefaultBuilderApp.csproj", "{79CF58CE-B020-45D8-BDB5-2D8036BEAD14}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TrimDeps", "tools\TrimDeps\TrimDeps.csproj", "{67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DependencyInjectionApp", "test\TestSites\DependencyInjectionApp\DependencyInjectionApp.csproj", "{65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateDefaultBuilderOfTApp", "test\TestSites\CreateDefaultBuilderOfTApp\CreateDefaultBuilderOfTApp.csproj", "{A922B5AC-836B-44F4-83F1-3CB9EB08A3F8}" @@ -61,10 +57,6 @@ Global {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Debug|Any CPU.Build.0 = Debug|Any CPU {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.ActiveCfg = Release|Any CPU {6F3D43F7-9546-4B41-AF04-CF4708B62051}.Release|Any CPU.Build.0 = Release|Any CPU - {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC8F551E-213A-45E8-AECA-507C4DB4F164}.Release|Any CPU.Build.0 = Release|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF5BB04E-92F7-4737-8B98-F86F6244FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -89,10 +81,6 @@ Global {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Debug|Any CPU.Build.0 = Debug|Any CPU {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.ActiveCfg = Release|Any CPU {79CF58CE-B020-45D8-BDB5-2D8036BEAD14}.Release|Any CPU.Build.0 = Release|Any CPU - {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Debug|Any CPU.Build.0 = Debug|Any CPU - {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.ActiveCfg = Release|Any CPU - {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82}.Release|Any CPU.Build.0 = Release|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -111,8 +99,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {6F3D43F7-9546-4B41-AF04-CF4708B62051} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} - {CC8F551E-213A-45E8-AECA-507C4DB4F164} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} - {F92CB7A1-C38E-408C-A7EC-A5C040D041E1} = {97D53BEB-A511-4FBE-B784-AB407D9A219F} {AF5BB04E-92F7-4737-8B98-F86F6244FAB2} = {192F583C-C4CA-43E5-B31C-D21B7806E274} {C72A756A-D29D-44C7-83D4-821DBE82DBCA} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} @@ -120,7 +106,6 @@ Global {3A85FA52-F601-422E-A42E-9F187DB28492} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {401C741B-6C7C-4E08-9F09-C3D43D22C0DE} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {79CF58CE-B020-45D8-BDB5-2D8036BEAD14} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} - {67E4C92F-6D12-4C52-BB79-B8D11BFC6B82} = {ED834E68-51C3-4ADE-ACC8-6BA6D4207C09} {65FE2E38-4529-4C93-A7B0-CF12DD7A70C3} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {A922B5AC-836B-44F4-83F1-3CB9EB08A3F8} = {EC22261D-0DE1-47DE-8F7C-072675D6F5B4} {BD08F027-3BB9-427B-9367-19534B7376B3} = {9E49B5B9-9E72-42FB-B684-90CA1B1BCF9C} diff --git a/build/BuildArchive.proj b/build/BuildArchive.proj deleted file mode 100644 index 3d2110bddc..0000000000 --- a/build/BuildArchive.proj +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/build/dependencies.props b/build/dependencies.props index 64bc851be2..4dfc6e6b11 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,7 +5,6 @@ 0.5.0-* 2.1.0-* - $(VersionPrefix)-$(VersionSuffix) 4.4.0-* 2.0.0-preview2-* 2.1.1-* @@ -17,192 +16,4 @@ 2.3.0 - - - - - $(AspNetCoreVersion) - None - - - $(AspNetCoreVersion) - None - - - $(AspNetCoreVersion) - Compile - - - $(AspNetCoreVersion) - None - - - None - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/repo.props b/build/repo.props index c5d1122efe..39ccbe3845 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,8 +1,3 @@ - - - - - diff --git a/build/repo.targets b/build/repo.targets deleted file mode 100644 index 3837b8f554..0000000000 --- a/build/repo.targets +++ /dev/null @@ -1,970 +0,0 @@ - - - - $(RepositoryRoot)src\Microsoft.AspNetCore.RuntimeStore\ - $(MetaPackagePath)Microsoft.AspNetCore.RuntimeStore.csproj - - $(RepositoryRoot)tools\Microsoft.AspNetCore.HostingStartup.Template\ - $(HostingStartupTemplatePath)Microsoft.AspNetCore.HostingStartup.Template.csproj - - - $(RepositoryRoot)src\Archive.AspNetCore.All\ - $(FallbackArchiveDir)Archive.AspNetCore.All.csproj - - - $(TIMESTAMP_FREE_VERSION) - final - - $(VersionPrefix)-$(OriginalVersionSuffix)-$(NoTimestampSuffix) - $(VersionPrefix) - $(VersionPrefix)-$(OriginalVersionSuffix)-$(BuildNumber) - - aspnetcore-store-$(TimestampVersion) - aspnetcore-store-$(NoTimestampVersion) - dotnet-hosting-$(TimestampVersion) - dotnet-hosting-$(NoTimestampVersion) - - $(RepositoryRoot).rw\ - $(RepositoryRoot).ro\ - $(RepositoryRoot)artifacts\ - $(ArtifactsDir)dotnetInstallers\ - $(ArtifactsDir)zip\ - $(ArtifactsDir)deps\ - $(ArtifactsZipDir)t\ - $(ArtifactsZipDir)n\ - $(ArtifactsZipDir)st\ - $(ArtifactsZipDir)sn\ - $(ArtifactsDir)installers\ - $(ArtifactsDir)rsArchive\ - $(ArtifactsDir)StoreTimestampLayout\ - $(RuntimeStoreInstallerLayoutTimestampDirectory)package_root\ - $(ArtifactsDir)StoreTimestampOutput\ - $(ArtifactsDir)StoreNoTimestampLayout\ - $(RuntimeStoreInstallerLayoutNoTimestampDirectory)package_root\ - $(ArtifactsDir)StoreNoTimestampOutput\ - $(ArtifactsDir)HostingTimestampLayout\ - $(HostingBundleInstallerLayoutTimestampDirectory)package_root\ - $(ArtifactsDir)HostingTimestampOutput\ - $(ArtifactsDir)HostingNoTimestampLayout\ - $(HostingBundleInstallerLayoutNoTimestampDirectory)package_root\ - $(ArtifactsDir)HostingNoTimestampOutput\ - $(ArtifactsDir)temp\ - $(RepositoryRoot)tools\ - $(ToolsDir)packaging\ - $(ToolsDir)scripts\ - $(ToolsDir)docker\ - $(RepositoryRoot).deps\build\ - $(ToolsDir)Build.RuntimeStore.References\ - $(RuntimeStoreReferenceDirectory)bin\Release\ - $(PackagingDir)store_debian_config.json - $(PackagingDir)hosting_debian_config.json - $(PackagingDir)changelog - $(ToolsDir)dotnet-deb-tool-consumer\ - /opt/code/ - - - - - - - - - - - - - - - - - - - win7-$(PACKAGE_CACHE_PLATFORM) - linux-$(PACKAGE_CACHE_PLATFORM) - osx-$(PACKAGE_CACHE_PLATFORM) - - $(ArtifactsDir)aspnetcore-store-$(TimestampVersion)-$(RID).zip - $(ArtifactsDir)aspnetcore-store-$(NoTimestampVersion)-$(RID).zip - $(ArtifactsDir)aspnetcore-symbols-$(TimestampVersion)-$(RID).zip - $(ArtifactsDir)aspnetcore-symbols-$(NoTimestampVersion)-$(RID).zip - $(ArtifactsDir)aspnetcore-symbols-$(TimestampVersion)-$(RID).tar.gz - $(ArtifactsDir)aspnetcore-symbols-$(NoTimestampVersion)-$(RID).tar.gz - - - - - - - - - - - - - - - - - - - - - - - - aspnetcore-store-$(TimestampVersion)-$(RID).xml - - <_RuntimeStoreFiles Include="$(RuntimeStoreOutputPath)**\*" Exclude="$(RuntimeStoreOutputPath)**\artifact.xml;$(RuntimeStoreOutputPath)symbols\**\*" /> - - $([System.String]::new('%(RecursiveDir)').Replace('$(TimestampVersion)', '$(NoTimestampVersion)')) - - <_RuntimeStoreSymbolFiles Include="$(RuntimeStoreOutputPath)symbols\**\*" /> - - $([System.String]::new('%(RecursiveDir)').Replace('$(TimestampVersion)', '$(NoTimestampVersion)')) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - aspnetcore-store-$(TimestampVersion)-common.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(DotnetHomeDirectory)shared\Microsoft.NETCore.App\$(SharedFrameworkVersion) - - - - - - - - - - - - - - - - - - - - - - - - - $(FallbackArchiveDir)obj/$(OutputPackageName) - $(RepositoryRoot)artifacts\$(OutputPackageName).lzma - $(FallbackArchiveDir)\obj\$(OutputPackageName).NuGet.config - - - - - - - - - - - - - - - - - - - - - - - - - $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages-NoTimeStamp - $(COHERENCE_SIGNED_DROP_LOCATION)\Signed\Packages - nuGetPackagesArchive-$(NoTimestampVersion) - nuGetPackagesArchive-$(TimestampVersion) - - - - - - - - - - - $(PublishShare)\fallbackArchives - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://dotnetcli.azureedge.net/dotnet/Runtime/$(SharedFrameworkVersion)/dotnet-host-$(SharedFrameworkVersion) - http://dotnetcli.azureedge.net/dotnet/Runtime/$(SharedFrameworkVersion)/dotnet-hostfxr-$(SharedFrameworkVersion) - http://dotnetcli.azureedge.net/dotnet/Runtime/$(SharedFrameworkVersion)/dotnet-runtime-$(SharedFrameworkVersion) - http://dotnetcli.azureedge.net/dotnet/Runtime/$(SharedFrameworkVersion)/dotnet-runtime-$(SharedFrameworkVersion)-linux-x64.tar.gz - - - - - - - - - - - - - - - - - - - - - - - - $(HostingBundleTimestampInstallerPackageName)-linux-$(PACKAGE_CACHE_PLATFORM).tar.gz - $(HostingBundleNoTimestampInstallerPackageName)-linux-$(PACKAGE_CACHE_PLATFORM).tar.gz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @(_StoreInstallerSummary) - @(_StoreInstallerDescription) - @(_StoreInstallerLicense) - @(_StoreInstallerPackageRevision) - @(_StoreInstallerHomepage) - @(_StoreInstallerMaintainerName) - @(_StoreInstallerMaintainerEmail) - @(_HostingInstallerSummary) - @(_HostingInstallerDescription) - @(_HostingInstallerLicense) - @(_HostingInstallerPackageRevision) - @(_HostingInstallerHomepage) - @(_HostingInstallerMaintainerName) - @(_HostingInstallerMaintainerEmail) - /opt/rh/rh-dotnet20/root/usr/lib64/dotnet/ - @(RHStoreDirectories->' --directories "%(FullPath)"', ' ') - /usr/share/dotnet/ - @(GeneralStoreDirectories->' --directories "%(FullPath)"', ' ') - - - - - - - - - - - - - - - - $(RuntimeStoreTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm - $(RuntimeStoreNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm - $(HostingBundleTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm - $(HostingBundleNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).rpm - $(StoreInstallerMaintainerName) <$(StoreInstallerMaintainerEmail)> - $(HostingInstallerMaintainerName) <$(HostingInstallerMaintainerEmail)> - .NET Foundation - - - - - - - - - - - - - - - - - $(TimestampVersion) - - - $(SharedFrameworkVersion) - - - $(NoTimestampVersion) - - - $(SharedFrameworkVersion) - - - - - @(HostingBundleTimestampDependencies->' -d "%(Identity) >= %(Version)"', ' ') - @(HostingBundleNoTimestampDependencies->' -d "%(Identity) >= %(Version)"', ' ') - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(RuntimeStoreTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb - $(RuntimeStoreNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb - $(HostingBundleTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb - $(HostingBundleNoTimestampInstallerPackageName)-$(InstallerPlatform)-$(PACKAGE_CACHE_PLATFORM).deb - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/tasks/CreateCommonManifest.cs b/build/tasks/CreateCommonManifest.cs deleted file mode 100644 index 4125bbccae..0000000000 --- a/build/tasks/CreateCommonManifest.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Xml; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; - -namespace RepoTasks -{ - /// - /// Creates a common manifest file used for trimming publish output given a list of packages and package definitions containing their versions. - /// - public class CreateCommonManifest : Task - { - /// - /// The path for the common manifest file to be created. - /// - /// - [Required] - public string DestinationFilePath { get; set; } - - /// - /// The packages to include in the common manifest file. - /// - /// - [Required] - public ITaskItem[] Packages { get; set; } - - /// - /// The package definitions used for resolving package versions. - /// - /// - [Required] - public ITaskItem[] PackageDefinitions { get; set; } - - public override bool Execute() - { - var xmlDoc = new XmlDocument(); - var packagesElement = xmlDoc.CreateElement("StoreArtifacts"); - - foreach (var package in Packages) - { - var packageName = package.ItemSpec; - var packageElement = xmlDoc.CreateElement("Package"); - - var idAttribute = xmlDoc.CreateAttribute("Id"); - idAttribute.Value = packageName; - packageElement.Attributes.Append(idAttribute); - - var versionAttribute = xmlDoc.CreateAttribute("Version"); - versionAttribute.Value = PackageDefinitions - .Where(p => string.Equals(p.GetMetadata("Name"), packageName, StringComparison.OrdinalIgnoreCase)) - .Select(p => p.GetMetadata("Version")).Single(); - packageElement.Attributes.Append(versionAttribute); - - packagesElement.AppendChild(packageElement); - } - - xmlDoc.AppendChild(packagesElement); - xmlDoc.Save(DestinationFilePath); - - return true; - } - } -} diff --git a/build/tasks/RepoTasks.csproj b/build/tasks/RepoTasks.csproj deleted file mode 100644 index 8457d61d39..0000000000 --- a/build/tasks/RepoTasks.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - - netcoreapp2.0 - 2.0.0-* - - - - diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks deleted file mode 100644 index 5de9828888..0000000000 --- a/build/tasks/RepoTasks.tasks +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj b/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj deleted file mode 100644 index 5315e09987..0000000000 --- a/src/Archive.AspNetCore.All/Archive.AspNetCore.All.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - netcoreapp2.0 - false - netcoreapp2.0 - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj deleted file mode 100644 index 4b702d4b73..0000000000 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - false - netcoreapp2.0 - aspnetcore - Microsoft.AspNetCore.All - false - - - - - - - - - - - - - - - diff --git a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets b/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets deleted file mode 100644 index a590cf01f1..0000000000 --- a/src/Microsoft.AspNetCore.All/build/PublishWithAspNetCoreTargetManifest.targets +++ /dev/null @@ -1,29 +0,0 @@ - - - true - - - - - - - - - - - - - $(TargetManifestFiles);@(AspNetCoreTargetManifestFiles) - - - diff --git a/src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets b/src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets deleted file mode 100644 index 0bed51f606..0000000000 --- a/src/Microsoft.AspNetCore.All/build/netcoreapp2.0/Microsoft.AspNetCore.All.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ b/src/Microsoft.AspNetCore.All/lib/netcoreapp2.0/_._ deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj b/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj deleted file mode 100644 index e05f4dba2f..0000000000 --- a/src/Microsoft.AspNetCore.RuntimeStore/Microsoft.AspNetCore.RuntimeStore.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - netcoreapp2.0 - - - - - - diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 508e334cb7..f7d0f3ba81 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -9,7 +9,21 @@ - + + + + + + + + + + + + + + + diff --git a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj deleted file mode 100644 index 76f439edf3..0000000000 --- a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - false - netcoreapp2.0 - - - - - - - - - - - - - diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj b/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj deleted file mode 100644 index 284a46c5ab..0000000000 --- a/tools/Microsoft.AspNetCore.HostingStartup.Template/Microsoft.AspNetCore.HostingStartup.Template.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netcoreapp2.0 - Exe - - - - - - - - - $(RuntimeFrameworkVersion) - $(DepsOutputPath)\$(HostingStartupPackageName)\shared\Microsoft.NETCore.App\$(DepsRuntimeFrameworkVersion)\$(HostingStartupPackageName).deps.json - - - - - - diff --git a/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs b/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs deleted file mode 100644 index 8cd3c0026c..0000000000 --- a/tools/Microsoft.AspNetCore.HostingStartup.Template/Program.cs +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -public class Program -{ - public static void Main() { } -} \ No newline at end of file diff --git a/tools/TrimDeps/Program.cs b/tools/TrimDeps/Program.cs deleted file mode 100644 index f318230425..0000000000 --- a/tools/TrimDeps/Program.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.IO; -using System.Linq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -public class Program -{ - public static void Main(string[] args) - { - Console.WriteLine("Trimming main library from " +args[0]); - ChangeEntryPointLibraryName(args[0]); - } - - private static void ChangeEntryPointLibraryName(string depsFile) - { - JToken deps; - using (var file = File.OpenText(depsFile)) - using (JsonTextReader reader = new JsonTextReader(file)) - { - deps = JObject.ReadFrom(reader); - } - - foreach (JProperty target in deps["targets"]) - { - var targetLibrary = target.Value.Children().FirstOrDefault(); - if (targetLibrary == null) - { - continue; - } - - targetLibrary.Remove(); - } - - var library = deps["libraries"].Children().First(); - library.Remove(); - - using (var file = File.CreateText(depsFile)) - using (var writer = new JsonTextWriter(file) { Formatting = Formatting.Indented }) - { - deps.WriteTo(writer); - } - } -} diff --git a/tools/TrimDeps/TrimDeps.csproj b/tools/TrimDeps/TrimDeps.csproj deleted file mode 100644 index 7a4e82dded..0000000000 --- a/tools/TrimDeps/TrimDeps.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - netcoreapp2.0 - Exe - - - - - - - diff --git a/tools/docker/debian.8/Dockerfile b/tools/docker/debian.8/Dockerfile deleted file mode 100644 index 0c032b9d7f..0000000000 --- a/tools/docker/debian.8/Dockerfile +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) .NET Foundation. All rights reserved. -# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -# - -# Dockerfile that creates a container suitable to build dotnet-cli -FROM debian:jessie - -# Misc Dependencies for build -RUN apt-get update && \ - apt-get -qqy install \ - curl \ - unzip \ - gettext \ - sudo \ - libunwind8 \ - libkrb5-3 \ - libicu52 \ - liblttng-ust0 \ - libssl1.0.0 \ - zlib1g \ - libuuid1 \ - debhelper \ - build-essential \ - devscripts \ - git \ - cmake \ - clang-3.5 \ - wget && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Use clang as c++ compiler -RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100 -RUN update-alternatives --set c++ /usr/bin/clang++-3.5 - -# Setup User to match Host User, and give superuser permissions -ARG USER_ID=0 -RUN useradd -m code_executor -u ${USER_ID} -g sudo -RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -# With the User Change, we need to change permissions on these directories -RUN chmod -R a+rwx /usr/local -RUN chmod -R a+rwx /home -RUN chmod -R 755 /usr/lib/sudo - -# Set user to the one we just created -USER ${USER_ID} - -# Set working directory -WORKDIR /opt/code diff --git a/tools/docker/rhel.7/Dockerfile b/tools/docker/rhel.7/Dockerfile deleted file mode 100644 index 73247d2809..0000000000 --- a/tools/docker/rhel.7/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) .NET Foundation. All rights reserved. -# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -# - -# Dockerfile that creates a container suitable to build dotnet-cli -FROM microsoft/dotnet-buildtools-prereqs:rhel-7-rpmpkg-c982313-20174116044113 - -# Install from sudo main package TODO This package needs to be mirrored -RUN yum install -y https://www.sudo.ws/sudo/dist/packages/RHEL/7/sudo-1.8.20-3.el7.x86_64.rpm \ - && yum clean all - -# Setup User to match Host User, and give superuser permissions -ARG USER_ID=0 -RUN useradd -m code_executor -u ${USER_ID} -g root -RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -# With the User Change, we need to change permssions on these directories -RUN chmod -R a+rwx /usr/local -RUN chmod -R a+rwx /home -RUN chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo - -# Set user to the one we just created -USER ${USER_ID} - -# Set working directory -WORKDIR /opt/code diff --git a/tools/docker/ubuntu.14.04/Dockerfile b/tools/docker/ubuntu.14.04/Dockerfile deleted file mode 100644 index f039506971..0000000000 --- a/tools/docker/ubuntu.14.04/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) .NET Foundation. All rights reserved. -# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -# - -# Dockerfile that creates a container suitable to build dotnet-cli -FROM ubuntu:14.04 - -# Misc Dependencies for build -RUN apt-get update && \ - apt-get -qqy install \ - curl \ - unzip \ - gettext \ - sudo \ - libunwind8 \ - libkrb5-3 \ - libicu52 \ - liblttng-ust0 \ - libssl1.0.0 \ - zlib1g \ - libuuid1 \ - debhelper \ - build-essential \ - devscripts \ - git \ - cmake \ - clang-3.5 \ - lldb-3.6 \ - wget && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Use clang as c++ compiler -RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100 -RUN update-alternatives --set c++ /usr/bin/clang++-3.5 - -# Setup User to match Host User, and give superuser permissions -ARG USER_ID=0 -RUN useradd -m code_executor -u ${USER_ID} -g sudo -RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -# With the User Change, we need to change permissions on these directories -RUN chmod -R a+rwx /usr/local -RUN chmod -R a+rwx /home -RUN chmod -R 755 /usr/lib/sudo - -# Set user to the one we just created -USER ${USER_ID} - -# Set working directory -WORKDIR /opt/code diff --git a/tools/docker/ubuntu.16.04/Dockerfile b/tools/docker/ubuntu.16.04/Dockerfile deleted file mode 100644 index 79e76f0703..0000000000 --- a/tools/docker/ubuntu.16.04/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (c) .NET Foundation. All rights reserved. -# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -# - -FROM ubuntu:16.04 - -# Install the base toolchain we need to build anything (clang, cmake, make and the like) -# this does not include libraries that we need to compile different projects, we'd like -# them in a different layer. -RUN apt-get update && \ - apt-get install -y cmake \ - make \ - llvm-3.5 \ - clang-3.5 \ - git \ - curl \ - tar \ - sudo \ - debhelper \ - build-essential \ - devscripts \ - libunwind8 \ - libkrb5-3 \ - libicu55 \ - liblttng-ust0 \ - libssl1.0.0 \ - zlib1g \ - libuuid1 \ - liblldb-3.6 \ - wget && \ - apt-get clean - -# Setup User to match Host User, and give superuser permissions -ARG USER_ID=0 -RUN useradd -m code_executor -u ${USER_ID} -g sudo -RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -# With the User Change, we need to change permissions on these directories -RUN chmod -R a+rwx /usr/local -RUN chmod -R a+rwx /home -RUN chmod -R 755 /usr/lib/sudo - -# Set user to the one we just created -USER ${USER_ID} - -# Set working directory -WORKDIR /opt/code \ No newline at end of file diff --git a/tools/docker/ubuntu.16.10/Dockerfile b/tools/docker/ubuntu.16.10/Dockerfile deleted file mode 100644 index c57bd4c3ff..0000000000 --- a/tools/docker/ubuntu.16.10/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) .NET Foundation. All rights reserved. -# Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -# - -# Dockerfile that creates a container suitable to build dotnet-cli -FROM ubuntu:16.10 - -# Misc Dependencies for build -RUN apt-get update && \ - apt-get -qqy install \ - curl \ - unzip \ - gettext \ - sudo \ - libunwind8 \ - libkrb5-3 \ - libicu57 \ - liblttng-ust0 \ - libssl1.0.0 \ - zlib1g \ - libuuid1 \ - liblldb-3.5 \ - debhelper \ - build-essential \ - devscripts \ - git \ - cmake \ - clang-3.5 \ - wget && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Use clang as c++ compiler -RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-3.5 100 -RUN update-alternatives --set c++ /usr/bin/clang++-3.5 - -# Setup User to match Host User, and give superuser permissions -ARG USER_ID=0 -RUN useradd -m code_executor -u ${USER_ID} -g sudo -RUN echo 'code_executor ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers - -# With the User Change, we need to change permissions on these directories -RUN chmod -R a+rwx /usr/local -RUN chmod -R a+rwx /home -RUN chmod -R 755 /usr/lib/sudo - -# Set user to the one we just created -USER ${USER_ID} - -# Set working directory -WORKDIR /opt/code \ No newline at end of file diff --git a/tools/dotnet-deb-tool-consumer/NuGet.config b/tools/dotnet-deb-tool-consumer/NuGet.config deleted file mode 100644 index 60d3088e1f..0000000000 --- a/tools/dotnet-deb-tool-consumer/NuGet.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj b/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj deleted file mode 100644 index db3987ea48..0000000000 --- a/tools/dotnet-deb-tool-consumer/dotnet-deb-tool-consumer.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - netcoreapp1.0 - - - - - - - diff --git a/tools/packaging/changelog b/tools/packaging/changelog deleted file mode 100644 index f28d88ed10..0000000000 --- a/tools/packaging/changelog +++ /dev/null @@ -1,2 +0,0 @@ -* DATE MAINTAINER_NAME - PACKAGE_VERSION-PACKAGE_REVISION -- \ No newline at end of file diff --git a/tools/packaging/hosting_debian_config.json b/tools/packaging/hosting_debian_config.json deleted file mode 100644 index a01cf5cafc..0000000000 --- a/tools/packaging/hosting_debian_config.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "maintainer_name": "Microsoft", - "maintainer_email": "nugetaspnet@microsoft.com", - - "package_name": "dotnet-hosting", - "install_root": "/usr/share/dotnet", - - "short_description": "Microsoft .NET Core 2.0.0 Linux Server Hosting", - "long_description": "Microsoft .NET Core 2.0.0 Linux Server Hosting enables hosting of ASP.NET Core applications and contains the ASP.NET Core Runtime Package Store and .NET Core Runtime. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs.", - "homepage": "https://www.asp.net/", - - "release":{ - "package_version":"0.0.0.0", - "package_revision":"1", - "urgency" : "low", - "changelog_message" : "" - }, - - "control": { - "priority":"standard", - "section":"devel", - "architecture":"any" - }, - - "copyright": "Microsoft", - "license": { - "type": "Apache-2.0", - "full_text": "Copyright (c) .NET Foundation. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthese files except in compliance with the License. You may obtain a copy of the\nLicense at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License." - }, - - "debian_dependencies": { - "dotnet-runtime-DOTNET_RUNTIME_VERSION": {}, - "aspnetcore-store-ASPNETCORE_STORE_VERSION": {} - } -} \ No newline at end of file diff --git a/tools/packaging/store_debian_config.json b/tools/packaging/store_debian_config.json deleted file mode 100644 index dfd9d9b499..0000000000 --- a/tools/packaging/store_debian_config.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "maintainer_name": "Microsoft", - "maintainer_email": "nugetaspnet@microsoft.com", - - "package_name": "aspnetcore-store", - "install_root": "/usr/share/dotnet", - - "short_description": "Microsoft ASP.NET Core 2.0.0 Runtime Package Store", - "long_description": "Runtime package store for Microsoft ASP.NET Core. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/aspnet/home). We happily accept issues and PRs.", - "homepage": "https://www.asp.net/", - - "release":{ - "package_version":"0.0.0.0", - "package_revision":"1", - "urgency" : "low", - "changelog_message" : "" - }, - - "control": { - "priority":"standard", - "section":"devel", - "architecture":"any" - }, - - "copyright": "Microsoft", - "license": { - "type": "Apache-2.0", - "full_text": "Copyright (c) .NET Foundation. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthese files except in compliance with the License. You may obtain a copy of the\nLicense at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License." - } -} \ No newline at end of file diff --git a/tools/scripts/GetSharedFrameworkVersion.ps1 b/tools/scripts/GetSharedFrameworkVersion.ps1 deleted file mode 100644 index 37772625fe..0000000000 --- a/tools/scripts/GetSharedFrameworkVersion.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -$infoOutput = dotnet --info -$versions = $infoOutput | Select-String -Pattern "version" -$FXVersionRaw = $versions | Select-Object -Last 1 -$FXVersionString = $FXVersionRaw.ToString() -$FXVersion = $FXVersionString.SubString($FXVersionString.IndexOf(':') + 1).Trim() -Write-Host $FXVersion diff --git a/tools/scripts/GetSharedFrameworkVersion.sh b/tools/scripts/GetSharedFrameworkVersion.sh deleted file mode 100755 index 1b6e0b4bb0..0000000000 --- a/tools/scripts/GetSharedFrameworkVersion.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -dotnet --info | grep -i version | tail -1 | cut -f 2 -d ":" | tr -d ' ' \ No newline at end of file diff --git a/tools/scripts/TestInstallers.sh b/tools/scripts/TestInstallers.sh deleted file mode 100755 index dbda428443..0000000000 --- a/tools/scripts/TestInstallers.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash -set -e -set -o pipefail - -artifactsDir="artifacts/" -installersDir=$artifactsDir"installers/" -dotnetInstallersDir=$artifactsDir"dotnetInstallers/" -installerTestDir=$artifactsDir"installerTest/" - -# clean up test directory -if [ -d $installerTestDir ]; then - rm -r $installerTestDir -fi -mkdir $installerTestDir - -# copy dotnet installers -cp $dotnetInstallersDir*$DotnetInstallerSuffix $installerTestDir - -# copy store and hosting installers -cp $installersDir$StoreInstallerFile $installerTestDir -cp $installersDir$HostingInstallerFile $installerTestDir - -# test store install -(cd $installerTestDir && $InstallCommand $StoreInstallerFile) - -if [ ! -d $InstallRoot"additionalDeps" ]; then - echo $InstallRoot"additionalDeps missing after installing the runtime store." - exit 1 -fi -if [ ! -d $InstallRoot"store" ]; then - echo $InstallRoot"store missing after installing the runtime store." - exit 1 -fi - -# test store uninstall -$UninstallCommand $StoreInstallerPackageName - -if [ -d $InstallRoot"additionalDeps" ]; then - echo $InstallRoot"additionalDeps remains after uninstalling the runtime store." - exit 1 -fi -if [ -d $InstallRoot"store" ]; then - echo $InstallRoot"store remains after uninstalling the runtime store." - exit 1 -fi - -# test hosting install -(cd $installerTestDir && $InstallCommand *$InstallerExtension) - -if [ ! -d $InstallRoot"additionalDeps" ]; then - echo $InstallRoot"additionalDeps missing after installing the hosting bundle." - exit 1 -fi -if [ ! -d $InstallRoot"shared" ]; then - echo $InstallRoot"shared missing after installing the hosting bundle." - exit 1 -fi -if [ ! -d $InstallRoot"store" ]; then - echo $InstallRoot"store missing after installing the hosting bundle." - exit 1 -fi - -# test hosting uninstall -$UninstallCommand $HostingInstallerPackageName - -if [ ! -d $InstallRoot"additionalDeps" ]; then - echo $InstallRoot"additionalDeps missing after installing the hosting bundle." - exit 1 -fi -if [ ! -d $InstallRoot"shared" ]; then - echo $InstallRoot"shared missing after installing the hosting bundle." - exit 1 -fi -if [ ! -d $InstallRoot"store" ]; then - echo $InstallRoot"store missing after installing the hosting bundle." - exit 1 -fi diff --git a/tools/scripts/zip2tgz.sh b/tools/scripts/zip2tgz.sh deleted file mode 100755 index 15a5cd2a12..0000000000 --- a/tools/scripts/zip2tgz.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -if [[ $# < 2 ]]; then - echo "Usage: [src] [dest]" - exit 1 -fi - -function realpath() { - [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" -} - -src="$(realpath $1)" -dest="$(realpath $2)" - -echo "Converting:" -echo " - $src" -echo " => $dest" - -tmp="$(mktemp -d)" -echo "Using temp dir $tmp" -function cleanup() { - echo "Cleaning up" - rm -rf $tmp - echo "Done" -} -trap cleanup INT TERM EXIT -set -e - -unzip -q $src -d $tmp -chmod -R +r $tmp -tar -c -z -f $dest -C $tmp . From 421bcb490f08d4a46221eb7a3eb6c09579dbd77b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 25 Oct 2017 16:46:21 -0700 Subject: [PATCH 261/361] Pin tools and package versions --- .gitignore | 1 - Directory.Build.props | 1 + Directory.Build.targets | 3 ++ NuGet.config | 1 - build/dependencies.props | 43 ++++++++++++------- build/repo.props | 5 ++- korebuild-lock.txt | 2 + korebuild.json | 4 ++ samples/SampleApp/SampleApp.csproj | 2 +- src/Directory.Build.props | 2 +- .../Microsoft.AspNetCore.csproj | 30 ++++++------- test/Directory.Build.props | 2 +- ...icrosoft.AspNetCore.FunctionalTests.csproj | 11 +++-- .../Microsoft.AspNetCore.Tests.csproj | 13 +++--- version.props | 9 ++++ version.xml | 12 ------ 16 files changed, 82 insertions(+), 59 deletions(-) create mode 100644 korebuild-lock.txt create mode 100644 korebuild.json create mode 100644 version.props delete mode 100644 version.xml diff --git a/.gitignore b/.gitignore index e8cd589251..3af0091ea3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,3 @@ global.json .deps/ .rw/ .ro/ -korebuild-lock.txt diff --git a/Directory.Build.props b/Directory.Build.props index 787f9a83f8..e43856d359 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,5 @@ + diff --git a/Directory.Build.targets b/Directory.Build.targets index f75adf7e4d..e83ff95e39 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,2 +1,5 @@  + + $(MicrosoftNETCoreApp20PackageVersion) + diff --git a/NuGet.config b/NuGet.config index 8a937d9f50..4e8a1f6de1 100644 --- a/NuGet.config +++ b/NuGet.config @@ -4,7 +4,6 @@ - diff --git a/build/dependencies.props b/build/dependencies.props index 4dfc6e6b11..def51bc728 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,19 +1,32 @@  - - - 0.5.0-* - 2.1.0-* - - 4.4.0-* - 2.0.0-preview2-* - 2.1.1-* - 10.0.1 - 4.7.49 - 2.0.0-* - 2.0.0-* - 15.3.0 - 2.3.0 + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - + + 2.1.0-preview1-15541 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 0.5.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.1.0-preview1-27424 + 2.0.0 + 15.3.0 + 4.7.49 + 2.0.0 + 2.3.0 + 2.3.0 + + diff --git a/build/repo.props b/build/repo.props index 39ccbe3845..1894f74d76 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,3 +1,6 @@ - + + Internal.AspNetCore.Universe.Lineup + https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json + diff --git a/korebuild-lock.txt b/korebuild-lock.txt new file mode 100644 index 0000000000..5dfe0a2e0d --- /dev/null +++ b/korebuild-lock.txt @@ -0,0 +1,2 @@ +version:2.1.0-preview1-15541 +commithash:0f388d759de1c87fe58383bc9eb1020228885d4d diff --git a/korebuild.json b/korebuild.json new file mode 100644 index 0000000000..bd5d51a51b --- /dev/null +++ b/korebuild.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", + "channel": "dev" +} diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index 35b28c8284..eabea3b14b 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d704a37df9..410f24daa9 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index f7d0f3ba81..e183b31571 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -9,21 +9,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index d704a37df9..410f24daa9 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -2,6 +2,6 @@ - + diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index 131e2ee181..1281e63751 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -21,11 +21,10 @@ - - - - - + + + + + - diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj index 7da44ee745..871a640f86 100644 --- a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj +++ b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj @@ -7,10 +7,13 @@ - - - - - \ No newline at end of file + + + + + + + + diff --git a/version.props b/version.props new file mode 100644 index 0000000000..e5fd0676de --- /dev/null +++ b/version.props @@ -0,0 +1,9 @@ + + + 2.1.0 + preview1 + $(VersionPrefix) + $(VersionPrefix)-$(VersionSuffix)-final + $(VersionSuffix)-$(BuildNumber) + + diff --git a/version.xml b/version.xml deleted file mode 100644 index 88464f4cc3..0000000000 --- a/version.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - dev - 2.1.0 - preview1 - $(VersionSuffix) - $(VersionSuffix)-$(BuildNumber) - $(VersionPrefix) - $(Version)-$(VersionSuffix) - - From d63542ca31614cff8a69c788d6fb1ebc8b0870f9 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 31 Oct 2017 13:52:49 -0700 Subject: [PATCH 262/361] Upgrade build tools and dependencies to latest versions [auto-updated: dependencies] --- build/dependencies.props | 39 +++++++++---------- build/repo.props | 3 +- korebuild-lock.txt | 4 +- ...icrosoft.AspNetCore.FunctionalTests.csproj | 2 +- .../Microsoft.AspNetCore.Tests.csproj | 2 +- version.props | 1 + 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index def51bc728..06c4004403 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,30 +3,29 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15541 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 0.5.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 - 2.1.0-preview1-27424 + 2.1.0-preview1-15549 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 0.5.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 + 2.1.0-preview1-27475 2.0.0 15.3.0 4.7.49 - 2.0.0 2.3.0 - 2.3.0 + 2.3.0 diff --git a/build/repo.props b/build/repo.props index 1894f74d76..20e96b5d3c 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,6 +1,7 @@ + Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 5dfe0a2e0d..45463cc71e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15541 -commithash:0f388d759de1c87fe58383bc9eb1020228885d4d +version:2.1.0-preview1-15549 +commithash:f570e08585fec510dd60cd4bfe8795388b757a95 diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index 1281e63751..27328c3da6 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -24,7 +24,7 @@ - + diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj index 871a640f86..5cbd5b5531 100644 --- a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj +++ b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj @@ -12,7 +12,7 @@ - + diff --git a/version.props b/version.props index e5fd0676de..5c4a7c32d1 100644 --- a/version.props +++ b/version.props @@ -4,6 +4,7 @@ preview1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final + t000 $(VersionSuffix)-$(BuildNumber) From b40a1a5a8cfb186d41689f3c319135e518a7630c Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 2 Nov 2017 14:35:39 -0700 Subject: [PATCH 263/361] Upgrade tools and dependencies --- build/dependencies.props | 36 +++++++++---------- korebuild-lock.txt | 4 +-- samples/SampleApp/SampleApp.csproj | 2 +- .../Microsoft.AspNetCore.csproj | 2 +- ...icrosoft.AspNetCore.FunctionalTests.csproj | 2 +- .../CreateDefaultBuilderApp.csproj | 4 +-- .../DependencyInjectionApp.csproj | 2 +- .../StartRequestDelegateUrlApp.csproj | 4 +-- .../StartRouteBuilderUrlApp.csproj | 4 +-- .../StartWithIApplicationBuilderUrlApp.csproj | 4 +-- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 06c4004403..9d4b2d33af 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,24 +3,24 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15549 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 0.5.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 - 2.1.0-preview1-27475 + 2.1.0-preview1-15551 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 0.5.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 + 2.1.0-preview1-27501 2.0.0 15.3.0 4.7.49 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 45463cc71e..86352477bb 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15549 -commithash:f570e08585fec510dd60cd4bfe8795388b757a95 +version:2.1.0-preview1-15551 +commithash:8fad9553b48533fddbb16a423ea55b9710ea2e63 diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index eabea3b14b..ff3ecf9676 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.0;net461 diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index e183b31571..949e2a991c 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index 27328c3da6..9a6bd04659 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.0;net461 diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj index 0956c47f07..7b43959e2f 100644 --- a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj +++ b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj @@ -1,4 +1,4 @@ - + Exe @@ -10,4 +10,4 @@ - \ No newline at end of file + diff --git a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj index 04691e82ed..7930c4a822 100644 --- a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj +++ b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj index 0c089dbc33..7930c4a822 100644 --- a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj +++ b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj @@ -1,4 +1,4 @@ - + Exe @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj index 0c089dbc33..7930c4a822 100644 --- a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj +++ b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj @@ -1,4 +1,4 @@ - + Exe @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj index 0c089dbc33..7930c4a822 100644 --- a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj +++ b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj @@ -1,4 +1,4 @@ - + Exe @@ -9,4 +9,4 @@ - \ No newline at end of file + From ba70eae94b34f8304b5abfe04e715f1ecb23216e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 16 Nov 2017 16:55:50 -0800 Subject: [PATCH 264/361] Update samples and tests to target netcoreapp2.1 --- korebuild-lock.txt | 4 ++-- samples/SampleApp/SampleApp.csproj | 2 +- test/Directory.Build.props | 7 +++++++ .../Microsoft.AspNetCore.FunctionalTests.csproj | 4 +--- .../Microsoft.AspNetCore.Tests.csproj | 3 +-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 86352477bb..b2036f3394 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15551 -commithash:8fad9553b48533fddbb16a423ea55b9710ea2e63 +version:2.1.0-preview1-15569 +commithash:47312a6364ad0ee6d7052eada54da940c9b17931 diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index ff3ecf9676..622f64cc4c 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0;net461 + netcoreapp2.1;net461 aspnetcore-MetaPackagesSampleApp-20170406180413 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 410f24daa9..2a4205c758 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,6 +1,13 @@  + + netcoreapp2.1 + $(DeveloperBuildTestTfms) + netcoreapp2.1;netcoreapp2.0 + $(StandardTestTfms);net461 + + diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index 9a6bd04659..d4a5bbdf12 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -1,15 +1,13 @@ - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) true - win7-x64 diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj index 5cbd5b5531..1b8156a1ca 100644 --- a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj +++ b/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj @@ -1,8 +1,7 @@ - netcoreapp2.0;net461 - netcoreapp2.0 + $(StandardTestTfms) From b01f1a9f6aacba7db3c72346138980135123b640 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 16 Nov 2017 16:56:40 -0800 Subject: [PATCH 265/361] Add support for looking up AspNetCoreSettings.props file beyond repo root --- Directory.Build.props | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index e43856d359..e577552801 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,8 @@ + + From e0144cb76711cc3cfeb50fcaa271c10e11cc8b5c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 17 Nov 2017 13:00:26 -0800 Subject: [PATCH 266/361] Use MicrosoftNETCoreApp21PackageVersion to determine the runtime framework in netcoreapp2.1 --- Directory.Build.targets | 1 + build/dependencies.props | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index e83ff95e39..894b1d0cf8 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,6 @@  $(MicrosoftNETCoreApp20PackageVersion) + $(MicrosoftNETCoreApp21PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 9d4b2d33af..3e9f31a276 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -22,6 +22,7 @@ 2.1.0-preview1-27501 2.1.0-preview1-27501 2.0.0 + 2.1.0-preview1-25907-02 15.3.0 4.7.49 2.3.0 From 9679581b4bb205bff32a1326bdf18df9800c4ccb Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 20 Nov 2017 12:18:22 -0800 Subject: [PATCH 267/361] Use MSBuild to set NuGet feeds instead of NuGet.config --- Directory.Build.props | 3 ++- NuGet.config | 4 +--- build/sources.props | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 build/sources.props diff --git a/Directory.Build.props b/Directory.Build.props index e577552801..9bcc46cef9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,11 @@ - + + Microsoft ASP.NET Core diff --git a/NuGet.config b/NuGet.config index 4e8a1f6de1..e32bddfd51 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,8 +2,6 @@ - - - + diff --git a/build/sources.props b/build/sources.props new file mode 100644 index 0000000000..c03f3ddb60 --- /dev/null +++ b/build/sources.props @@ -0,0 +1,16 @@ + + + + + $(DotNetRestoreSources) + + $(RestoreSources); + https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; + + + $(RestoreSources); + https://api.nuget.org/v3/index.json; + + + From 688ba2baa2ffff5f82449e5bacd7d35c99a4b5a4 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Nov 2017 15:48:19 -0800 Subject: [PATCH 268/361] Replace aspnetcore-ci-dev feed with aspnetcore-dev --- build/dependencies.props | 38 +++++++++++++++++++------------------- build/repo.props | 4 ++-- build/sources.props | 2 +- korebuild-lock.txt | 4 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3e9f31a276..175523db44 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,26 +1,26 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15551 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 0.5.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 - 2.1.0-preview1-27501 + 2.1.0-preview1-15576 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 0.5.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 + 2.1.0-preview1-27644 2.0.0 2.1.0-preview1-25907-02 15.3.0 diff --git a/build/repo.props b/build/repo.props index 20e96b5d3c..07c5f08325 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,7 +1,7 @@ - + Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index c03f3ddb60..9feff29d09 100644 --- a/build/sources.props +++ b/build/sources.props @@ -5,7 +5,7 @@ $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b2036f3394..1a99066b7c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15569 -commithash:47312a6364ad0ee6d7052eada54da940c9b17931 +version:2.1.0-preview1-15576 +commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 From c25e5cdd082a9d3419c85141cd56b08714361d3b Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 29 Nov 2017 14:09:28 -0800 Subject: [PATCH 269/361] Specify runtime versions to install --- build/repo.props | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/repo.props b/build/repo.props index 07c5f08325..78b0ce5879 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,7 +1,14 @@  + + Internal.AspNetCore.Universe.Lineup https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + + + + + From f0de53c661a3c01f5cd446a802231365a82f5026 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Fri, 1 Dec 2017 10:25:25 -0800 Subject: [PATCH 270/361] Update bootstrappers --- run.ps1 | 17 +++++++++++------ run.sh | 30 +++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/run.ps1 b/run.ps1 index 49c2899856..27dcf848f8 100644 --- a/run.ps1 +++ b/run.ps1 @@ -29,6 +29,9 @@ Updates KoreBuild to the latest version even if a lock file is present. .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. +.PARAMETER ToolsSourceSuffix +The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. + .PARAMETER Arguments Arguments to be passed to the command @@ -51,7 +54,7 @@ Example config file: #> [CmdletBinding(PositionalBinding = $false)] param( - [Parameter(Mandatory=$true, Position = 0)] + [Parameter(Mandatory = $true, Position = 0)] [string]$Command, [string]$Path = $PSScriptRoot, [Alias('c')] @@ -63,6 +66,7 @@ param( [Alias('u')] [switch]$Update, [string]$ConfigFile, + [string]$ToolsSourceSuffix, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -79,7 +83,7 @@ function Get-KoreBuild { $lockFile = Join-Path $Path 'korebuild-lock.txt' if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix } $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 @@ -96,7 +100,7 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile + Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath @@ -124,7 +128,7 @@ function Join-Paths([string]$path, [string[]]$childPaths) { return $path } -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { if ($RemotePath -notlike 'http*') { Copy-Item $RemotePath $LocalPath return @@ -134,7 +138,7 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) { while ($retries -gt 0) { $retries -= 1 try { - Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath + Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath return } catch { @@ -161,7 +165,8 @@ if (Test-Path $ConfigFile) { if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} } - } catch { + } + catch { Write-Warning "$ConfigFile could not be read. Its settings will be ignored." Write-Warning $Error[0] } diff --git a/run.sh b/run.sh index c278423acc..834961fc3a 100755 --- a/run.sh +++ b/run.sh @@ -17,6 +17,7 @@ update=false repo_path="$DIR" channel='' tools_source='' +tools_source_suffix='' # # Functions @@ -29,13 +30,14 @@ __usage() { echo " ... Arguments passed to the command. Variable number of arguments allowed." echo "" echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --verbose Show verbose output." + echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." + echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." + echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." + echo " --path The directory to build. Defaults to the directory containing the script." + echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." + echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." + echo " -u|--update Update to the latest KoreBuild even if the lock file is present." echo "" echo "Description:" 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." @@ -50,7 +52,7 @@ get_korebuild() { local version local lock_file="$repo_path/korebuild-lock.txt" if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" fi version="$(grep 'version:*' -m 1 "$lock_file")" if [[ "$version" == '' ]]; then @@ -66,7 +68,7 @@ get_korebuild() { local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" tmpfile="$(mktemp)" echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile"; then + if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then unzip -q -d "$korebuild_path" "$tmpfile" fi rm "$tmpfile" || true @@ -98,6 +100,7 @@ __machine_has() { __get_remote_file() { local remote_path=$1 local local_path=$2 + local remote_path_suffix=$3 if [[ "$remote_path" != 'http'* ]]; then cp "$remote_path" "$local_path" @@ -106,14 +109,14 @@ __get_remote_file() { local failed=false if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true + wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true else failed=true fi if [ "$failed" = true ] && __machine_has curl; then failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true fi if [ "$failed" = true ]; then @@ -164,6 +167,11 @@ while [[ $# -gt 0 ]]; do tools_source="${1:-}" [ -z "$tools_source" ] && __usage ;; + --tools-source-suffix|-ToolsSourceSuffix) + shift + tools_source_suffix="${1:-}" + [ -z "$tools_source_suffix" ] && __usage + ;; -u|--update|-Update) update=true ;; From 54a2ee4b2914b4764dd55f8ca586908090d10bf7 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 10 Dec 2017 13:12:57 -0800 Subject: [PATCH 271/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 42 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 175523db44..420983566c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,30 +3,30 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15576 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 0.5.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 - 2.1.0-preview1-27644 + 2.1.0-preview1-15618 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 0.5.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 + 2.1.0-preview1-27773 2.0.0 - 2.1.0-preview1-25907-02 + 2.1.0-preview1-25915-01 15.3.0 4.7.49 - 2.3.0 - 2.3.0 + 2.3.1 + 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 1a99066b7c..e7cce93009 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15576 -commithash:2f3856d2ba4f659fcb9253215b83946a06794a27 +version:2.1.0-preview1-15618 +commithash:00ce1383114015fe89b221146036e59e6bc11219 From 7a5568f80fd11d1aa8c60e7850823ac94b52ee29 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 13 Dec 2017 21:11:50 +0000 Subject: [PATCH 272/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 420983566c..938881708f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15618 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 0.5.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 - 2.1.0-preview1-27773 + 2.1.0-preview1-15626 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 0.5.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 + 2.1.0-preview1-27807 2.0.0 - 2.1.0-preview1-25915-01 + 2.1.0-preview1-26008-01 15.3.0 4.7.49 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e7cce93009..8d52a6128c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15618 -commithash:00ce1383114015fe89b221146036e59e6bc11219 +version:2.1.0-preview1-15626 +commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 From 61ffe44d09b96b1ce43ae026c261587c27ee1f3d Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 18 Dec 2017 17:25:40 -0800 Subject: [PATCH 273/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 938881708f..417ebc3960 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,25 +4,25 @@ 2.1.0-preview1-15626 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 0.5.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 - 2.1.0-preview1-27807 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 0.5.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 + 2.1.0-preview1-27849 2.0.0 - 2.1.0-preview1-26008-01 + 2.1.0-preview1-26016-05 15.3.0 4.7.49 2.3.1 From ee9b0808756bf7a11e5bd24d47bda04cfe8c7a16 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 21 Dec 2017 12:37:32 -0800 Subject: [PATCH 274/361] Allow untrusted certs in tests --- build/dependencies.props | 34 +++++++++---------- .../WebHostFunctionalTests.cs | 12 +++++-- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 417ebc3960..8dd9ce6a66 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,23 +4,23 @@ 2.1.0-preview1-15626 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 0.5.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 - 2.1.0-preview1-27849 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 0.5.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 + 2.1.0-preview1-27885 2.0.0 2.1.0-preview1-26016-05 15.3.0 diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index 385ce19cd4..fa03852a0e 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -52,7 +52,9 @@ namespace Microsoft.AspNetCore.Tests var applicationName = "CreateDefaultBuilderApp"; await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { - var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; + var client = new HttpClient(handler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; + var response = await RetryHelper.RetryRequest(() => client.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); var responseText = await response.Content.ReadAsStringAsync(); try @@ -78,7 +80,9 @@ namespace Microsoft.AspNetCore.Tests var applicationName = "CreateDefaultBuilderOfTApp"; await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { - var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; + var client = new HttpClient(handler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; + var response = await RetryHelper.RetryRequest(() => client.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); var responseText = await response.Content.ReadAsStringAsync(); try @@ -106,7 +110,9 @@ namespace Microsoft.AspNetCore.Tests var applicationName = "DependencyInjectionApp"; await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { - var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; + var client = new HttpClient(handler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; + var response = await RetryHelper.RetryRequest(() => client.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); var responseText = await response.Content.ReadAsStringAsync(); try { From 7511a4da7f1d1d9651d19801aadea77f557e0b11 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 21 Dec 2017 14:02:47 -0800 Subject: [PATCH 275/361] Add kestrel config to CreateDefaultBuilder --- samples/SampleApp/appsettings.json | 50 +++++++------------ src/Microsoft.AspNetCore/WebHost.cs | 11 ++-- .../WebHostFunctionalTests.cs | 3 +- .../CreateDefaultBuilderApp/appsettings.json | 9 +++- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/samples/SampleApp/appsettings.json b/samples/SampleApp/appsettings.json index 2c651a7765..66f0f7ade6 100644 --- a/samples/SampleApp/appsettings.json +++ b/samples/SampleApp/appsettings.json @@ -2,61 +2,47 @@ "Kestrel": { "EndPoints": { "Http": { - "Address": "127.0.0.1", - "Port": 5000 - }, + "Url": "http://localhost:5005" + } // To enable HTTPS using a certificate file, set the path to a .pfx file in // the "Path" property below and configure the password in user secrets. // The "Password" property should be set in user secrets. //"HttpsInlineCertFile": { - // "Address": "127.0.0.1", - // "Port": 5001, + // "Url": "http://localhost:5005" // "Certificate": { - // "Source": "File", - // "Path": "" + // "Path": "", + // "Password: "" // } //}, //"HttpsInlineCertStore": { - // "Address": "127.0.0.1", - // "Port": 5002, + // "Url": "http://localhost:5005" // "Certificate": { - // "Source": "Store", // "Subject": "", - // "StoreName": "", - // "StoreLocation": "", + // "Store": "", + // "Location": "", // "AllowInvalid": "" // Set to "true" to allow invalid certificates (e.g. expired) // } //}, - // To enable this endpoint, set the path to a .pfx file in the "Path" property - // of the "TestCert" certificate defined under the "Certificates" section. - // Configure the password in user secrets. - //"HttpsCertFile": { - // "Address": "127.0.0.1", - // "Port": 5003, - // "Certificate": "TestCert" + // This uses the cert defined under Certificates/Default or the development cert. + //"HttpsDefaultCert": { + // "Url": "http://localhost:5005" //} - - //"HttpsCertStore": { - // "Address": "127.0.0.1", - // "Port": 5004, - // "Certificate": "TestCertInStore" - //}, } }, "Certificates": { - //"TestCert": { - // "Source": "File", - // "Path": "" + //"Default": { + // "Path": "", + // "Password": "" //}, - //"TestCertInStore": { - // "Source": "Store", + // From cert store: + //"Default": { // "Subject": "", - // "StoreName": "", - // "StoreLocation": "", + // "Store": "", + // "Location": "", // "AllowInvalid": "" // Set to "true" to allow invalid certificates (e.g. expired certificates) //} } diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index df3b91d75b..1d5a1ecb9f 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore ///
/// /// The following defaults are applied to the returned : - /// use Kestrel as the web server, + /// use Kestrel as the web server and configure it using the application's configuration providers, /// set the to the result of , /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore ///
/// /// The following defaults are applied to the returned : - /// use Kestrel as the web server, + /// use Kestrel as the web server and configure it using the application's configuration providers, /// set the to the result of , /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, @@ -148,7 +148,10 @@ namespace Microsoft.AspNetCore public static IWebHostBuilder CreateDefaultBuilder(string[] args) { var builder = new WebHostBuilder() - .UseKestrel() + .UseKestrel((builderContext, options) => + { + options.Configure(builderContext.Configuration.GetSection("Kestrel")); + }) .UseContentRoot(Directory.GetCurrentDirectory()) .ConfigureAppConfiguration((hostingContext, config) => { @@ -198,7 +201,7 @@ namespace Microsoft.AspNetCore ///
/// /// The following defaults are applied to the returned : - /// use Kestrel as the web server, + /// use Kestrel as the web server and configure it using the application's configuration providers, /// set the to the result of , /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index fa03852a0e..3a9ac52e29 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -61,7 +61,8 @@ namespace Microsoft.AspNetCore.Tests { // Assert server is Kestrel Assert.Equal("Kestrel", response.Headers.Server.ToString()); - + // Set from default config + Assert.Equal("http://localhost:5002/", deploymentResult.ApplicationBaseUri); // The application name will be sent in response when all asserts succeed in the test app. Assert.Equal(applicationName, responseText); } diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.json b/test/TestSites/CreateDefaultBuilderApp/appsettings.json index bc5ff92c67..393b080efb 100644 --- a/test/TestSites/CreateDefaultBuilderApp/appsettings.json +++ b/test/TestSites/CreateDefaultBuilderApp/appsettings.json @@ -1,3 +1,10 @@ { - "settingsKey": "settingsValue" + "settingsKey": "settingsValue", + "Kestrel": { + "Endpoints": { + "HTTP": { + "Url": "http://localhost:5002" + } + } + } } From 464e08b4f4f00b90e5c082f8e641e2413746e7bc Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 22 Dec 2017 12:40:44 -0800 Subject: [PATCH 276/361] Force http in tests --- .../WebHostFunctionalTests.cs | 15 +++++---------- .../CreateDefaultBuilderOfTApp/appsettings.json | 9 ++++++++- test/TestSites/DependencyInjectionApp/Program.cs | 1 + 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index 3a9ac52e29..b882205779 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -52,9 +52,7 @@ namespace Microsoft.AspNetCore.Tests var applicationName = "CreateDefaultBuilderApp"; await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { - var handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; - var client = new HttpClient(handler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; - var response = await RetryHelper.RetryRequest(() => client.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); var responseText = await response.Content.ReadAsStringAsync(); try @@ -81,16 +79,15 @@ namespace Microsoft.AspNetCore.Tests var applicationName = "CreateDefaultBuilderOfTApp"; await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { - var handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; - var client = new HttpClient(handler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; - var response = await RetryHelper.RetryRequest(() => client.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); var responseText = await response.Content.ReadAsStringAsync(); try { // Assert server is Kestrel Assert.Equal("Kestrel", response.Headers.Server.ToString()); - + // Set from default config + Assert.Equal("http://localhost:5002/", deploymentResult.ApplicationBaseUri); // The application name will be sent in response when all asserts succeed in the test app. Assert.Equal(applicationName, responseText); } @@ -111,9 +108,7 @@ namespace Microsoft.AspNetCore.Tests var applicationName = "DependencyInjectionApp"; await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { - var handler = new HttpClientHandler() { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator }; - var client = new HttpClient(handler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; - var response = await RetryHelper.RetryRequest(() => client.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); var responseText = await response.Content.ReadAsStringAsync(); try { diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json index bc5ff92c67..393b080efb 100644 --- a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json +++ b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json @@ -1,3 +1,10 @@ { - "settingsKey": "settingsValue" + "settingsKey": "settingsValue", + "Kestrel": { + "Endpoints": { + "HTTP": { + "Url": "http://localhost:5002" + } + } + } } diff --git a/test/TestSites/DependencyInjectionApp/Program.cs b/test/TestSites/DependencyInjectionApp/Program.cs index 555dcc7156..6e4850002b 100644 --- a/test/TestSites/DependencyInjectionApp/Program.cs +++ b/test/TestSites/DependencyInjectionApp/Program.cs @@ -22,6 +22,7 @@ namespace CreateDefaultBuilderApp static void Main(string[] args) { WebHost.CreateDefaultBuilder() + .UseUrls("http://localhost:5002") .ConfigureServices((context, services) => { services.AddSingleton(typeof(IService<>), typeof(Service<>)); From afee0de3e416f8e2807c7d49ad2bdef5016dae5f Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 31 Dec 2017 21:29:23 +0000 Subject: [PATCH 277/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8dd9ce6a66..e19028c809 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,24 +3,24 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15626 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 0.5.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 - 2.1.0-preview1-27885 + 2.1.0-preview1-15651 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 0.5.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 + 2.1.0-preview1-27942 2.0.0 2.1.0-preview1-26016-05 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 8d52a6128c..7c2e97aa79 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15626 -commithash:fd6410e9c90c428bc01238372303ad09cb9ec889 +version:2.1.0-preview1-15651 +commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 From c3d6c28dd128daefdae551fe487094ea098e7356 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 4 Jan 2018 01:35:27 +0000 Subject: [PATCH 278/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index e19028c809..458381c64f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,23 +4,23 @@ 2.1.0-preview1-15651 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 0.5.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 - 2.1.0-preview1-27942 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 0.5.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 + 2.1.0-preview1-27965 2.0.0 2.1.0-preview1-26016-05 15.3.0 From 0494f7ee5c5af7948e483dcf00b6b93a1c1cba07 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sat, 6 Jan 2018 15:08:22 -0800 Subject: [PATCH 279/361] Update dependencies.props [auto-updated: dependencies] --- korebuild-lock.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7c2e97aa79..2146d006d7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15651 -commithash:ebf2365121c2c6a6a0fbfa9b0f37bb5effc89323 +version:2.1.0-preview1-15661 +commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 From 1525559baba37384df540bd094b28aec8b9e24db Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 23 Jan 2018 15:31:59 -0800 Subject: [PATCH 280/361] Branching for 2.1.0-preview1 --- build/dependencies.props | 38 +++++++++++++++++++------------------- build/repo.props | 4 ++-- build/sources.props | 4 ++-- korebuild-lock.txt | 4 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 458381c64f..3fa6453484 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 0.5.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview1-15679 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 0.5.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 + 2.1.0-preview1-28153 2.0.0 - 2.1.0-preview1-26016-05 + 2.1.0-preview1-26115-03 15.3.0 4.7.49 2.3.1 diff --git a/build/repo.props b/build/repo.props index 78b0ce5879..d94ff7d00d 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,10 +1,10 @@ - + Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9feff29d09..5d66393335 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,11 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2146d006d7..a474bc0e35 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15661 -commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 +version:2.1.0-preview1-15679 +commithash:5347461137cb45a77ddcc0b55b2478092de43338 From 702cadf32503810fed71d9d44de2b241c3253461 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 24 Jan 2018 15:00:28 -0800 Subject: [PATCH 281/361] Updating version to preview2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 5c4a7c32d1..370d5ababd 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 381f3a7414c3c0f1c6d9a2fe30a643d34396bf23 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 31 Jan 2018 15:01:12 -0800 Subject: [PATCH 282/361] Update dependencies.props to 2.1.0-preview-28193, build tools to 2.1.0-preview1-1010 [ci skip] Scripted changes: - updated travis and appveyor.yml files to only build dev, ci, and release branches - updated dependencies.props - updated korebuild-lock.txt - updated korebuild.json to release/2.1 channel --- .appveyor.yml | 16 +++++++--------- .travis.yml | 24 ++++++++++++------------ build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- korebuild.json | 4 ++-- 5 files changed, 42 insertions(+), 44 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c7b6e34316..4eea96ab69 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,19 +1,17 @@ init: - - git config --global core.autocrlf true +- git config --global core.autocrlf true branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ build_script: - - ps: .\run.ps1 default-build +- ps: .\run.ps1 default-build clone_depth: 1 environment: global: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: off -deploy: off +test: 'off' +deploy: 'off' os: Visual Studio 2017 diff --git a/.travis.yml b/.travis.yml index 6c59666f3a..64bdbb4441 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,25 +3,25 @@ sudo: false dist: trusty env: global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 mono: none os: - - linux - - osx +- linux +- osx osx_image: xcode8.2 addons: apt: packages: - - libunwind8 + - libunwind8 branches: only: - - master - - release - - dev - - /^(.*\/)?ci-.*$/ - - /^rel\/.*/ + - dev + - /^release\/.*$/ + - /^(.*\/)?ci-.*$/ before_install: - - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /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 /usr/local/lib/; fi +- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s + /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 + /usr/local/lib/; fi script: - - ./build.sh +- ./build.sh diff --git a/build/dependencies.props b/build/dependencies.props index 3fa6453484..845ea66323 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15679 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 0.5.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 - 2.1.0-preview1-28153 + 2.1.0-preview1-1010 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 0.5.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 + 2.1.0-preview1-28193 2.0.0 - 2.1.0-preview1-26115-03 + 2.1.0-preview1-26122-01 15.3.0 4.7.49 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a474bc0e35..851bfbf203 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15679 -commithash:5347461137cb45a77ddcc0b55b2478092de43338 +version:2.1.0-preview1-1010 +commithash:75ca924dfbd673c38841025b04c4dcd93b84f56d diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From 97e23887d80c1103ffb421afece1b01cb69898d2 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 1 Feb 2018 03:53:11 +0000 Subject: [PATCH 283/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 458381c64f..02dd1492b9 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview1-15651 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 0.5.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 - 2.1.0-preview1-27965 + 2.1.0-preview2-15692 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 0.5.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 + 2.1.0-preview2-28215 2.0.0 - 2.1.0-preview1-26016-05 + 2.1.0-preview2-26130-04 15.3.0 4.7.49 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2146d006d7..232cb858c2 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview1-15661 -commithash:c9349d4c8a495d3085d9b879214d80f2f45e2193 +version:2.1.0-preview2-15692 +commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 From 614fe90be1fab97a1dd276333dd35c5ab83bc780 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sat, 3 Feb 2018 02:53:53 +0000 Subject: [PATCH 284/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 02dd1492b9..63c749f1f0 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,24 +3,24 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15692 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 0.5.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 - 2.1.0-preview2-28215 + 2.1.0-preview2-15694 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 0.5.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 + 2.1.0-preview2-30020 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 232cb858c2..6f294ef0e6 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15692 -commithash:5d9f445ce3f8492451a6f461df7e739bbed6a7f8 +version:2.1.0-preview2-15694 +commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b From 054f36f91acd230abb7902bd1e37a6c743f40194 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 9 Feb 2018 11:50:50 -0800 Subject: [PATCH 285/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 63c749f1f0..5c8c12f1af 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,24 +3,24 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15694 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 0.5.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 - 2.1.0-preview2-30020 + 2.1.0-preview2-15698 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 0.5.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 + 2.1.0-preview2-30066 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 6f294ef0e6..3e2b56b91b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15694 -commithash:f61af02b48e89592c9aadb7ebaebe84228666c3b +version:2.1.0-preview2-15698 +commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 From 404f18360049a3bc172fce6eaae420b487c2afb0 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 11 Feb 2018 12:31:58 -0800 Subject: [PATCH 286/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5c8c12f1af..6b77ca8991 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,29 +4,29 @@ 2.1.0-preview2-15698 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 0.5.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 - 2.1.0-preview2-30066 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 0.5.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 + 2.1.0-preview2-30077 2.0.0 2.1.0-preview2-26130-04 15.3.0 4.7.49 2.3.1 - 2.3.1 + 2.4.0-beta.1.build3945 From bf6aab278a9330b2b01e294c9de0672c3163ec5b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 18 Feb 2018 12:24:33 -0800 Subject: [PATCH 287/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ korebuild-lock.txt | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 6b77ca8991..a49b02569f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,24 +3,24 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15698 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 0.5.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 - 2.1.0-preview2-30077 + 2.1.0-preview2-15707 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 0.5.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 + 2.1.0-preview2-30131 2.0.0 2.1.0-preview2-26130-04 15.3.0 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3e2b56b91b..89d0ad3d15 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15698 -commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73 +version:2.1.0-preview2-15707 +commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 From fad6ec6b9a07badbd32d4fbc5a3c6ade2ab0b4cf Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 21 Feb 2018 18:27:03 -0800 Subject: [PATCH 288/361] Use FeatureBranchVersionSuffix when generating VersionSuffix --- version.props | 1 + 1 file changed, 1 insertion(+) diff --git a/version.props b/version.props index 370d5ababd..65c8a07e37 100644 --- a/version.props +++ b/version.props @@ -5,6 +5,7 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 + $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From 7e776fe45598c09b1774c2f5fb34a125cb31ea48 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 26 Feb 2018 11:08:24 -0800 Subject: [PATCH 289/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a49b02569f..2741da67e2 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15707 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 0.5.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 - 2.1.0-preview2-30131 + 2.1.0-preview2-15721 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 0.5.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 + 2.1.0-preview2-30187 2.0.0 2.1.0-preview2-26130-04 - 15.3.0 + 15.6.0 4.7.49 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 89d0ad3d15..e6c7fddffa 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15707 -commithash:e74e53f129ab34332947fea7ac7b7591b027cb22 +version:2.1.0-preview2-15721 +commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 From 2141c31a1cbce4d420651c8d0d81373395d4cd08 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:04:55 -0800 Subject: [PATCH 290/361] Use dotnet-core feed in repos --- build/sources.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/sources.props b/build/sources.props index 9feff29d09..9215df9751 100644 --- a/build/sources.props +++ b/build/sources.props @@ -1,10 +1,11 @@ - + $(DotNetRestoreSources) $(RestoreSources); + https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; From b4788ddbe6a597f873de87a179706ef7f05ad754 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 6 Mar 2018 10:04:55 -0800 Subject: [PATCH 291/361] Prepend FeatureBranchVersionPrefix if FeatureBranchVersionSuffix is specified --- version.props | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.props b/version.props index 65c8a07e37..a11ea1ed52 100644 --- a/version.props +++ b/version.props @@ -5,7 +5,8 @@ $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 - $(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) + a- + $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) $(VersionSuffix)-$(BuildNumber) From ef54dad3a39bff434a063849a462507500814755 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 8 Mar 2018 13:06:46 -0800 Subject: [PATCH 292/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 2741da67e2..8d88c84f62 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15721 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 0.5.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 - 2.1.0-preview2-30187 + 2.1.0-preview2-15728 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 0.5.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 + 2.1.0-preview2-30272 2.0.0 - 2.1.0-preview2-26130-04 + 2.1.0-preview2-26225-03 15.6.0 4.7.49 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e6c7fddffa..138d848db1 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15721 -commithash:f9bb4be59e39938ec59a6975257e26099b0d03c1 +version:2.1.0-preview2-15728 +commithash:393377068ddcf51dfee0536536d455f57a828b06 From da8576280beaad34f5df1bda372bca3b649dd956 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:15:47 -0700 Subject: [PATCH 293/361] Branching for 2.1.0-preview2 --- build/dependencies.props | 38 +++++++++++++++++++------------------- build/repo.props | 4 ++-- build/sources.props | 2 +- korebuild-lock.txt | 4 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8d88c84f62..899a04ac19 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,26 +3,26 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 0.5.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview2-15742 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 0.5.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 + 2.1.0-preview2-30355 2.0.0 - 2.1.0-preview2-26225-03 + 2.1.0-preview2-26314-02 15.6.0 4.7.49 2.3.1 diff --git a/build/repo.props b/build/repo.props index 78b0ce5879..d94ff7d00d 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,10 +1,10 @@ - + Internal.AspNetCore.Universe.Lineup - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json diff --git a/build/sources.props b/build/sources.props index 9215df9751..36045f12b5 100644 --- a/build/sources.props +++ b/build/sources.props @@ -6,7 +6,7 @@ $(RestoreSources); https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; + https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 138d848db1..e40ef6651b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15728 -commithash:393377068ddcf51dfee0536536d455f57a828b06 +version:2.1.0-preview2-15742 +commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 From 6c7d01306c899a55f46c4c127f459db5b751cde5 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 11:27:17 -0700 Subject: [PATCH 294/361] Update version prefix to preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index a11ea1ed52..24f2b00a0a 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From e93503fcd7a648b8e81b4068eff488deca7665ce Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 16 Mar 2018 12:32:00 -0700 Subject: [PATCH 295/361] Update KoreBuild channel --- korebuild.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } From 0e7f12bfb3a05ece7e73aceedb985e38023bdba1 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 23 Mar 2018 14:41:22 -0700 Subject: [PATCH 296/361] Add HostFiltering to the default web host --- build/dependencies.props | 37 ++++++++++--------- samples/SampleApp/appsettings.json | 1 + .../HostFilteringStartupFilter.cs | 21 +++++++++++ .../Microsoft.AspNetCore.csproj | 1 + src/Microsoft.AspNetCore/WebHost.cs | 10 +++++ .../CreateDefaultBuilderOfTApp/Startup.cs | 15 +++++++- .../appsettings.json | 1 + 7 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs diff --git a/build/dependencies.props b/build/dependencies.props index 899a04ac19..69c5b8ed06 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,26 +4,27 @@ 2.1.0-preview2-15742 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 0.5.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 0.5.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 + 2.1.0-preview2-30431 2.0.0 2.1.0-preview2-26314-02 - 15.6.0 + 15.6.1 4.7.49 2.3.1 2.4.0-beta.1.build3945 diff --git a/samples/SampleApp/appsettings.json b/samples/SampleApp/appsettings.json index 66f0f7ade6..6a1c35ebcf 100644 --- a/samples/SampleApp/appsettings.json +++ b/samples/SampleApp/appsettings.json @@ -1,4 +1,5 @@ { + "AllowedHosts": "example.com;localhost", "Kestrel": { "EndPoints": { "Http": { diff --git a/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs b/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs new file mode 100644 index 0000000000..56c6d9c34f --- /dev/null +++ b/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs @@ -0,0 +1,21 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; + +namespace Microsoft.AspNetCore +{ + internal class HostFilteringStartupFilter : IStartupFilter + { + public Action Configure(Action next) + { + return app => + { + app.UseHostFiltering(); + next(app); + }; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 949e2a991c..e52a4f74ed 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 1d5a1ecb9f..e9c21ed554 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -182,6 +182,16 @@ namespace Microsoft.AspNetCore logging.AddConsole(); logging.AddDebug(); }) + .ConfigureServices((hostingContext, services) => + { + var hosts = hostingContext.Configuration["AllowedHosts"]?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + services.AddHostFiltering(options => + { + options.AllowedHosts = (hosts?.Length > 0 ? hosts : new[] { "*" }); + }); + + services.AddTransient(); + }) .UseIISIntegration() .UseDefaultServiceProvider((context, options) => { diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs b/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs index eb82a20357..2bfb0cdfe9 100644 --- a/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs +++ b/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs @@ -4,8 +4,11 @@ using System; using System.IO; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.HostFiltering; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; namespace CreateDefaultBuilderOfTApp { @@ -15,11 +18,12 @@ namespace CreateDefaultBuilderOfTApp { app.Run(context => { - return context.Response.WriteAsync(GetResponseMessage(webHostBuilderContext)); + var message = GetResponseMessage(webHostBuilderContext, app.ApplicationServices.GetRequiredService>()); + return context.Response.WriteAsync(message); }); } - private static string GetResponseMessage(WebHostBuilderContext context) + private static string GetResponseMessage(WebHostBuilderContext context, IOptions hostFilteringOptions) { // Verify ContentRootPath set if (!string.Equals(Directory.GetCurrentDirectory(), context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) @@ -53,6 +57,13 @@ namespace CreateDefaultBuilderOfTApp return $"Command line arguments not loaded into Configuration."; } + // Verify allowed hosts were loaded + var hosts = string.Join(',', hostFilteringOptions.Value.AllowedHosts); + if (!string.Equals("example.com,localhost", hosts, StringComparison.Ordinal)) + { + return $"AllowedHosts not loaded into Options."; + } + // TODO: Verify AddConsole called // TODO: Verify AddDebug called // TODO: Verify UseIISIntegration called diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json index 393b080efb..27eb1aaf44 100644 --- a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json +++ b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json @@ -1,5 +1,6 @@ { "settingsKey": "settingsValue", + "AllowedHosts": "example.com;localhost", "Kestrel": { "Endpoints": { "HTTP": { From 811b78d0bf8740a732c8f6999ca39b0bb5ce3872 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 25 Mar 2018 15:47:20 -0700 Subject: [PATCH 297/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 8d88c84f62..8792a2077e 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15728 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 0.5.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 - 2.1.0-preview2-30272 + 2.1.0-preview3-17001 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 0.5.0-preview2-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 + 2.1.0-preview3-32037 2.0.0 - 2.1.0-preview2-26225-03 - 15.6.0 + 2.1.0-preview2-26314-02 + 15.6.1 4.7.49 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 138d848db1..3a326c7d58 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15728 -commithash:393377068ddcf51dfee0536536d455f57a828b06 +version:2.1.0-preview3-17001 +commithash:dda68c56abf0d3b911fe6a2315872c446b314585 From 3235adf61ad3e4ed2b02ee7c09ce0e60d52a2e5f Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Wed, 28 Mar 2018 10:54:29 -0700 Subject: [PATCH 298/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 69c5b8ed06..1e9d6045c4 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15742 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 0.5.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 - 2.1.0-preview2-30431 + 2.1.0-preview2-15749 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 0.5.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 2.0.0 - 2.1.0-preview2-26314-02 + 2.1.0-preview2-26326-03 15.6.1 4.7.49 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e40ef6651b..b8e036fe2c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15742 -commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 +version:2.1.0-preview2-15749 +commithash:5544c9ab20fa5e24b9e155d8958a3c3b6f5f9df9 From f972d15501fa494e39ffc81ef3a594b64780ca4a Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 3 Apr 2018 22:34:25 +0000 Subject: [PATCH 299/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 474cfb47b0..cd184f6706 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17001 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 0.5.0-preview2-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 - 2.1.0-preview3-32037 + 2.1.0-preview3-17002 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 0.5.0-preview2-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 + 2.1.0-preview3-32110 2.0.0 - 2.1.0-preview2-26314-02 + 2.1.0-preview3-26331-01 15.6.1 4.7.49 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3a326c7d58..b3af0b8bce 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17001 -commithash:dda68c56abf0d3b911fe6a2315872c446b314585 +version:2.1.0-preview3-17002 +commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f From 0b5cb8a8b8370a74b6ccbdb9f790e939be788dd3 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Wed, 11 Apr 2018 11:57:46 -0700 Subject: [PATCH 300/361] Reload HostFilteringOptions on change --- src/Microsoft.AspNetCore/WebHost.cs | 17 +++++-- .../WebHostTests.cs | 51 +++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index e9c21ed554..8c49d2eb23 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -5,12 +5,14 @@ using System; using System.IO; using System.Reflection; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.HostFiltering; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore { @@ -184,11 +186,20 @@ namespace Microsoft.AspNetCore }) .ConfigureServices((hostingContext, services) => { - var hosts = hostingContext.Configuration["AllowedHosts"]?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - services.AddHostFiltering(options => + // Fallback + services.PostConfigure(options => { - options.AllowedHosts = (hosts?.Length > 0 ? hosts : new[] { "*" }); + if (options.AllowedHosts == null || options.AllowedHosts.Count == 0) + { + // "AllowedHosts": "localhost;127.0.0.1;[::1]" + var hosts = hostingContext.Configuration["AllowedHosts"]?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + // Fall back to "*" to disable. + options.AllowedHosts = (hosts?.Length > 0 ? hosts : new[] { "*" }); + } }); + // Change notification + services.AddSingleton>( + new ConfigurationChangeTokenSource(hostingContext.Configuration)); services.AddTransient(); }) diff --git a/test/Microsoft.AspNetCore.Tests/WebHostTests.cs b/test/Microsoft.AspNetCore.Tests/WebHostTests.cs index 27f98263f5..e076f0f19c 100644 --- a/test/Microsoft.AspNetCore.Tests/WebHostTests.cs +++ b/test/Microsoft.AspNetCore.Tests/WebHostTests.cs @@ -1,7 +1,13 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using System.Threading; +using Microsoft.AspNetCore.HostFiltering; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Xunit; namespace Microsoft.AspNetCore.Tests @@ -14,5 +20,50 @@ namespace Microsoft.AspNetCore.Tests var builder = WebHost.CreateDefaultBuilder(new string[] { "--urls", "http://localhost:5001" }); Assert.Equal("http://localhost:5001", builder.GetSetting(WebHostDefaults.ServerUrlsKey)); } + + [Fact] + public void WebHostConfiguration_HostFilterOptionsAreReloadable() + { + var host = WebHost.CreateDefaultBuilder() + .Configure(app => { }) + .ConfigureAppConfiguration(configBuilder => + { + configBuilder.Add(new ReloadableMemorySource()); + }).Build(); + var config = host.Services.GetRequiredService(); + var monitor = host.Services.GetRequiredService>(); + var options = monitor.CurrentValue; + + Assert.Contains("*", options.AllowedHosts); + + var changed = new ManualResetEvent(false); + monitor.OnChange(newOptions => + { + changed.Set(); + }); + + config["AllowedHosts"] = "NewHost"; + + Assert.True(changed.WaitOne(TimeSpan.FromSeconds(10))); + options = monitor.CurrentValue; + Assert.Contains("NewHost", options.AllowedHosts); + } + + private class ReloadableMemorySource : IConfigurationSource + { + public IConfigurationProvider Build(IConfigurationBuilder builder) + { + return new ReloadableMemoryProvider(); + } + } + + private class ReloadableMemoryProvider : ConfigurationProvider + { + public override void Set(string key, string value) + { + base.Set(key, value); + OnReload(); + } + } } } From f5dcb7578aa134a368a5687e6ba119cedcda86d8 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Apr 2018 14:18:26 -0700 Subject: [PATCH 301/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index cd184f6706..8c35ce5312 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17002 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 0.5.0-preview2-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 - 2.1.0-preview3-32110 + 2.1.0-preview3-17018 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 0.5.0-preview2-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 + 2.1.0-preview3-32233 2.0.0 - 2.1.0-preview3-26331-01 + 2.1.0-preview3-26413-05 15.6.1 4.7.49 2.3.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b3af0b8bce..b419d767b9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17002 -commithash:b8e4e6ab104adc94c0719bb74229870e9b584a7f +version:2.1.0-preview3-17018 +commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be From 750fd873d172b382ef53a4146872688044fcb2c7 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 16:59:39 -0700 Subject: [PATCH 302/361] Branching for 2.1.0-rc1 --- build/repo.props | 3 ++- korebuild.json | 4 ++-- version.props | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/repo.props b/build/repo.props index 78b0ce5879..dab1601c88 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,9 +1,10 @@ - + Internal.AspNetCore.Universe.Lineup + 2.1.0-rc1-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..678d8bb948 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", + "channel": "release/2.1" } diff --git a/version.props b/version.props index 24f2b00a0a..e27532787e 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - preview3 + rc1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 35351b2677ea47a3ed69e99e4b8ddb68ab28b86d Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 16 Apr 2018 16:59:44 -0700 Subject: [PATCH 303/361] Update version number to 2.2.0 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index 24f2b00a0a..44985cedb3 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ - 2.1.0 - preview3 + 2.2.0 + preview1 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From c3ca4e6d5429b46813f0b6bbabf8f05ba217d6e6 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Apr 2018 16:40:54 -0700 Subject: [PATCH 304/361] Set NETStandardImplicitPackageVersion via dependencies.props --- Directory.Build.targets | 1 + build/dependencies.props | 1 + 2 files changed, 2 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 894b1d0cf8..53b3f6e1da 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -2,5 +2,6 @@ $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(NETStandardLibrary20PackageVersion) diff --git a/build/dependencies.props b/build/dependencies.props index 8c35ce5312..9543b13297 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -25,6 +25,7 @@ 2.0.0 2.1.0-preview3-26413-05 15.6.1 + 2.0.1 4.7.49 2.3.1 2.4.0-beta.1.build3945 From 9a5f4958e20c8cf3698d03bb262b1fd06b60be15 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 19 Apr 2018 22:29:20 -0700 Subject: [PATCH 305/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 42 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9543b13297..67f78ffb83 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,30 +3,30 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview3-17018 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 0.5.0-preview2-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 - 2.1.0-preview3-32233 + 2.1.0-rc1-15774 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 0.5.0-preview2-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 + 2.1.0-rc1-30613 2.0.0 - 2.1.0-preview3-26413-05 + 2.1.0-rc1-26419-02 15.6.1 - 2.0.1 4.7.49 + 2.0.1 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b419d767b9..9d4ef8c888 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.1.0-rc1-15774 +commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 From 647c557e85eb149407f3c84d5c902676ae43d9a4 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 23 Apr 2018 12:17:18 -0700 Subject: [PATCH 306/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 67f78ffb83..62c324eb47 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rc1-15774 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 0.5.0-preview2-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 + 2.2.0-preview1-17037 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 0.5.0-preview3-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 + 2.2.0-preview1-34029 2.0.0 - 2.1.0-rc1-26419-02 + 2.1.0-preview3-26413-05 15.6.1 4.7.49 2.0.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b419d767b9..f27a67b442 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview3-17018 -commithash:af264ca131f212b5ba8aafbc5110fc0fc510a2be +version:2.2.0-preview1-17037 +commithash:557055a86cbdc359c97d4fb1c2d23a3dc7ae731e From c52a4d76397726fb09b67930704105b93caae438 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Apr 2018 12:24:30 -0700 Subject: [PATCH 307/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 42 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 62c324eb47..49dda4205a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,30 +3,30 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17037 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 0.5.0-preview3-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 - 2.2.0-preview1-34029 + 2.2.0-preview1-17042 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 0.5.0-preview3-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 + 2.2.0-preview1-34066 2.0.0 - 2.1.0-preview3-26413-05 + 2.2.0-preview1-26424-04 15.6.1 4.7.49 - 2.0.1 + 2.0.3 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index f27a67b442..335e579e06 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17037 -commithash:557055a86cbdc359c97d4fb1c2d23a3dc7ae731e +version:2.2.0-preview1-17042 +commithash:edf0705d014293c260de763543784330514db9a3 From 2f3f541371e7fba3f9065fc0dc899f1847c30946 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Mon, 30 Apr 2018 14:51:42 -0700 Subject: [PATCH 308/361] Bump version to 2.1.0-rtm --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index e27532787e..b9552451d8 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.1.0 - rc1 + rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 4e1b90774367d96595eb5e990510b6ba1300ee4e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Fri, 4 May 2018 07:43:13 -0700 Subject: [PATCH 309/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 42 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 67f78ffb83..7e85c84ed5 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,30 +3,30 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rc1-15774 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 0.5.0-preview2-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 - 2.1.0-rc1-30613 + 2.1.0-rtm-15783 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 0.5.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 + 2.1.0-rtm-30721 2.0.0 - 2.1.0-rc1-26419-02 + 2.1.0-rtm-26502-02 15.6.1 4.7.49 - 2.0.1 + 2.0.3 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 9d4ef8c888..3673744db9 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rc1-15774 -commithash:ed5ca9de3c652347dbb0158a9a65eff3471d2114 +version:2.1.0-rtm-15783 +commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 From b014a6039937b3475eeca5b48273b7d5cff2e5b9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 6 May 2018 12:23:41 -0700 Subject: [PATCH 310/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 49dda4205a..dae62ad3f3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,25 +3,25 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17042 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 0.5.0-preview3-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 - 2.2.0-preview1-34066 + 2.2.0-preview1-17047 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 0.6.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 + 2.2.0-preview1-34135 2.0.0 2.2.0-preview1-26424-04 15.6.1 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 335e579e06..a16d4b9ee4 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17042 -commithash:edf0705d014293c260de763543784330514db9a3 +version:2.2.0-preview1-17047 +commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c From 7fea7ab5fd4ffbb97c1b659101b3eea37d224129 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 7 May 2018 15:13:25 -0700 Subject: [PATCH 311/361] Upgrade to netcoreapp22 --- Directory.Build.targets | 5 +++- build/dependencies.props | 41 +++++++++++++++--------------- build/repo.props | 3 ++- korebuild-lock.txt | 4 +-- samples/SampleApp/SampleApp.csproj | 2 +- test/Directory.Build.props | 6 ++--- 6 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 53b3f6e1da..78626b773e 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,7 +1,10 @@ - + $(MicrosoftNETCoreApp20PackageVersion) $(MicrosoftNETCoreApp21PackageVersion) + $(MicrosoftNETCoreApp22PackageVersion) $(NETStandardLibrary20PackageVersion) + + 99.9 diff --git a/build/dependencies.props b/build/dependencies.props index dae62ad3f3..5e9be1e40a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,29 +1,30 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17047 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 0.6.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 - 2.2.0-preview1-34135 + 2.2.0-preview1-17048 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 0.6.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 + 2.2.0-preview1-34140 2.0.0 2.2.0-preview1-26424-04 + 2.2.0-preview1-26502-01 15.6.1 4.7.49 2.0.3 diff --git a/build/repo.props b/build/repo.props index 78b0ce5879..17a98ac7e7 100644 --- a/build/repo.props +++ b/build/repo.props @@ -1,4 +1,4 @@ - + @@ -10,5 +10,6 @@ + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a16d4b9ee4..2573a03995 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17047 -commithash:e1957b52ddc8b62bd39c5c400322fccb5364624c +version:2.2.0-preview1-17048 +commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8 diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index 622f64cc4c..64ab5e297e 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1;net461 + netcoreapp2.2;net461 aspnetcore-MetaPackagesSampleApp-20170406180413 diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 2a4205c758..b8557e9f98 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,10 +1,10 @@ - + - netcoreapp2.1 + netcoreapp2.2 $(DeveloperBuildTestTfms) - netcoreapp2.1;netcoreapp2.0 + $(StandardTestTfms);net461 From 80d05bdebc91f732611331ab7aedc73eecce5b3b Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 13 May 2018 14:16:20 -0700 Subject: [PATCH 312/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 44 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 5e9be1e40a..4b5c6a5f63 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,30 +1,30 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17048 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 0.6.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 - 2.2.0-preview1-34140 + 2.2.0-preview1-17051 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 0.6.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 + 2.2.0-preview1-34184 2.0.0 - 2.2.0-preview1-26424-04 - 2.2.0-preview1-26502-01 + 2.1.0-rc1 + 2.2.0-preview1-26509-06 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 2573a03995..89629b454c 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17048 -commithash:de14a0ee5fb48508ee8a29c14280a2928f8dabf8 +version:2.2.0-preview1-17051 +commithash:253c3a480063bc3abaa5cde42f6e27b58457ef9b From 6d5863a03301d965ded80543835c30600ea733d5 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Mon, 14 May 2018 08:09:47 -0700 Subject: [PATCH 313/361] Fix tests failing after netcoreapp2.2 migration --- .../CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj | 4 ++-- .../CreateDefaultBuilderOfTApp.csproj | 4 ++-- .../DependencyInjectionApp/DependencyInjectionApp.csproj | 4 ++-- .../StartRequestDelegateUrlApp.csproj | 4 ++-- .../StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj | 4 ++-- .../StartWithIApplicationBuilderUrlApp.csproj | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj index 7b43959e2f..9fc88e0995 100644 --- a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj +++ b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp2.0 + netcoreapp2.2 aspnetcore-CreateDefaultBuilder-20170424224131 diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj b/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj index c73ee499ff..beca85599c 100644 --- a/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj +++ b/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp2.0 + netcoreapp2.2 aspnetcore-CreateDefaultBuilderOfT-20170424224131 diff --git a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj index 7930c4a822..f52140e4d0 100644 --- a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj +++ b/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp2.0 + netcoreapp2.2 diff --git a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj index 7930c4a822..f52140e4d0 100644 --- a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj +++ b/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp2.0 + netcoreapp2.2 diff --git a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj index 7930c4a822..f52140e4d0 100644 --- a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj +++ b/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp2.0 + netcoreapp2.2 diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj index 7930c4a822..f52140e4d0 100644 --- a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj +++ b/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj @@ -1,8 +1,8 @@ - + Exe - netcoreapp2.0 + netcoreapp2.2 From e25ebbb5e0cd6ca6bc056858948463bfd0c2091f Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 20 May 2018 19:39:35 +0000 Subject: [PATCH 314/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 38 +++++++++++++++++++------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 4b5c6a5f63..517514fadf 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,25 +3,25 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17051 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 0.6.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 - 2.2.0-preview1-34184 + 2.2.0-preview1-17060 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 0.6.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 + 2.2.0-preview1-34255 2.0.0 2.1.0-rc1 2.2.0-preview1-26509-06 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 89629b454c..cf2fff7def 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17051 -commithash:253c3a480063bc3abaa5cde42f6e27b58457ef9b +version:2.2.0-preview1-17060 +commithash:25b4b134d6f8f7b461928f0d495cfc695ccabb5b From 30b506a02d05686c96c58b3c1841775a283c0cdc Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 24 May 2018 10:02:01 -0700 Subject: [PATCH 315/361] Update dependencies.props --- build/dependencies.props | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 517514fadf..64c96df104 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,27 +4,27 @@ 2.2.0-preview1-17060 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 0.6.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 - 2.2.0-preview1-34255 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 0.6.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 + 2.2.0-preview1-34298 2.0.0 2.1.0-rc1 - 2.2.0-preview1-26509-06 + 2.2.0-preview1-26524-01 15.6.1 4.7.49 2.0.3 From 48a9013e089a8d15a3314c83e14679d789fd894d Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Thu, 24 May 2018 11:18:31 -0700 Subject: [PATCH 316/361] Do not overwrite ContentRoot #267 --- src/Microsoft.AspNetCore/WebHost.cs | 20 +++++++++++-------- .../WebHostFunctionalTests.cs | 4 ++-- .../CreateDefaultBuilderApp/Program.cs | 5 +++-- .../CreateDefaultBuilderOfTApp/Startup.cs | 5 +++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 8c49d2eb23..987d9afd2c 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -149,12 +149,21 @@ namespace Microsoft.AspNetCore /// The initialized . public static IWebHostBuilder CreateDefaultBuilder(string[] args) { - var builder = new WebHostBuilder() - .UseKestrel((builderContext, options) => + var builder = new WebHostBuilder(); + + if (string.IsNullOrEmpty(builder.GetSetting(WebHostDefaults.ContentRootKey))) + { + builder.UseContentRoot(Directory.GetCurrentDirectory()); + } + if (args != null) + { + builder.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build()); + } + + builder.UseKestrel((builderContext, options) => { options.Configure(builderContext.Configuration.GetSection("Kestrel")); }) - .UseContentRoot(Directory.GetCurrentDirectory()) .ConfigureAppConfiguration((hostingContext, config) => { var env = hostingContext.HostingEnvironment; @@ -209,11 +218,6 @@ namespace Microsoft.AspNetCore options.ValidateScopes = context.HostingEnvironment.IsDevelopment(); }); - if (args != null) - { - builder.UseConfiguration(new ConfigurationBuilder().AddCommandLine(args).Build()); - } - return builder; } diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index b882205779..4942fefb39 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -52,7 +52,7 @@ namespace Microsoft.AspNetCore.Tests var applicationName = "CreateDefaultBuilderApp"; await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { - var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken, retryCount: 5); var responseText = await response.Content.ReadAsStringAsync(); try @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Tests var applicationName = "CreateDefaultBuilderOfTApp"; await ExecuteTestApp(applicationName, async (deploymentResult, logger) => { - var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken); + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken, retryCount: 5); var responseText = await response.Content.ReadAsStringAsync(); try diff --git a/test/TestSites/CreateDefaultBuilderApp/Program.cs b/test/TestSites/CreateDefaultBuilderApp/Program.cs index e8b91c67c0..e0002ced01 100644 --- a/test/TestSites/CreateDefaultBuilderApp/Program.cs +++ b/test/TestSites/CreateDefaultBuilderApp/Program.cs @@ -35,9 +35,10 @@ namespace CreateDefaultBuilderApp private static string GetResponseMessage(WebHostBuilderContext context, IServiceCollection services) { // Verify ContentRootPath set - if (!string.Equals(Directory.GetCurrentDirectory(), context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) + var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT"); + if (!string.Equals(contentRoot, context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) { - return $"Current directory incorrect. Expected: {Directory.GetCurrentDirectory()} Actual: {context.HostingEnvironment.ContentRootPath}"; + return $"ContentRootPath incorrect. Expected: {contentRoot} Actual: {context.HostingEnvironment.ContentRootPath}"; } // Verify appsettings.json loaded diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs b/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs index 2bfb0cdfe9..4d607bffc0 100644 --- a/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs +++ b/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs @@ -26,9 +26,10 @@ namespace CreateDefaultBuilderOfTApp private static string GetResponseMessage(WebHostBuilderContext context, IOptions hostFilteringOptions) { // Verify ContentRootPath set - if (!string.Equals(Directory.GetCurrentDirectory(), context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) + var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT"); + if (!string.Equals(contentRoot, context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) { - return $"Current directory incorrect. Expected: {Directory.GetCurrentDirectory()} Actual: {context.HostingEnvironment.ContentRootPath}"; + return $"ContentRootPath incorrect. Expected: {contentRoot} Actual: {context.HostingEnvironment.ContentRootPath}"; } // Verify appsettings.json loaded From c474b99d8d4aec00e3b3ff7be8e341dc205a9c5b Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Fri, 25 May 2018 16:16:14 -0700 Subject: [PATCH 317/361] Update bootstrapper scripts (automated commit) [ci skip] --- run.ps1 | 25 +++++++++++++++++++------ run.sh | 33 +++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/run.ps1 b/run.ps1 index 27dcf848f8..3b27382468 100644 --- a/run.ps1 +++ b/run.ps1 @@ -26,12 +26,18 @@ The base url where build tools can be downloaded. Overrides the value from the c .PARAMETER Update Updates KoreBuild to the latest version even if a lock file is present. +.PARAMETER Reinstall +Re-installs KoreBuild + .PARAMETER ConfigFile The path to the configuration file that stores values. Defaults to korebuild.json. .PARAMETER ToolsSourceSuffix The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. +.PARAMETER CI +Sets up CI specific settings and variables. + .PARAMETER Arguments Arguments to be passed to the command @@ -65,8 +71,10 @@ param( [string]$ToolsSource, [Alias('u')] [switch]$Update, - [string]$ConfigFile, + [switch]$Reinstall, [string]$ToolsSourceSuffix, + [string]$ConfigFile = $null, + [switch]$CI, [Parameter(ValueFromRemainingArguments = $true)] [string[]]$Arguments ) @@ -93,6 +101,10 @@ function Get-KoreBuild { $version = $version.TrimStart('version:').Trim() $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) + if ($Reinstall -and (Test-Path $korebuildPath)) { + Remove-Item -Force -Recurse $korebuildPath + } + if (!(Test-Path $korebuildPath)) { Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" New-Item -ItemType Directory -Path $korebuildPath | Out-Null @@ -101,9 +113,9 @@ function Get-KoreBuild { try { $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { + if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) { # Use built-in commands where possible as they are cross-plat compatible - Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath + Microsoft.PowerShell.Archive\Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath } else { # Fallback to old approach for old installations of PowerShell @@ -167,8 +179,9 @@ if (Test-Path $ConfigFile) { } } catch { - Write-Warning "$ConfigFile could not be read. Its settings will be ignored." - Write-Warning $Error[0] + Write-Host -ForegroundColor Red $Error[0] + Write-Error "$ConfigFile contains invalid JSON." + exit 1 } } @@ -188,7 +201,7 @@ $korebuildPath = Get-KoreBuild Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile + Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI Invoke-KoreBuildCommand $Command @Arguments } finally { diff --git a/run.sh b/run.sh index 834961fc3a..02aac15874 100755 --- a/run.sh +++ b/run.sh @@ -14,10 +14,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" [ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" verbose=false update=false +reinstall=false repo_path="$DIR" channel='' tools_source='' tools_source_suffix='' +ci=false # # Functions @@ -38,6 +40,8 @@ __usage() { echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." echo " -u|--update Update to the latest KoreBuild even if the lock file is present." + echo " --reinstall Reinstall KoreBuild." + echo " --ci Apply CI specific settings and environment variables." echo "" echo "Description:" 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." @@ -62,6 +66,10 @@ get_korebuild() { version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" + if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then + rm -rf "$korebuild_path" + fi + { if [ ! -d "$korebuild_path" ]; then mkdir -p "$korebuild_path" @@ -175,6 +183,12 @@ while [[ $# -gt 0 ]]; do -u|--update|-Update) update=true ;; + --reinstall|-[Rr]einstall) + reinstall=true + ;; + --ci|-[Cc][Ii]) + ci=true + ;; --verbose|-Verbose) verbose=true ;; @@ -206,17 +220,28 @@ if [ -f "$config_file" ]; then config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" else - __warn "$config_file is invalid JSON. Its settings will be ignored." + _error "$config_file contains invalid JSON." + exit 1 fi elif __machine_has python ; then if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then 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 '')")" 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 '')")" else - __warn "$config_file is invalid JSON. Its settings will be ignored." + _error "$config_file contains invalid JSON." + exit 1 + fi + elif __machine_has python3 ; then + if python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then + 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 '')")" + 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 '')")" + else + _error "$config_file contains invalid JSON." + exit 1 fi else - __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' + _error 'Missing required command: jq or python. Could not parse the JSON file.' + exit 1 fi [ ! -z "${config_channel:-}" ] && channel="$config_channel" @@ -227,5 +252,5 @@ fi [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" +set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" invoke_korebuild_command "$command" "$@" From aadd74527c7f64e42bb1ea22c76dea7131265646 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 27 May 2018 19:22:15 +0000 Subject: [PATCH 318/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 64c96df104..53eb322ccc 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,28 +3,28 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17060 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 0.6.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 - 2.2.0-preview1-34298 + 2.2.0-preview1-17064 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 0.6.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 + 2.2.0-preview1-34326 2.0.0 2.1.0-rc1 - 2.2.0-preview1-26524-01 + 2.2.0-preview1-26526-03 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index cf2fff7def..3028b66761 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17060 -commithash:25b4b134d6f8f7b461928f0d495cfc695ccabb5b +version:2.2.0-preview1-17064 +commithash:5380a2461b135b261646f31d1c919ab0a7b577a8 From eb6dbe37d3c161151b1732eedd4d59ac15a52d4a Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 29 May 2018 09:45:50 -0700 Subject: [PATCH 319/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 7e85c84ed5..a665cb8f1a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-rtm-15783 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 0.5.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 - 2.1.0-rtm-30721 + 2.1.1-rtm-15790 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 0.5.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 + 2.1.0 2.0.0 - 2.1.0-rtm-26502-02 + 2.1.0 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3673744db9..cd5b409a1e 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-rtm-15783 -commithash:5fc2b2f607f542a2ffde11c19825e786fc1a3774 +version:2.1.1-rtm-15790 +commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 From 10e735d42002db959e1a769a3362c84ec0ef1c27 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 30 May 2018 09:50:03 -0700 Subject: [PATCH 320/361] Bumping version from 2.1.0 to 2.1.1 --- version.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.props b/version.props index b9552451d8..669c874829 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@ - + - 2.1.0 + 2.1.1 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From a797456a0d20c465bf5a1d19dd48a1fda45f278a Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 3 Jun 2018 19:21:25 +0000 Subject: [PATCH 321/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 42 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 53eb322ccc..78631007d6 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,28 +3,28 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17064 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 0.6.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 - 2.2.0-preview1-34326 + 2.2.0-preview1-17067 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 0.6.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 + 2.2.0-preview1-34373 2.0.0 - 2.1.0-rc1 - 2.2.0-preview1-26526-03 + 2.1.0 + 2.2.0-preview1-26531-03 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3028b66761..06ba6285b7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17064 -commithash:5380a2461b135b261646f31d1c919ab0a7b577a8 +version:2.2.0-preview1-17067 +commithash:2af0e2e3d02329b4f0290061ab9bd8c7ca1aa26f From 59eeb37a292d065723a24ca001e4b88d93236696 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 5 Jun 2018 22:33:35 -0700 Subject: [PATCH 322/361] Add certificate names for code signing --- Directory.Build.props | 2 ++ korebuild-lock.txt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 9bcc46cef9..465808b636 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,6 +15,8 @@ false $(MSBuildThisFileDirectory)build\Key.snk true + Microsoft + MicrosoftNuGet true true diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 06ba6285b7..b679b80427 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17067 -commithash:2af0e2e3d02329b4f0290061ab9bd8c7ca1aa26f +version:2.2.0-preview1-17075 +commithash:d9f07c7f313a0af1d49f003f5424b4dbbdd3e09f From 24025a21a84b7fe29308cd86168cabf0168918e9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Thu, 7 Jun 2018 19:42:24 +0000 Subject: [PATCH 323/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 78631007d6..3414291ae7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,28 +3,28 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17067 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 0.6.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 - 2.2.0-preview1-34373 + 2.2.0-preview1-17081 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 0.6.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 + 2.2.0-preview1-34411 2.0.0 2.1.0 - 2.2.0-preview1-26531-03 + 2.2.0-preview1-26606-01 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index b679b80427..deb7e546f0 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17075 -commithash:d9f07c7f313a0af1d49f003f5424b4dbbdd3e09f +version:2.2.0-preview1-17081 +commithash:73f09c256e2a54270951562ecc0ef4a953926c36 From b6666c405de48c9834df57b1e7ef1bb6b0a818f2 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 7 Jun 2018 15:46:36 -0700 Subject: [PATCH 324/361] Adding VSTS file --- .vsts-pipelines/builds/ci-internal.yml | 13 +++++++++++++ .vsts-pipelines/builds/ci-public.yml | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .vsts-pipelines/builds/ci-internal.yml create mode 100644 .vsts-pipelines/builds/ci-public.yml diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml new file mode 100644 index 0000000000..d7ceb76378 --- /dev/null +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -0,0 +1,13 @@ +trigger: +- dev +- release/* + +resources: + repositories: + - repository: buildtools + type: git + name: aspnet-BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml new file mode 100644 index 0000000000..b7f25723f8 --- /dev/null +++ b/.vsts-pipelines/builds/ci-public.yml @@ -0,0 +1,15 @@ +trigger: +- dev +- release/* + +# See https://github.com/aspnet/BuildTools +resources: + repositories: + - repository: buildtools + type: github + endpoint: DotNet-Bot GitHub Connection + name: aspnet/BuildTools + ref: refs/heads/dev + +phases: +- template: .vsts-pipelines/templates/project-ci.yml@buildtools From d5cd1cf82110eea62b625783247b5289059a61fa Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 12 Jun 2018 19:27:27 +0000 Subject: [PATCH 325/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index a665cb8f1a..245ab9cb19 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,27 +3,27 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.1-rtm-15790 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 0.5.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 - 2.1.0 + 2.1.1-rtm-15793 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 0.5.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 + 2.1.1 2.0.0 - 2.1.0 + 2.1.1 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index cd5b409a1e..bc84e0cd53 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15790 -commithash:274c65868e735f29f4078c1884c61c4371ee1fc0 +version:2.1.1-rtm-15793 +commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a From 337c3a3a7013709e07fa47c7bc5b5745092c5389 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 30 May 2018 15:23:30 -0700 Subject: [PATCH 326/361] Bumping version from 2.1.1 to 2.1.2 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 669c874829..478dfd16ed 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.1 + 2.1.2 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From a6caaec7b46a9fcd64fb05b1d12adf5d4b9622c9 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 25 Jun 2018 11:22:27 -0700 Subject: [PATCH 327/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3414291ae7..381b8e9529 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,28 +3,28 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17081 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 0.6.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 - 2.2.0-preview1-34411 + 2.2.0-preview1-17090 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 0.6.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 + 2.2.0-preview1-34530 2.0.0 2.1.0 - 2.2.0-preview1-26606-01 + 2.2.0-preview1-26618-02 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index deb7e546f0..a8109db529 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17081 -commithash:73f09c256e2a54270951562ecc0ef4a953926c36 +version:2.2.0-preview1-17090 +commithash:b19e903e946579cd9482089bce7d917e8bacd765 From e4d891c6f67c9f8e3105081d338091b05f357296 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 27 Jun 2018 13:39:49 -0700 Subject: [PATCH 328/361] Bumping version from 2.1.2 to 2.1.3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 478dfd16ed..8d05c92ab8 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.2 + 2.1.3 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From 68cecdbee0bb26256bf4c5fe334a41d4f38ae6af Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 28 Jun 2018 16:20:53 -0700 Subject: [PATCH 329/361] Update infrastructure for the 2.2 release --- .vsts-pipelines/builds/ci-internal.yml | 4 ++-- .vsts-pipelines/builds/ci-public.yml | 6 +++--- build/repo.props | 1 + korebuild.json | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml index d7ceb76378..dc7b8a3cb9 100644 --- a/.vsts-pipelines/builds/ci-internal.yml +++ b/.vsts-pipelines/builds/ci-internal.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* resources: @@ -7,7 +7,7 @@ resources: - repository: buildtools type: git name: aspnet-BuildTools - ref: refs/heads/dev + ref: refs/heads/release/2.2 phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml index b7f25723f8..f5087d9c30 100644 --- a/.vsts-pipelines/builds/ci-public.yml +++ b/.vsts-pipelines/builds/ci-public.yml @@ -1,5 +1,5 @@ trigger: -- dev +- master - release/* # See https://github.com/aspnet/BuildTools @@ -9,7 +9,7 @@ resources: type: github endpoint: DotNet-Bot GitHub Connection name: aspnet/BuildTools - ref: refs/heads/dev - + ref: refs/heads/release/2.2 + phases: - template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/build/repo.props b/build/repo.props index 17a98ac7e7..f1fe24dd27 100644 --- a/build/repo.props +++ b/build/repo.props @@ -4,6 +4,7 @@ Internal.AspNetCore.Universe.Lineup + 2.2.0-* https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json diff --git a/korebuild.json b/korebuild.json index bd5d51a51b..d217d06e3e 100644 --- a/korebuild.json +++ b/korebuild.json @@ -1,4 +1,4 @@ { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev" + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.2/tools/korebuild.schema.json", + "channel": "release/2.2" } From 36ea388e9b09fa721f590e1cf915b8e437730192 Mon Sep 17 00:00:00 2001 From: Patrick Westerhoff Date: Fri, 6 Jul 2018 01:13:28 +0200 Subject: [PATCH 330/361] Remove doc about unshipped default configuration (#274) --- src/Microsoft.AspNetCore/WebHost.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 987d9afd2c..31ab9461d2 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -122,16 +122,15 @@ namespace Microsoft.AspNetCore /// load from 'appsettings.json' and 'appsettings.[].json', /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, - /// configures the to log to the console and debug output, - /// enables IIS integration, - /// and enables the ability for frameworks to bind their options to their default configuration sections. + /// configure the to log to the console and debug output, + /// and enable IIS integration. /// /// The initialized . public static IWebHostBuilder CreateDefaultBuilder() => CreateDefaultBuilder(args: null); /// - /// Initializes a new instance of the class with pre-configured defaults. + /// Initializes a new instance of the class with pre-configured defaults. /// /// /// The following defaults are applied to the returned : @@ -141,9 +140,8 @@ namespace Microsoft.AspNetCore /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, /// load from supplied command line args, - /// configures the to log to the console and debug output, - /// enables IIS integration, - /// and enables the ability for frameworks to bind their options to their default configuration sections. + /// configure the to log to the console and debug output, + /// and enable IIS integration. /// /// The command line args. /// The initialized . @@ -232,9 +230,8 @@ namespace Microsoft.AspNetCore /// load from User Secrets when is 'Development' using the entry assembly, /// load from environment variables, /// load from supplied command line args, - /// configures the to log to the console and debug output, - /// enables IIS integration, - /// enables the ability for frameworks to bind their options to their default configuration sections. + /// configure the to log to the console and debug output, + /// enable IIS integration. /// /// The type containing the startup methods for the application. /// The command line args. From 5f4f181c97811e739b295b1bbbf0529f5f147d0d Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 8 Jul 2018 12:21:23 -0700 Subject: [PATCH 331/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 44 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 381b8e9529..c0bb42235a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,33 +3,33 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17090 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 0.6.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.2.0-preview1-34530 - 2.0.0 - 2.1.0 + 2.2.0-preview1-17099 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 0.6.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.2.0-preview1-34640 + 2.0.7 + 2.1.1 2.2.0-preview1-26618-02 15.6.1 4.7.49 2.0.3 2.3.1 - 2.4.0-beta.1.build3945 + 2.4.0-rc.1.build4038 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index a8109db529..27e2e80f9a 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17090 -commithash:b19e903e946579cd9482089bce7d917e8bacd765 +version:2.2.0-preview1-17099 +commithash:263ed1db9866b6b419b1f5d5189a712aa218acb3 From f1c62f2f78baeca76903a418d9480a6a78de843c Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 11 Jul 2018 18:49:19 -0700 Subject: [PATCH 332/361] Updating dependencies to 2.1.2 and adding a section for pinned variable versions --- build/dependencies.props | 17 ++++++++++++----- korebuild-lock.txt | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 245ab9cb19..248b808db7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -2,16 +2,18 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - 2.1.1-rtm-15793 + + + + 2.1.3-rtm-15802 2.1.1 2.1.1 2.1.1 2.1.1 2.1.1 0.5.1 - 2.1.1 - 2.1.1 + 2.1.2 + 2.1.2 2.1.1 2.1.1 2.1.1 @@ -23,12 +25,17 @@ 2.1.1 2.1.1 2.0.0 - 2.1.1 + 2.1.2 15.6.1 4.7.49 2.0.3 2.3.1 2.4.0-beta.1.build3945 + + + + + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index bc84e0cd53..251c227c83 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.1-rtm-15793 -commithash:988313f4b064d6c69fc6f7b845b6384a6af3447a +version:2.1.3-rtm-15802 +commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a From fb621740a02e1bd2f2438a3b04459b439ffdc258 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 12 Jul 2018 11:55:36 -0700 Subject: [PATCH 333/361] Pin version variables to the ASP.NET Core 2.1.2 baseline This reverts our previous policy of cascading versions on all servicing updates. This moves variables into the 'pinned' section, and points them to the latest stable release (versions that were used at the time of the 2.1.2 release). --- build/dependencies.props | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 248b808db7..d88fdc5c8a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,8 +4,15 @@ - + 2.1.3-rtm-15802 + 2.0.0 + 2.1.2 + 15.6.1 + 4.7.49 + 2.0.3 + 2.3.1 + 2.4.0-beta.1.build3945 2.1.1 2.1.1 2.1.1 @@ -24,13 +31,6 @@ 2.1.1 2.1.1 2.1.1 - 2.0.0 - 2.1.2 - 15.6.1 - 4.7.49 - 2.0.3 - 2.3.1 - 2.4.0-beta.1.build3945 From 24a80d755343220557f44723a26d0d1fbe91b184 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 12 Jul 2018 14:23:37 -0700 Subject: [PATCH 334/361] fixup! Pin version variables to the ASP.NET Core 2.1.2 baseline --- build/dependencies.props | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d88fdc5c8a..bca0b5e999 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -6,13 +6,6 @@ 2.1.3-rtm-15802 - 2.0.0 - 2.1.2 - 15.6.1 - 4.7.49 - 2.0.3 - 2.3.1 - 2.4.0-beta.1.build3945 2.1.1 2.1.1 2.1.1 @@ -31,6 +24,13 @@ 2.1.1 2.1.1 2.1.1 + 2.0.0 + 2.1.2 + 15.6.1 + 4.7.49 + 2.0.3 + 2.3.1 + 2.4.0-beta.1.build3945 From 4e581a2a4fed2fa472ffca942b0b628b01ee9d47 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 15 Jul 2018 12:20:46 -0700 Subject: [PATCH 335/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index c0bb42235a..67d4134bef 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,26 +4,26 @@ 2.2.0-preview1-17099 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 0.6.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.2.0-preview1-34640 - 2.0.7 - 2.1.1 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 0.6.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.2.0-preview1-34694 + 2.0.9 + 2.1.2 2.2.0-preview1-26618-02 15.6.1 4.7.49 From 06a25a93c2bdb01f2d69e7a60c5590bee21ef8c8 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 22 Jul 2018 12:20:09 -0700 Subject: [PATCH 336/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 67d4134bef..d5392bf9cc 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,24 +4,24 @@ 2.2.0-preview1-17099 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 0.6.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 - 2.2.0-preview1-34694 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 0.6.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 + 2.2.0-preview1-34755 2.0.9 2.1.2 2.2.0-preview1-26618-02 From 5875ff40b11c686535c762a1fc0c49ca9e38fdb3 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 27 Jul 2018 10:18:56 -0700 Subject: [PATCH 337/361] Add UseIIS to CreateDefaultBuilder (#278) --- build/dependencies.props | 6 ++- .../Microsoft.AspNetCore.csproj | 3 +- src/Microsoft.AspNetCore/WebHost.cs | 1 + ...icrosoft.AspNetCore.FunctionalTests.csproj | 1 + .../WebHostFunctionalTests.cs | 48 +++++++++++++++++-- .../CreateDefaultBuilderApp.csproj | 6 +++ 6 files changed, 60 insertions(+), 5 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d5392bf9cc..ce1352aac0 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,12 +4,16 @@ 2.2.0-preview1-17099 + 2.2.0-a-preview1-croot-17070 + 2.2.0-a-preview1-croot-17070 2.2.0-preview1-34755 2.2.0-preview1-34755 2.2.0-preview1-34755 2.2.0-preview1-34755 - 2.2.0-preview1-34755 + 2.2.0-a-preview1-croot-17070 + 2.2.0-a-preview1-croot-17070 0.6.0-preview1-34755 + 2.2.0-preview1-34755 2.2.0-preview1-34755 2.2.0-preview1-34755 2.2.0-preview1-34755 diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index e52a4f74ed..1e77df2cae 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -13,6 +13,7 @@ + diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 31ab9461d2..985386af34 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -210,6 +210,7 @@ namespace Microsoft.AspNetCore services.AddTransient(); }) + .UseIIS() .UseIISIntegration() .UseDefaultServiceProvider((context, options) => { diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj index d4a5bbdf12..67422e13d6 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj @@ -20,6 +20,7 @@ + diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index 4942fefb39..a017c66d8e 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; using Xunit; @@ -165,6 +166,42 @@ namespace Microsoft.AspNetCore.Tests } } + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] + public async Task RunsInIISExpressInProcess() + { + var applicationName = "CreateDefaultBuilderApp"; + var deploymentParameters = new DeploymentParameters(Path.Combine(_testSitesPath, applicationName), ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) + { + TargetFramework = "netcoreapp2.2", + HostingModel = HostingModel.InProcess, + AncmVersion = AncmVersion.AspNetCoreModuleV2 + }; + + SetEnvironmentVariables(deploymentParameters, "Development"); + + using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory)) + { + var deploymentResult = await deployer.DeployAsync(); + var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), Logger, deploymentResult.HostShutdownToken, retryCount: 5); + + var responseText = await response.Content.ReadAsStringAsync(); + try + { + // Assert server is IISExpress + Assert.Equal("Microsoft-IIS/10.0", response.Headers.Server.ToString()); + // The application name will be sent in response when all asserts succeed in the test app. + Assert.Equal(applicationName, responseText); + } + catch (XunitException) + { + Logger.LogWarning(response.ToString()); + Logger.LogWarning(responseText); + throw; + } + } + } + private async Task ExecuteStartOrStartWithTest(Func> getResponse, string applicationName) { await ExecuteTestApp(applicationName, async (deploymentResult, logger) => @@ -197,11 +234,10 @@ namespace Microsoft.AspNetCore.Tests if (setTestEnvVars) { - deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("aspnetcore_environment", environment)); - deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("envKey", "envValue")); + SetEnvironmentVariables(deploymentParameters, environment); } - using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) + using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) { var deploymentResult = await deployer.DeployAsync(); @@ -210,6 +246,12 @@ namespace Microsoft.AspNetCore.Tests } } + private static void SetEnvironmentVariables(DeploymentParameters deploymentParameters, string environment) + { + deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("aspnetcore_environment", environment)); + deploymentParameters.EnvironmentVariables.Add(new KeyValuePair("envKey", "envValue")); + } + private static string GetTestSitesPath() { var applicationBasePath = AppContext.BaseDirectory; diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj index 9fc88e0995..74fe7e3679 100644 --- a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj +++ b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj @@ -6,6 +6,12 @@ aspnetcore-CreateDefaultBuilder-20170424224131 + + + + + + From a2e96209dccbdb4115a8557ac8b6d5e4aaf14f75 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 29 Jul 2018 12:19:32 -0700 Subject: [PATCH 338/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 49 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index ce1352aac0..6025eb2f94 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,29 +3,29 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17099 - 2.2.0-a-preview1-croot-17070 - 2.2.0-a-preview1-croot-17070 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-a-preview1-croot-17070 - 2.2.0-a-preview1-croot-17070 - 0.6.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 - 2.2.0-preview1-34755 + 2.2.0-preview1-17102 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 0.6.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 + 2.2.0-preview1-34823 2.0.9 2.1.2 2.2.0-preview1-26618-02 @@ -33,7 +33,8 @@ 4.7.49 2.0.3 2.3.1 - 2.4.0-rc.1.build4038 + 2.4.0 + diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 27e2e80f9a..6b8da29e6b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17099 -commithash:263ed1db9866b6b419b1f5d5189a712aa218acb3 +version:2.2.0-preview1-17102 +commithash:e7e2b5a97ca92cfc6acc4def534cb0901a6d1eb9 From ffe45b8aa09195db368db26ce6b4116dd233cbf8 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 5 Aug 2018 19:21:40 +0000 Subject: [PATCH 339/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 46 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 6025eb2f94..617af2d490 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,29 +3,29 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-17102 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 0.6.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 - 2.2.0-preview1-34823 + 2.2.0-preview1-20180731.1 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 0.6.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 + 2.2.0-preview1-34882 2.0.9 2.1.2 2.2.0-preview1-26618-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 6b8da29e6b..c7af2292c7 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-17102 -commithash:e7e2b5a97ca92cfc6acc4def534cb0901a6d1eb9 +version:2.2.0-preview1-20180731.1 +commithash:29fde58465439f4bb9df40830635ed758e063daf From e41703a6cea047df0826824c5f0d79ce35fa15f0 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Mon, 6 Aug 2018 20:44:17 +0000 Subject: [PATCH 340/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 617af2d490..ac93ddd7ea 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,28 +4,28 @@ 2.2.0-preview1-20180731.1 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 0.6.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 - 2.2.0-preview1-34882 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 0.6.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 + 2.2.0-preview1-34896 2.0.9 2.1.2 2.2.0-preview1-26618-02 From e692ca5a30d50861b3a593d927d82fcab76da69e Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 12 Aug 2018 19:21:31 +0000 Subject: [PATCH 341/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 46 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index ac93ddd7ea..01bed78ae3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,29 +3,29 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180731.1 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 0.6.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 - 2.2.0-preview1-34896 + 2.2.0-preview1-20180807.2 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 0.6.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 + 2.2.0-preview1-34967 2.0.9 2.1.2 2.2.0-preview1-26618-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index c7af2292c7..3fbcc80189 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180731.1 -commithash:29fde58465439f4bb9df40830635ed758e063daf +version:2.2.0-preview1-20180807.2 +commithash:11495dbd236104434e08cb1152fcb58cf2a20923 From 8f0e948d609fc250b13ed2a20408fa92ee3607ba Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 21 Aug 2018 13:33:51 -0700 Subject: [PATCH 342/361] Update package branding for 2.2.0-preview2 --- build/dependencies.props | 2 +- version.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 01bed78ae3..ae1b2804ff 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -35,6 +35,6 @@ 2.3.1 2.4.0 - + diff --git a/version.props b/version.props index 44985cedb3..15637ba785 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview1 + preview2 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 3dedfa2f61e64e54cd12fd5ed581a0ebe6afc9a4 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 28 Aug 2018 09:07:52 -0700 Subject: [PATCH 343/361] Bumping version from 2.1.3 to 2.1.4 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 8d05c92ab8..c24d014891 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.3 + 2.1.4 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From d022ce775b3dc178f66965ef7fe6d502aaed1fcd Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 2 Sep 2018 12:20:10 -0700 Subject: [PATCH 344/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 46 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index ae1b2804ff..d01a44aa25 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,29 +3,29 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180807.2 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 0.6.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 - 2.2.0-preview1-34967 + 2.2.0-preview1-20180821.1 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 0.6.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 + 2.2.0-preview2-35143 2.0.9 2.1.2 2.2.0-preview1-26618-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 3fbcc80189..ad704918df 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180807.2 -commithash:11495dbd236104434e08cb1152fcb58cf2a20923 +version:2.2.0-preview1-20180821.1 +commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 From 16eb603cb216ab4c58c5da3fa12e3ba349daad77 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Wed, 5 Sep 2018 16:35:27 -0700 Subject: [PATCH 345/361] Update branding to 2.2.0-preview3 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index 15637ba785..704cac087b 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview2 + preview3 $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From b9f5b26a2ec9ccfaa015f45076a561d56b883de7 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 9 Sep 2018 12:22:30 -0700 Subject: [PATCH 346/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 50 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index d01a44aa25..858651f107 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,32 +3,32 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180821.1 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 0.6.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 - 2.2.0-preview2-35143 + 2.2.0-preview1-20180907.8 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 0.6.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 2.0.9 - 2.1.2 - 2.2.0-preview1-26618-02 + 2.1.3 + 2.2.0-preview2-26905-02 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index ad704918df..312f82f9a5 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180821.1 -commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 +version:2.2.0-preview1-20180907.8 +commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 From badd2e81b80dd572c0399be113ef19465d647fdf Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 16 Sep 2018 12:21:02 -0700 Subject: [PATCH 347/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 46 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 858651f107..47c8d4ca18 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,29 +3,29 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180907.8 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 0.6.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 - 2.2.0-preview3-35202 + 2.2.0-preview1-20180911.1 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 0.6.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 + 2.2.0-preview3-35252 2.0.9 2.1.3 2.2.0-preview2-26905-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 312f82f9a5..7124f37441 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180907.8 -commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 +version:2.2.0-preview1-20180911.1 +commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 From fc42580cd2f7edfedc2ab08c883d2adc6a07ec5f Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 23 Sep 2018 19:23:51 +0000 Subject: [PATCH 348/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 46 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 47c8d4ca18..67d298eea1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,29 +3,29 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180911.1 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 0.6.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 - 2.2.0-preview3-35252 + 2.2.0-preview1-20180918.1 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 0.6.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 + 2.2.0-preview3-35301 2.0.9 2.1.3 2.2.0-preview2-26905-02 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 7124f37441..649bf2ba0b 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180911.1 -commithash:ddfecdfc6e8e4859db5a0daea578070b862aac65 +version:2.2.0-preview1-20180918.1 +commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 From f20e2f82aaa3717e97fc109cf7427c259dfb34cf Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 28 Sep 2018 09:52:59 -0700 Subject: [PATCH 349/361] Bumping version from 2.1.4 to 2.1.5 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index c24d014891..16607eed0f 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.4 + 2.1.5 rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From a0323945bc5da22e4157ce46a2ad030c89e61f44 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 28 Sep 2018 11:48:05 -0700 Subject: [PATCH 350/361] Remove PublicSign and unnecessary certificate name properties --- Directory.Build.props | 3 --- 1 file changed, 3 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 465808b636..b0629544b1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,9 +15,6 @@ false $(MSBuildThisFileDirectory)build\Key.snk true - Microsoft - MicrosoftNuGet - true true From bdc9ab00f63a5cdd5c726a9b3bb44a317e7607ed Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 28 Sep 2018 17:10:37 -0700 Subject: [PATCH 351/361] automated: bulk infrastructure updates. Update bootstrapper scripts and remove unnecessary signing properties --- run.ps1 | 6 +++--- run.sh | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/run.ps1 b/run.ps1 index 3b27382468..34604c7175 100644 --- a/run.ps1 +++ b/run.ps1 @@ -52,8 +52,8 @@ in the file are overridden by command line parameters. Example config file: ```json { - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", + "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", + "channel": "master", "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" } ``` @@ -192,7 +192,7 @@ if (!$DotNetHome) { else { Join-Path $PSScriptRoot '.dotnet'} } -if (!$Channel) { $Channel = 'dev' } +if (!$Channel) { $Channel = 'master' } if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } # Execute diff --git a/run.sh b/run.sh index 02aac15874..4c1fed5646 100755 --- a/run.sh +++ b/run.sh @@ -220,7 +220,7 @@ if [ -f "$config_file" ]; then config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi elif __machine_has python ; then @@ -228,7 +228,7 @@ if [ -f "$config_file" ]; then 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 '')")" 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 '')")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi elif __machine_has python3 ; then @@ -236,11 +236,11 @@ if [ -f "$config_file" ]; then 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 '')")" 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 '')")" else - _error "$config_file contains invalid JSON." + __error "$config_file contains invalid JSON." exit 1 fi else - _error 'Missing required command: jq or python. Could not parse the JSON file.' + __error 'Missing required command: jq or python. Could not parse the JSON file.' exit 1 fi @@ -248,7 +248,7 @@ if [ -f "$config_file" ]; then [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" fi -[ -z "$channel" ] && channel='dev' +[ -z "$channel" ] && channel='master' [ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' get_korebuild From a3cb22f171d6c5c19c4d64953fb8f842941e87e7 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 30 Sep 2018 12:24:03 -0700 Subject: [PATCH 352/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 48 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 67d298eea1..927ea83b25 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,32 +3,32 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180918.1 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 0.6.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 - 2.2.0-preview3-35301 + 2.2.0-preview1-20180928.5 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 0.6.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 + 2.2.0-preview3-35359 2.0.9 2.1.3 - 2.2.0-preview2-26905-02 + 2.2.0-preview3-26927-02 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 649bf2ba0b..26697a21fa 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180918.1 -commithash:ad5e3fc53442741a0dd49bce437d2ac72f4b5800 +version:2.2.0-preview1-20180928.5 +commithash:43faa29f679f47b88689d645b39e6be5e0055d70 From 96be626c87c3ca325b18aa6653602f5e7087497f Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 5 Oct 2018 12:09:55 -0700 Subject: [PATCH 353/361] Update branding to 2.1.6-servicing (#289) Per discussion with our team, we want to make the following changes to versioning during servicing updates: * The versioning on packages with ship with ASP.NET Core should be consistent * (No change) on packages with changes in them ship during servicing updates * Version gaps are okay. For example, this repo is producing a patch for 2.1.6, so packages will be 2.1.6. It did not patch for 2.1.4 or 2.1.3 so those versions will be skipped. This also includes another minor change: for consistency with the rest of the .NET Core teams, pre-release servicing builds will be 2.1.x-servicing-buildnumber. --- version.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/version.props b/version.props index 16607eed0f..a60480f5bf 100644 --- a/version.props +++ b/version.props @@ -1,9 +1,9 @@  - 2.1.5 - rtm - $(VersionPrefix) - $(VersionPrefix)-$(VersionSuffix)-final + 2.1.6 + servicing + $(VersionPrefix) + $(VersionPrefix)-$(VersionSuffix)-final t000 a- $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-')) From ca6ab92ca48dc0d7f488192fee7deda48bc4182a Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 7 Oct 2018 19:24:47 +0000 Subject: [PATCH 354/361] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 48 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 ++-- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 927ea83b25..618ad93c56 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,32 +3,32 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.2.0-preview1-20180928.5 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 0.6.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 - 2.2.0-preview3-35359 + 2.2.0-preview2-20181004.6 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 0.6.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 + 2.2.0-preview3-35425 2.0.9 2.1.3 - 2.2.0-preview3-26927-02 + 2.2.0-preview3-27001-02 15.6.1 4.7.49 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 26697a21fa..96fe3217ef 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180928.5 -commithash:43faa29f679f47b88689d645b39e6be5e0055d70 +version:2.2.0-preview2-20181004.6 +commithash:c04c4b2f5018632647f96210ab01876661302dac From 4347a45f292fe340a5e78c9afddde7e6d2f3dd29 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 8 Oct 2018 09:31:44 -0700 Subject: [PATCH 355/361] Always add event source logger (#287) --- build/dependencies.props | 1 + .../Microsoft.AspNetCore.csproj | 1 + src/Microsoft.AspNetCore/WebHost.cs | 1 + .../WebHostTests.cs | 53 +++++++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/build/dependencies.props b/build/dependencies.props index 618ad93c56..8d12964ca3 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -25,6 +25,7 @@ 2.2.0-preview3-35425 2.2.0-preview3-35425 2.2.0-preview3-35425 + 2.2.0-preview3-35425 2.2.0-preview3-35425 2.0.9 2.1.3 diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj index 1e77df2cae..ea9a676d87 100644 --- a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj +++ b/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj @@ -26,6 +26,7 @@ +
diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Microsoft.AspNetCore/WebHost.cs index 985386af34..10726c8356 100644 --- a/src/Microsoft.AspNetCore/WebHost.cs +++ b/src/Microsoft.AspNetCore/WebHost.cs @@ -190,6 +190,7 @@ namespace Microsoft.AspNetCore logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); logging.AddDebug(); + logging.AddEventSourceLogger(); }) .ConfigureServices((hostingContext, services) => { diff --git a/test/Microsoft.AspNetCore.Tests/WebHostTests.cs b/test/Microsoft.AspNetCore.Tests/WebHostTests.cs index e076f0f19c..4b040e0c03 100644 --- a/test/Microsoft.AspNetCore.Tests/WebHostTests.cs +++ b/test/Microsoft.AspNetCore.Tests/WebHostTests.cs @@ -2,11 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics.Tracing; +using System.Linq; using System.Threading; using Microsoft.AspNetCore.HostFiltering; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Xunit; @@ -49,6 +54,54 @@ namespace Microsoft.AspNetCore.Tests Assert.Contains("NewHost", options.AllowedHosts); } + [Fact] + public void CreateDefaultBuilder_RegistersEventSourceLogger() + { + var listener = new TestEventListener(); + var host = WebHost.CreateDefaultBuilder() + .Configure(_ => { }) + .Build(); + + var logger = host.Services.GetRequiredService>(); + logger.LogInformation("Request starting"); + + var events = listener.EventData.ToArray(); + Assert.Contains(events, args => + args.EventSource.Name == "Microsoft-Extensions-Logging" && + args.Payload.OfType().Any(p => p.Contains("Request starting"))); + } + + private class TestEventListener : EventListener + { + private volatile bool _disposed; + + private ConcurrentQueue _events = new ConcurrentQueue(); + + public IEnumerable EventData => _events; + + protected override void OnEventSourceCreated(EventSource eventSource) + { + if (eventSource.Name == "Microsoft-Extensions-Logging") + { + EnableEvents(eventSource, EventLevel.Informational); + } + } + + protected override void OnEventWritten(EventWrittenEventArgs eventData) + { + if (!_disposed) + { + _events.Enqueue(eventData); + } + } + + public override void Dispose() + { + _disposed = true; + base.Dispose(); + } + } + private class ReloadableMemorySource : IConfigurationSource { public IConfigurationProvider Build(IConfigurationBuilder builder) From f13f262bad34212446bbb27d7c8c6d49aeec8abf Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 9 Oct 2018 11:05:11 -0700 Subject: [PATCH 356/361] Remove ANCM reference from test site (#281) --- .../CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj index 74fe7e3679..9fc88e0995 100644 --- a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj +++ b/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj @@ -6,12 +6,6 @@ aspnetcore-CreateDefaultBuilder-20170424224131 - - - - - - From 9949306ca3229c41fc952edee981d34ece62c637 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Tue, 16 Oct 2018 12:48:17 -0700 Subject: [PATCH 357/361] Update package branding for 2.2 RTM --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index a8d060b064..9b41b556d7 100644 --- a/version.props +++ b/version.props @@ -1,7 +1,7 @@ 2.2.0 - preview3 + rtm $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final t000 From 27efce1042914569097d6c68db404e5286ad7b20 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 29 Oct 2018 17:39:18 -0700 Subject: [PATCH 358/361] Do not use the default 5000 port for functional tests --- .../WebHostFunctionalTests.cs | 48 +++-------- .../CreateDefaultBuilderApp/Program.cs | 32 ++++---- .../CreateDefaultBuilderApp/appsettings.json | 3 +- .../CreateDefaultBuilderOfTApp/Program.cs | 80 ++++++++++++++++++- .../CreateDefaultBuilderOfTApp/Startup.cs | 75 ----------------- .../appsettings.json | 5 +- .../DependencyInjectionApp/Program.cs | 9 +-- 7 files changed, 115 insertions(+), 137 deletions(-) delete mode 100644 test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs index a017c66d8e..d2e71f5778 100644 --- a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs +++ b/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs @@ -4,31 +4,20 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net.Http; using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Testing.xunit; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; using Xunit; -using Xunit.Abstractions; using Xunit.Sdk; namespace Microsoft.AspNetCore.Tests { public class WebHostFunctionalTests : LoggedTest { - private readonly string _testSitesPath; - - public WebHostFunctionalTests(ITestOutputHelper output) : base(output) - { - _testSitesPath = GetTestSitesPath(); - } - [Fact] public async Task Start_RequestDelegate_Url() { @@ -60,8 +49,6 @@ namespace Microsoft.AspNetCore.Tests { // Assert server is Kestrel Assert.Equal("Kestrel", response.Headers.Server.ToString()); - // Set from default config - Assert.Equal("http://localhost:5002/", deploymentResult.ApplicationBaseUri); // The application name will be sent in response when all asserts succeed in the test app. Assert.Equal(applicationName, responseText); } @@ -87,8 +74,6 @@ namespace Microsoft.AspNetCore.Tests { // Assert server is Kestrel Assert.Equal("Kestrel", response.Headers.Server.ToString()); - // Set from default config - Assert.Equal("http://localhost:5002/", deploymentResult.ApplicationBaseUri); // The application name will be sent in response when all asserts succeed in the test app. Assert.Equal(applicationName, responseText); } @@ -139,7 +124,7 @@ namespace Microsoft.AspNetCore.Tests } } "); - using (var webHost = WebHost.Start(context => context.Response.WriteAsync("Hello, World!"))) + using (var webHost = WebHost.Start("http://127.0.0.1:0", context => context.Response.WriteAsync("Hello, World!"))) { var factory = (ILoggerFactory)webHost.Services.GetService(typeof(ILoggerFactory)); var logger = factory.CreateLogger("Test"); @@ -171,13 +156,13 @@ namespace Microsoft.AspNetCore.Tests public async Task RunsInIISExpressInProcess() { var applicationName = "CreateDefaultBuilderApp"; - var deploymentParameters = new DeploymentParameters(Path.Combine(_testSitesPath, applicationName), ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) + var deploymentParameters = new DeploymentParameters(Path.Combine(GetTestSitesPath(), applicationName), ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64) { TargetFramework = "netcoreapp2.2", HostingModel = HostingModel.InProcess, AncmVersion = AncmVersion.AspNetCoreModuleV2 }; - + SetEnvironmentVariables(deploymentParameters, "Development"); using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory)) @@ -227,22 +212,18 @@ namespace Microsoft.AspNetCore.Tests bool setTestEnvVars = false, string environment = "Development") { - using (StartLog(out var loggerFactory, applicationName)) + var deploymentParameters = new DeploymentParameters(Path.Combine(GetTestSitesPath(), applicationName), ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64); + + if (setTestEnvVars) { - var logger = loggerFactory.CreateLogger(nameof(WebHost.Start)); - var deploymentParameters = new DeploymentParameters(Path.Combine(_testSitesPath, applicationName), ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64); + SetEnvironmentVariables(deploymentParameters, environment); + } - if (setTestEnvVars) - { - SetEnvironmentVariables(deploymentParameters, environment); - } + using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, LoggerFactory)) + { + var deploymentResult = await deployer.DeployAsync(); - using (var deployer = IISApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) - { - var deploymentResult = await deployer.DeployAsync(); - - await assertAction(deploymentResult, logger); - } + await assertAction(deploymentResult, Logger); } } @@ -271,10 +252,5 @@ namespace Microsoft.AspNetCore.Tests throw new Exception($"Solution root could not be found using {applicationBasePath}"); } - - private static int GetWebHostPort(IWebHost webHost) - => webHost.ServerFeatures.Get().Addresses - .Select(serverAddress => new Uri(serverAddress).Port) - .FirstOrDefault(); } } diff --git a/test/TestSites/CreateDefaultBuilderApp/Program.cs b/test/TestSites/CreateDefaultBuilderApp/Program.cs index e0002ced01..5d58a6f97b 100644 --- a/test/TestSites/CreateDefaultBuilderApp/Program.cs +++ b/test/TestSites/CreateDefaultBuilderApp/Program.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.IO; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -15,24 +14,29 @@ namespace CreateDefaultBuilderApp { static void Main(string[] args) { - string responseMessage = string.Empty; + string responseMessage = null; WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) - .ConfigureServices((context, services) => - { - responseMessage = GetResponseMessage(context, services); - }) - .Configure(app => - { - app.Run(context => + .ConfigureServices((context, services) => responseMessage = responseMessage ?? GetResponseMessage(context)) + .ConfigureKestrel(options => options + .Configure(options.ConfigurationLoader.Configuration) + .Endpoint("HTTP", endpointOptions => { - return context.Response.WriteAsync(responseMessage); - }); - }) + if (responseMessage == null + && !string.Equals("KestrelEndPointSettingValue", endpointOptions.ConfigSection["KestrelEndPointSettingName"])) + { + responseMessage = "Default Kestrel configuration not read."; + } + })) + .Configure(app => app.Run(context => + { + var hostingEnvironment = app.ApplicationServices.GetRequiredService(); + return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName); + })) .Build().Run(); } - private static string GetResponseMessage(WebHostBuilderContext context, IServiceCollection services) + private static string GetResponseMessage(WebHostBuilderContext context) { // Verify ContentRootPath set var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT"); @@ -71,7 +75,7 @@ namespace CreateDefaultBuilderApp // TODO: Verify AddDebug called // TODO: Verify UseIISIntegration called - return context.HostingEnvironment.ApplicationName; + return null; } } } \ No newline at end of file diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.json b/test/TestSites/CreateDefaultBuilderApp/appsettings.json index 393b080efb..1d28ed80fc 100644 --- a/test/TestSites/CreateDefaultBuilderApp/appsettings.json +++ b/test/TestSites/CreateDefaultBuilderApp/appsettings.json @@ -3,7 +3,8 @@ "Kestrel": { "Endpoints": { "HTTP": { - "Url": "http://localhost:5002" + "Url": "http://127.0.0.1:0", + "KestrelEndPointSettingName": "KestrelEndPointSettingValue" } } } diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs b/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs index fbdc90efee..3419340dc3 100644 --- a/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs +++ b/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs @@ -1,14 +1,92 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.HostFiltering; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; namespace CreateDefaultBuilderOfTApp { public class Program { - static void Main(string[] args) => WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) .Build().Run(); + static void Main(string[] args) + { + string responseMessage = null; + + WebHost.CreateDefaultBuilder(new[] { "--cliKey", "cliValue" }) + .ConfigureServices((context, service) => responseMessage = responseMessage ?? GetResponseMessage(context)) + .ConfigureKestrel(options => options + .Configure(options.ConfigurationLoader.Configuration) + .Endpoint("HTTP", endpointOptions => + { + if (responseMessage == null + && !string.Equals("KestrelEndPointSettingValue", endpointOptions.ConfigSection["KestrelEndPointSettingName"])) + { + responseMessage = "Default Kestrel configuration not read."; + } + })) + .Configure(app => app.Run(context => + { + // Verify allowed hosts were loaded + var hostFilteringOptions = app.ApplicationServices.GetRequiredService>(); + var hosts = string.Join(',', hostFilteringOptions.Value.AllowedHosts); + if (responseMessage == null && !string.Equals("example.com,127.0.0.1", hosts, StringComparison.Ordinal)) + { + responseMessage = "AllowedHosts not loaded into Options."; + } + + var hostingEnvironment = app.ApplicationServices.GetRequiredService(); + return context.Response.WriteAsync(responseMessage ?? hostingEnvironment.ApplicationName); + })) + .Build() + .Run(); + } + + private static string GetResponseMessage(WebHostBuilderContext context) + { + // Verify ContentRootPath set + var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT"); + if (!string.Equals(contentRoot, context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) + { + return $"ContentRootPath incorrect. Expected: {contentRoot} Actual: {context.HostingEnvironment.ContentRootPath}"; + } + + // Verify appsettings.json loaded + if (!string.Equals("settingsValue", context.Configuration["settingsKey"], StringComparison.Ordinal)) + { + return $"appsettings.json not loaded into Configuration."; + } + + // Verify appsettings.environment.json loaded + if (!string.Equals("devSettingsValue", context.Configuration["devSettingsKey"], StringComparison.Ordinal)) + { + return $"appsettings.{context.HostingEnvironment.EnvironmentName}.json not loaded into Configuration."; + } + + // TODO: Verify UserSecrets loaded + + // Verify environment variables loaded + if (!string.Equals("envValue", context.Configuration["envKey"], StringComparison.Ordinal)) + { + return $"Environment variables not loaded into Configuration."; + } + + // Verify command line arguments loaded + if (!string.Equals("cliValue", context.Configuration["cliKey"], StringComparison.Ordinal)) + { + return $"Command line arguments not loaded into Configuration."; + } + + // TODO: Verify AddConsole called + // TODO: Verify AddDebug called + // TODO: Verify UseIISIntegration called + + return null; + } } } \ No newline at end of file diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs b/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs deleted file mode 100644 index 4d607bffc0..0000000000 --- a/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.IO; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.HostFiltering; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; - -namespace CreateDefaultBuilderOfTApp -{ - class Startup - { - public void Configure(IApplicationBuilder app, WebHostBuilderContext webHostBuilderContext) - { - app.Run(context => - { - var message = GetResponseMessage(webHostBuilderContext, app.ApplicationServices.GetRequiredService>()); - return context.Response.WriteAsync(message); - }); - } - - private static string GetResponseMessage(WebHostBuilderContext context, IOptions hostFilteringOptions) - { - // Verify ContentRootPath set - var contentRoot = Environment.GetEnvironmentVariable("ASPNETCORE_CONTENTROOT"); - if (!string.Equals(contentRoot, context.HostingEnvironment.ContentRootPath, StringComparison.Ordinal)) - { - return $"ContentRootPath incorrect. Expected: {contentRoot} Actual: {context.HostingEnvironment.ContentRootPath}"; - } - - // Verify appsettings.json loaded - if (!string.Equals("settingsValue", context.Configuration["settingsKey"], StringComparison.Ordinal)) - { - return $"appsettings.json not loaded into Configuration."; - } - - // Verify appsettings.environment.json loaded - if (!string.Equals("devSettingsValue", context.Configuration["devSettingsKey"], StringComparison.Ordinal)) - { - return $"appsettings.{context.HostingEnvironment.EnvironmentName}.json not loaded into Configuration."; - } - - // TODO: Verify UserSecrets loaded - - // Verify environment variables loaded - if (!string.Equals("envValue", context.Configuration["envKey"], StringComparison.Ordinal)) - { - return $"Environment variables not loaded into Configuration."; - } - - // Verify command line arguments loaded - if (!string.Equals("cliValue", context.Configuration["cliKey"], StringComparison.Ordinal)) - { - return $"Command line arguments not loaded into Configuration."; - } - - // Verify allowed hosts were loaded - var hosts = string.Join(',', hostFilteringOptions.Value.AllowedHosts); - if (!string.Equals("example.com,localhost", hosts, StringComparison.Ordinal)) - { - return $"AllowedHosts not loaded into Options."; - } - - // TODO: Verify AddConsole called - // TODO: Verify AddDebug called - // TODO: Verify UseIISIntegration called - - return context.HostingEnvironment.ApplicationName; - } - } -} diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json index 27eb1aaf44..a2f89f1a54 100644 --- a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json +++ b/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json @@ -1,10 +1,11 @@ { "settingsKey": "settingsValue", - "AllowedHosts": "example.com;localhost", + "AllowedHosts": "example.com;127.0.0.1", "Kestrel": { "Endpoints": { "HTTP": { - "Url": "http://localhost:5002" + "Url": "http://127.0.0.1:0", + "KestrelEndPointSettingName": "KestrelEndPointSettingValue" } } } diff --git a/test/TestSites/DependencyInjectionApp/Program.cs b/test/TestSites/DependencyInjectionApp/Program.cs index 6e4850002b..c8877442e5 100644 --- a/test/TestSites/DependencyInjectionApp/Program.cs +++ b/test/TestSites/DependencyInjectionApp/Program.cs @@ -2,18 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Logging.Console; -using Microsoft.Extensions.Logging.Debug; namespace CreateDefaultBuilderApp { @@ -22,7 +15,7 @@ namespace CreateDefaultBuilderApp static void Main(string[] args) { WebHost.CreateDefaultBuilder() - .UseUrls("http://localhost:5002") + .UseUrls("http://127.0.0.1:0") .ConfigureServices((context, services) => { services.AddSingleton(typeof(IService<>), typeof(Service<>)); From 975011071b02f6937261c604fcde48d7e43030ce Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 7 Nov 2018 14:51:28 -0800 Subject: [PATCH 359/361] Bump version to 2.1.7 --- version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.props b/version.props index a60480f5bf..c5a1f7a6cf 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@  - 2.1.6 + 2.1.7 servicing $(VersionPrefix) $(VersionPrefix)-$(VersionSuffix)-final From 219fd0b3003cb1cfdb3a00ce5b3ef44b21ebe4a8 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Mon, 19 Nov 2018 16:20:16 -0800 Subject: [PATCH 360/361] Reorganize source code in preparation to move into aspnet/AspNetCore Prior to reorganization, this source code was found in https://github.com/aspnet/Metapackages/tree/975011071b02f6937261c604fcde48d7e43030ce --- .appveyor.yml | 17 -- .gitattributes | 52 ---- .travis.yml | 27 -- CONTRIBUTING.md | 4 - LICENSE.txt | 14 -- NuGet.config | 7 - build.cmd | 2 - build.sh | 8 - korebuild-lock.txt | 2 - korebuild.json | 4 - run.cmd | 2 - run.ps1 | 196 --------------- run.sh | 231 ------------------ .gitignore => src/Metapackages/.gitignore | 0 .../Metapackages/Directory.Build.props | 0 .../Metapackages/Directory.Build.targets | 0 .../Metapackages/MetaPackages.sln | 0 .../Metapackages/NuGetPackageVerifier.json | 0 README.md => src/Metapackages/README.md | 0 {build => src/Metapackages/build}/Key.snk | Bin .../Metapackages/build}/dependencies.props | 0 {build => src/Metapackages/build}/repo.props | 0 .../Metapackages/build}/sources.props | 0 .../samples}/SampleApp/Program.cs | 0 .../SampleApp/Properties/launchSettings.json | 0 .../samples}/SampleApp/SampleApp.csproj | 0 .../samples}/SampleApp/Startup.cs | 0 .../samples}/SampleApp/appsettings.json | 0 .../samples}/SampleApp/wwwroot/htmlpage.html | 0 .../src}/Directory.Build.props | 0 .../HostFilteringStartupFilter.cs | 0 .../Microsoft.AspNetCore.csproj | 0 .../src}/Microsoft.AspNetCore/WebHost.cs | 0 .../baseline.netcore.json | 0 .../Metapackages/test}/Directory.Build.props | 0 ...icrosoft.AspNetCore.FunctionalTests.csproj | 0 .../WebHostFunctionalTests.cs | 0 .../testCert.pfx | Bin .../Microsoft.AspNetCore.Tests.csproj | 0 .../WebHostTests.cs | 0 .../CreateDefaultBuilderApp.csproj | 0 .../CreateDefaultBuilderApp/Program.cs | 0 .../appsettings.Development.json | 0 .../CreateDefaultBuilderApp/appsettings.json | 0 .../CreateDefaultBuilderOfTApp.csproj | 0 .../CreateDefaultBuilderOfTApp/Program.cs | 0 .../CreateDefaultBuilderOfTApp/Startup.cs | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 .../DependencyInjectionApp.csproj | 0 .../DependencyInjectionApp/Program.cs | 0 .../StartRequestDelegateUrlApp/Program.cs | 0 .../StartRequestDelegateUrlApp.csproj | 0 .../StartRouteBuilderUrlApp/Program.cs | 0 .../StartRouteBuilderUrlApp.csproj | 0 .../Program.cs | 0 .../StartWithIApplicationBuilderUrlApp.csproj | 0 .../Metapackages/version.props | 0 58 files changed, 566 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .gitattributes delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE.txt delete mode 100644 NuGet.config delete mode 100644 build.cmd delete mode 100755 build.sh delete mode 100644 korebuild-lock.txt delete mode 100644 korebuild.json delete mode 100644 run.cmd delete mode 100644 run.ps1 delete mode 100755 run.sh rename .gitignore => src/Metapackages/.gitignore (100%) rename Directory.Build.props => src/Metapackages/Directory.Build.props (100%) rename Directory.Build.targets => src/Metapackages/Directory.Build.targets (100%) rename MetaPackages.sln => src/Metapackages/MetaPackages.sln (100%) rename NuGetPackageVerifier.json => src/Metapackages/NuGetPackageVerifier.json (100%) rename README.md => src/Metapackages/README.md (100%) rename {build => src/Metapackages/build}/Key.snk (100%) rename {build => src/Metapackages/build}/dependencies.props (100%) rename {build => src/Metapackages/build}/repo.props (100%) rename {build => src/Metapackages/build}/sources.props (100%) rename {samples => src/Metapackages/samples}/SampleApp/Program.cs (100%) rename {samples => src/Metapackages/samples}/SampleApp/Properties/launchSettings.json (100%) rename {samples => src/Metapackages/samples}/SampleApp/SampleApp.csproj (100%) rename {samples => src/Metapackages/samples}/SampleApp/Startup.cs (100%) rename {samples => src/Metapackages/samples}/SampleApp/appsettings.json (100%) rename {samples => src/Metapackages/samples}/SampleApp/wwwroot/htmlpage.html (100%) rename src/{ => Metapackages/src}/Directory.Build.props (100%) rename src/{ => Metapackages/src}/Microsoft.AspNetCore/HostFilteringStartupFilter.cs (100%) rename src/{ => Metapackages/src}/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj (100%) rename src/{ => Metapackages/src}/Microsoft.AspNetCore/WebHost.cs (100%) rename src/{ => Metapackages/src}/Microsoft.AspNetCore/baseline.netcore.json (100%) rename {test => src/Metapackages/test}/Directory.Build.props (100%) rename {test => src/Metapackages/test}/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj (100%) rename {test => src/Metapackages/test}/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs (100%) rename {test => src/Metapackages/test}/Microsoft.AspNetCore.FunctionalTests/testCert.pfx (100%) rename {test => src/Metapackages/test}/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj (100%) rename {test => src/Metapackages/test}/Microsoft.AspNetCore.Tests/WebHostTests.cs (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderApp/Program.cs (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderApp/appsettings.Development.json (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderApp/appsettings.json (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderOfTApp/Program.cs (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderOfTApp/Startup.cs (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json (100%) rename {test => src/Metapackages/test}/TestSites/CreateDefaultBuilderOfTApp/appsettings.json (100%) rename {test => src/Metapackages/test}/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj (100%) rename {test => src/Metapackages/test}/TestSites/DependencyInjectionApp/Program.cs (100%) rename {test => src/Metapackages/test}/TestSites/StartRequestDelegateUrlApp/Program.cs (100%) rename {test => src/Metapackages/test}/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj (100%) rename {test => src/Metapackages/test}/TestSites/StartRouteBuilderUrlApp/Program.cs (100%) rename {test => src/Metapackages/test}/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj (100%) rename {test => src/Metapackages/test}/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs (100%) rename {test => src/Metapackages/test}/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj (100%) rename version.props => src/Metapackages/version.props (100%) diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 4eea96ab69..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -init: -- git config --global core.autocrlf true -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -build_script: -- ps: .\run.ps1 default-build -clone_depth: 1 -environment: - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: 'off' -deploy: 'off' -os: Visual Studio 2017 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index c2f0f84273..0000000000 --- a/.gitattributes +++ /dev/null @@ -1,52 +0,0 @@ -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain - -*.jpg binary -*.png binary -*.gif binary - -*.cs text=auto diff=csharp -*.vb text=auto -*.resx text=auto -*.c text=auto -*.cpp text=auto -*.cxx text=auto -*.h text=auto -*.hxx text=auto -*.py text=auto -*.rb text=auto -*.java text=auto -*.html text=auto -*.htm text=auto -*.css text=auto -*.scss text=auto -*.sass text=auto -*.less text=auto -*.js text=auto -*.lisp text=auto -*.clj text=auto -*.sql text=auto -*.php text=auto -*.lua text=auto -*.m text=auto -*.asm text=auto -*.erl text=auto -*.fs text=auto -*.fsx text=auto -*.hs text=auto - -*.csproj text=auto -*.vbproj text=auto -*.fsproj text=auto -*.dbproj text=auto -*.sln text=auto eol=crlf - -*.sh eol=lf \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 64bdbb4441..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: csharp -sudo: false -dist: trusty -env: - global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -mono: none -os: -- linux -- osx -osx_image: xcode8.2 -addons: - apt: - packages: - - libunwind8 -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -before_install: -- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s - /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 - /usr/local/lib/; fi -script: -- ./build.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 64ff041d5c..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,4 +0,0 @@ -Contributing -====== - -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 7b2956ecee..0000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) .NET Foundation and Contributors - -All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index e32bddfd51..0000000000 --- a/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build.cmd b/build.cmd deleted file mode 100644 index c0050bda12..0000000000 --- a/build.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh deleted file mode 100755 index 98a4b22765..0000000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) -chmod +x "$DIR/run.sh"; sync -"$DIR/run.sh" default-build "$@" diff --git a/korebuild-lock.txt b/korebuild-lock.txt deleted file mode 100644 index 251c227c83..0000000000 --- a/korebuild-lock.txt +++ /dev/null @@ -1,2 +0,0 @@ -version:2.1.3-rtm-15802 -commithash:a7c08b45b440a7d2058a0aa1eaa3eb6ba811976a diff --git a/korebuild.json b/korebuild.json deleted file mode 100644 index 678d8bb948..0000000000 --- a/korebuild.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.1/tools/korebuild.schema.json", - "channel": "release/2.1" -} diff --git a/run.cmd b/run.cmd deleted file mode 100644 index d52d5c7e68..0000000000 --- a/run.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/run.ps1 b/run.ps1 deleted file mode 100644 index 27dcf848f8..0000000000 --- a/run.ps1 +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env powershell -#requires -version 4 - -<# -.SYNOPSIS -Executes KoreBuild commands. - -.DESCRIPTION -Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. - -.PARAMETER Command -The KoreBuild command to run. - -.PARAMETER Path -The folder to build. Defaults to the folder containing this script. - -.PARAMETER Channel -The channel of KoreBuild to download. Overrides the value from the config file. - -.PARAMETER DotNetHome -The directory where .NET Core tools will be stored. - -.PARAMETER ToolsSource -The base url where build tools can be downloaded. Overrides the value from the config file. - -.PARAMETER Update -Updates KoreBuild to the latest version even if a lock file is present. - -.PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to korebuild.json. - -.PARAMETER ToolsSourceSuffix -The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. - -.PARAMETER Arguments -Arguments to be passed to the command - -.NOTES -This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. -When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. - -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 -in the file are overridden by command line parameters. - -.EXAMPLE -Example config file: -```json -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json", - "channel": "dev", - "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" -} -``` -#> -[CmdletBinding(PositionalBinding = $false)] -param( - [Parameter(Mandatory = $true, Position = 0)] - [string]$Command, - [string]$Path = $PSScriptRoot, - [Alias('c')] - [string]$Channel, - [Alias('d')] - [string]$DotNetHome, - [Alias('s')] - [string]$ToolsSource, - [Alias('u')] - [switch]$Update, - [string]$ConfigFile, - [string]$ToolsSourceSuffix, - [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$Arguments -) - -Set-StrictMode -Version 2 -$ErrorActionPreference = 'Stop' - -# -# Functions -# - -function Get-KoreBuild { - - $lockFile = Join-Path $Path 'korebuild-lock.txt' - - if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix - } - - $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 - if (!$version) { - Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" - } - $version = $version.TrimStart('version:').Trim() - $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) - - if (!(Test-Path $korebuildPath)) { - Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" - New-Item -ItemType Directory -Path $korebuildPath | Out-Null - $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" - - try { - $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) { - # Use built-in commands where possible as they are cross-plat compatible - Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath - } - else { - # Fallback to old approach for old installations of PowerShell - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) - } - } - catch { - Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore - throw - } - finally { - Remove-Item $tmpfile -ErrorAction Ignore - } - } - - return $korebuildPath -} - -function Join-Paths([string]$path, [string[]]$childPaths) { - $childPaths | ForEach-Object { $path = Join-Path $path $_ } - return $path -} - -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { - if ($RemotePath -notlike 'http*') { - Copy-Item $RemotePath $LocalPath - return - } - - $retries = 10 - while ($retries -gt 0) { - $retries -= 1 - try { - Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath - return - } - catch { - Write-Verbose "Request failed. $retries retries remaining" - } - } - - Write-Error "Download failed: '$RemotePath'." -} - -# -# Main -# - -# Load configuration or set defaults - -$Path = Resolve-Path $Path -if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } - -if (Test-Path $ConfigFile) { - try { - $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json - if ($config) { - if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } - if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} - } - } - catch { - Write-Warning "$ConfigFile could not be read. Its settings will be ignored." - Write-Warning $Error[0] - } -} - -if (!$DotNetHome) { - $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` - elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` - elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` - else { Join-Path $PSScriptRoot '.dotnet'} -} - -if (!$Channel) { $Channel = 'dev' } -if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } - -# Execute - -$korebuildPath = Get-KoreBuild -Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') - -try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile - Invoke-KoreBuildCommand $Command @Arguments -} -finally { - Remove-Module 'KoreBuild' -ErrorAction Ignore -} diff --git a/run.sh b/run.sh deleted file mode 100755 index 834961fc3a..0000000000 --- a/run.sh +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -YELLOW="\033[0;33m" -MAGENTA="\033[0;95m" -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -verbose=false -update=false -repo_path="$DIR" -channel='' -tools_source='' -tools_source_suffix='' - -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " command The command to be run." - echo " ... Arguments passed to the command. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo "" - echo "Description:" - 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." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}error: $*${RESET}" 1>&2 -} - -__warn() { - echo -e "${YELLOW}warning: $*${RESET}" -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - local remote_path_suffix=$3 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -# -# main -# - -command="${1:-}" -shift - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - if [ ! -f "$config_file" ]; then - __error "Invalid value for --config-file. $config_file does not exist." - exit 1 - fi - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - --tools-source-suffix|-ToolsSourceSuffix) - shift - tools_source_suffix="${1:-}" - [ -z "$tools_source_suffix" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" -if [ -f "$config_file" ]; then - if __machine_has jq ; then - if jq '.' "$config_file" >/dev/null ; then - config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" - config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" - else - __warn "$config_file is invalid JSON. Its settings will be ignored." - fi - elif __machine_has python ; then - if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then - 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 '')")" - 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 '')")" - else - __warn "$config_file is invalid JSON. Its settings will be ignored." - fi - else - __warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.' - fi - - [ ! -z "${config_channel:-}" ] && channel="$config_channel" - [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" -fi - -[ -z "$channel" ] && channel='dev' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" -invoke_korebuild_command "$command" "$@" diff --git a/.gitignore b/src/Metapackages/.gitignore similarity index 100% rename from .gitignore rename to src/Metapackages/.gitignore diff --git a/Directory.Build.props b/src/Metapackages/Directory.Build.props similarity index 100% rename from Directory.Build.props rename to src/Metapackages/Directory.Build.props diff --git a/Directory.Build.targets b/src/Metapackages/Directory.Build.targets similarity index 100% rename from Directory.Build.targets rename to src/Metapackages/Directory.Build.targets diff --git a/MetaPackages.sln b/src/Metapackages/MetaPackages.sln similarity index 100% rename from MetaPackages.sln rename to src/Metapackages/MetaPackages.sln diff --git a/NuGetPackageVerifier.json b/src/Metapackages/NuGetPackageVerifier.json similarity index 100% rename from NuGetPackageVerifier.json rename to src/Metapackages/NuGetPackageVerifier.json diff --git a/README.md b/src/Metapackages/README.md similarity index 100% rename from README.md rename to src/Metapackages/README.md diff --git a/build/Key.snk b/src/Metapackages/build/Key.snk similarity index 100% rename from build/Key.snk rename to src/Metapackages/build/Key.snk diff --git a/build/dependencies.props b/src/Metapackages/build/dependencies.props similarity index 100% rename from build/dependencies.props rename to src/Metapackages/build/dependencies.props diff --git a/build/repo.props b/src/Metapackages/build/repo.props similarity index 100% rename from build/repo.props rename to src/Metapackages/build/repo.props diff --git a/build/sources.props b/src/Metapackages/build/sources.props similarity index 100% rename from build/sources.props rename to src/Metapackages/build/sources.props diff --git a/samples/SampleApp/Program.cs b/src/Metapackages/samples/SampleApp/Program.cs similarity index 100% rename from samples/SampleApp/Program.cs rename to src/Metapackages/samples/SampleApp/Program.cs diff --git a/samples/SampleApp/Properties/launchSettings.json b/src/Metapackages/samples/SampleApp/Properties/launchSettings.json similarity index 100% rename from samples/SampleApp/Properties/launchSettings.json rename to src/Metapackages/samples/SampleApp/Properties/launchSettings.json diff --git a/samples/SampleApp/SampleApp.csproj b/src/Metapackages/samples/SampleApp/SampleApp.csproj similarity index 100% rename from samples/SampleApp/SampleApp.csproj rename to src/Metapackages/samples/SampleApp/SampleApp.csproj diff --git a/samples/SampleApp/Startup.cs b/src/Metapackages/samples/SampleApp/Startup.cs similarity index 100% rename from samples/SampleApp/Startup.cs rename to src/Metapackages/samples/SampleApp/Startup.cs diff --git a/samples/SampleApp/appsettings.json b/src/Metapackages/samples/SampleApp/appsettings.json similarity index 100% rename from samples/SampleApp/appsettings.json rename to src/Metapackages/samples/SampleApp/appsettings.json diff --git a/samples/SampleApp/wwwroot/htmlpage.html b/src/Metapackages/samples/SampleApp/wwwroot/htmlpage.html similarity index 100% rename from samples/SampleApp/wwwroot/htmlpage.html rename to src/Metapackages/samples/SampleApp/wwwroot/htmlpage.html diff --git a/src/Directory.Build.props b/src/Metapackages/src/Directory.Build.props similarity index 100% rename from src/Directory.Build.props rename to src/Metapackages/src/Directory.Build.props diff --git a/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs b/src/Metapackages/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs similarity index 100% rename from src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs rename to src/Metapackages/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/Metapackages/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj similarity index 100% rename from src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj rename to src/Metapackages/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/Metapackages/src/Microsoft.AspNetCore/WebHost.cs similarity index 100% rename from src/Microsoft.AspNetCore/WebHost.cs rename to src/Metapackages/src/Microsoft.AspNetCore/WebHost.cs diff --git a/src/Microsoft.AspNetCore/baseline.netcore.json b/src/Metapackages/src/Microsoft.AspNetCore/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore/baseline.netcore.json rename to src/Metapackages/src/Microsoft.AspNetCore/baseline.netcore.json diff --git a/test/Directory.Build.props b/src/Metapackages/test/Directory.Build.props similarity index 100% rename from test/Directory.Build.props rename to src/Metapackages/test/Directory.Build.props diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/src/Metapackages/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj similarity index 100% rename from test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj rename to src/Metapackages/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/src/Metapackages/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs rename to src/Metapackages/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs diff --git a/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx b/src/Metapackages/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx similarity index 100% rename from test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx rename to src/Metapackages/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/src/Metapackages/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj similarity index 100% rename from test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj rename to src/Metapackages/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj diff --git a/test/Microsoft.AspNetCore.Tests/WebHostTests.cs b/src/Metapackages/test/Microsoft.AspNetCore.Tests/WebHostTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Tests/WebHostTests.cs rename to src/Metapackages/test/Microsoft.AspNetCore.Tests/WebHostTests.cs diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/src/Metapackages/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj similarity index 100% rename from test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj rename to src/Metapackages/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj diff --git a/test/TestSites/CreateDefaultBuilderApp/Program.cs b/src/Metapackages/test/TestSites/CreateDefaultBuilderApp/Program.cs similarity index 100% rename from test/TestSites/CreateDefaultBuilderApp/Program.cs rename to src/Metapackages/test/TestSites/CreateDefaultBuilderApp/Program.cs diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json b/src/Metapackages/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json similarity index 100% rename from test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json rename to src/Metapackages/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.json b/src/Metapackages/test/TestSites/CreateDefaultBuilderApp/appsettings.json similarity index 100% rename from test/TestSites/CreateDefaultBuilderApp/appsettings.json rename to src/Metapackages/test/TestSites/CreateDefaultBuilderApp/appsettings.json diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj b/src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj rename to src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs b/src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/Program.cs rename to src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs b/src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs rename to src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/Startup.cs diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json b/src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json rename to src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json b/src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json rename to src/Metapackages/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json diff --git a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj b/src/Metapackages/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj similarity index 100% rename from test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj rename to src/Metapackages/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj diff --git a/test/TestSites/DependencyInjectionApp/Program.cs b/src/Metapackages/test/TestSites/DependencyInjectionApp/Program.cs similarity index 100% rename from test/TestSites/DependencyInjectionApp/Program.cs rename to src/Metapackages/test/TestSites/DependencyInjectionApp/Program.cs diff --git a/test/TestSites/StartRequestDelegateUrlApp/Program.cs b/src/Metapackages/test/TestSites/StartRequestDelegateUrlApp/Program.cs similarity index 100% rename from test/TestSites/StartRequestDelegateUrlApp/Program.cs rename to src/Metapackages/test/TestSites/StartRequestDelegateUrlApp/Program.cs diff --git a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj b/src/Metapackages/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj similarity index 100% rename from test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj rename to src/Metapackages/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj diff --git a/test/TestSites/StartRouteBuilderUrlApp/Program.cs b/src/Metapackages/test/TestSites/StartRouteBuilderUrlApp/Program.cs similarity index 100% rename from test/TestSites/StartRouteBuilderUrlApp/Program.cs rename to src/Metapackages/test/TestSites/StartRouteBuilderUrlApp/Program.cs diff --git a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj b/src/Metapackages/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj similarity index 100% rename from test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj rename to src/Metapackages/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs b/src/Metapackages/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs similarity index 100% rename from test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs rename to src/Metapackages/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj b/src/Metapackages/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj similarity index 100% rename from test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj rename to src/Metapackages/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj diff --git a/version.props b/src/Metapackages/version.props similarity index 100% rename from version.props rename to src/Metapackages/version.props From a6acf47e79b2d6db3dda6c7517688cd958cd72ee Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 20 Nov 2018 11:06:50 -0800 Subject: [PATCH 361/361] Reorganize source code in preparation to move into aspnet/AspNetCore Prior to reorganization, this source code was found in https://github.com/aspnet/MetaPackages/tree/27efce1042914569097d6c68db404e5286ad7b20 --- .appveyor.yml | 17 -- .gitattributes | 52 ---- .travis.yml | 27 -- .vsts-pipelines/builds/ci-internal.yml | 13 - .vsts-pipelines/builds/ci-public.yml | 15 - CONTRIBUTING.md | 4 - LICENSE.txt | 14 - NuGet.config | 7 - build.cmd | 2 - build.sh | 8 - korebuild-lock.txt | 2 - korebuild.json | 4 - run.cmd | 2 - run.ps1 | 209 -------------- run.sh | 256 ------------------ .gitignore => src/MetaPackages/.gitignore | 0 .../MetaPackages/Directory.Build.props | 0 .../MetaPackages/Directory.Build.targets | 0 .../MetaPackages/MetaPackages.sln | 0 .../MetaPackages/NuGetPackageVerifier.json | 0 README.md => src/MetaPackages/README.md | 0 {build => src/MetaPackages/build}/Key.snk | Bin .../MetaPackages/build}/dependencies.props | 0 {build => src/MetaPackages/build}/repo.props | 0 .../MetaPackages/build}/sources.props | 0 .../samples}/SampleApp/Program.cs | 0 .../SampleApp/Properties/launchSettings.json | 0 .../samples}/SampleApp/SampleApp.csproj | 0 .../samples}/SampleApp/Startup.cs | 0 .../samples}/SampleApp/appsettings.json | 0 .../samples}/SampleApp/wwwroot/htmlpage.html | 0 .../src}/Directory.Build.props | 0 .../HostFilteringStartupFilter.cs | 0 .../Microsoft.AspNetCore.csproj | 0 .../src}/Microsoft.AspNetCore/WebHost.cs | 0 .../baseline.netcore.json | 0 .../MetaPackages/test}/Directory.Build.props | 0 ...icrosoft.AspNetCore.FunctionalTests.csproj | 0 .../WebHostFunctionalTests.cs | 0 .../testCert.pfx | Bin .../Microsoft.AspNetCore.Tests.csproj | 0 .../WebHostTests.cs | 0 .../CreateDefaultBuilderApp.csproj | 0 .../CreateDefaultBuilderApp/Program.cs | 0 .../appsettings.Development.json | 0 .../CreateDefaultBuilderApp/appsettings.json | 0 .../CreateDefaultBuilderOfTApp.csproj | 0 .../CreateDefaultBuilderOfTApp/Program.cs | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 .../DependencyInjectionApp.csproj | 0 .../DependencyInjectionApp/Program.cs | 0 .../StartRequestDelegateUrlApp/Program.cs | 0 .../StartRequestDelegateUrlApp.csproj | 0 .../StartRouteBuilderUrlApp/Program.cs | 0 .../StartRouteBuilderUrlApp.csproj | 0 .../Program.cs | 0 .../StartWithIApplicationBuilderUrlApp.csproj | 0 .../MetaPackages/version.props | 0 59 files changed, 632 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .gitattributes delete mode 100644 .travis.yml delete mode 100644 .vsts-pipelines/builds/ci-internal.yml delete mode 100644 .vsts-pipelines/builds/ci-public.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE.txt delete mode 100644 NuGet.config delete mode 100644 build.cmd delete mode 100755 build.sh delete mode 100644 korebuild-lock.txt delete mode 100644 korebuild.json delete mode 100644 run.cmd delete mode 100644 run.ps1 delete mode 100755 run.sh rename .gitignore => src/MetaPackages/.gitignore (100%) rename Directory.Build.props => src/MetaPackages/Directory.Build.props (100%) rename Directory.Build.targets => src/MetaPackages/Directory.Build.targets (100%) rename MetaPackages.sln => src/MetaPackages/MetaPackages.sln (100%) rename NuGetPackageVerifier.json => src/MetaPackages/NuGetPackageVerifier.json (100%) rename README.md => src/MetaPackages/README.md (100%) rename {build => src/MetaPackages/build}/Key.snk (100%) rename {build => src/MetaPackages/build}/dependencies.props (100%) rename {build => src/MetaPackages/build}/repo.props (100%) rename {build => src/MetaPackages/build}/sources.props (100%) rename {samples => src/MetaPackages/samples}/SampleApp/Program.cs (100%) rename {samples => src/MetaPackages/samples}/SampleApp/Properties/launchSettings.json (100%) rename {samples => src/MetaPackages/samples}/SampleApp/SampleApp.csproj (100%) rename {samples => src/MetaPackages/samples}/SampleApp/Startup.cs (100%) rename {samples => src/MetaPackages/samples}/SampleApp/appsettings.json (100%) rename {samples => src/MetaPackages/samples}/SampleApp/wwwroot/htmlpage.html (100%) rename src/{ => MetaPackages/src}/Directory.Build.props (100%) rename src/{ => MetaPackages/src}/Microsoft.AspNetCore/HostFilteringStartupFilter.cs (100%) rename src/{ => MetaPackages/src}/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj (100%) rename src/{ => MetaPackages/src}/Microsoft.AspNetCore/WebHost.cs (100%) rename src/{ => MetaPackages/src}/Microsoft.AspNetCore/baseline.netcore.json (100%) rename {test => src/MetaPackages/test}/Directory.Build.props (100%) rename {test => src/MetaPackages/test}/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj (100%) rename {test => src/MetaPackages/test}/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs (100%) rename {test => src/MetaPackages/test}/Microsoft.AspNetCore.FunctionalTests/testCert.pfx (100%) rename {test => src/MetaPackages/test}/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj (100%) rename {test => src/MetaPackages/test}/Microsoft.AspNetCore.Tests/WebHostTests.cs (100%) rename {test => src/MetaPackages/test}/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj (100%) rename {test => src/MetaPackages/test}/TestSites/CreateDefaultBuilderApp/Program.cs (100%) rename {test => src/MetaPackages/test}/TestSites/CreateDefaultBuilderApp/appsettings.Development.json (100%) rename {test => src/MetaPackages/test}/TestSites/CreateDefaultBuilderApp/appsettings.json (100%) rename {test => src/MetaPackages/test}/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj (100%) rename {test => src/MetaPackages/test}/TestSites/CreateDefaultBuilderOfTApp/Program.cs (100%) rename {test => src/MetaPackages/test}/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json (100%) rename {test => src/MetaPackages/test}/TestSites/CreateDefaultBuilderOfTApp/appsettings.json (100%) rename {test => src/MetaPackages/test}/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj (100%) rename {test => src/MetaPackages/test}/TestSites/DependencyInjectionApp/Program.cs (100%) rename {test => src/MetaPackages/test}/TestSites/StartRequestDelegateUrlApp/Program.cs (100%) rename {test => src/MetaPackages/test}/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj (100%) rename {test => src/MetaPackages/test}/TestSites/StartRouteBuilderUrlApp/Program.cs (100%) rename {test => src/MetaPackages/test}/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj (100%) rename {test => src/MetaPackages/test}/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs (100%) rename {test => src/MetaPackages/test}/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj (100%) rename version.props => src/MetaPackages/version.props (100%) diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 4eea96ab69..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -init: -- git config --global core.autocrlf true -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -build_script: -- ps: .\run.ps1 default-build -clone_depth: 1 -environment: - global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -test: 'off' -deploy: 'off' -os: Visual Studio 2017 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index c2f0f84273..0000000000 --- a/.gitattributes +++ /dev/null @@ -1,52 +0,0 @@ -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain - -*.jpg binary -*.png binary -*.gif binary - -*.cs text=auto diff=csharp -*.vb text=auto -*.resx text=auto -*.c text=auto -*.cpp text=auto -*.cxx text=auto -*.h text=auto -*.hxx text=auto -*.py text=auto -*.rb text=auto -*.java text=auto -*.html text=auto -*.htm text=auto -*.css text=auto -*.scss text=auto -*.sass text=auto -*.less text=auto -*.js text=auto -*.lisp text=auto -*.clj text=auto -*.sql text=auto -*.php text=auto -*.lua text=auto -*.m text=auto -*.asm text=auto -*.erl text=auto -*.fs text=auto -*.fsx text=auto -*.hs text=auto - -*.csproj text=auto -*.vbproj text=auto -*.fsproj text=auto -*.dbproj text=auto -*.sln text=auto eol=crlf - -*.sh eol=lf \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 64bdbb4441..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: csharp -sudo: false -dist: trusty -env: - global: - - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - - DOTNET_CLI_TELEMETRY_OPTOUT: 1 -mono: none -os: -- linux -- osx -osx_image: xcode8.2 -addons: - apt: - packages: - - libunwind8 -branches: - only: - - dev - - /^release\/.*$/ - - /^(.*\/)?ci-.*$/ -before_install: -- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s - /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 - /usr/local/lib/; fi -script: -- ./build.sh diff --git a/.vsts-pipelines/builds/ci-internal.yml b/.vsts-pipelines/builds/ci-internal.yml deleted file mode 100644 index dc7b8a3cb9..0000000000 --- a/.vsts-pipelines/builds/ci-internal.yml +++ /dev/null @@ -1,13 +0,0 @@ -trigger: -- master -- release/* - -resources: - repositories: - - repository: buildtools - type: git - name: aspnet-BuildTools - ref: refs/heads/release/2.2 - -phases: -- template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/.vsts-pipelines/builds/ci-public.yml b/.vsts-pipelines/builds/ci-public.yml deleted file mode 100644 index f5087d9c30..0000000000 --- a/.vsts-pipelines/builds/ci-public.yml +++ /dev/null @@ -1,15 +0,0 @@ -trigger: -- master -- release/* - -# See https://github.com/aspnet/BuildTools -resources: - repositories: - - repository: buildtools - type: github - endpoint: DotNet-Bot GitHub Connection - name: aspnet/BuildTools - ref: refs/heads/release/2.2 - -phases: -- template: .vsts-pipelines/templates/project-ci.yml@buildtools diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 64ff041d5c..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,4 +0,0 @@ -Contributing -====== - -Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo. diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 7b2956ecee..0000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) .NET Foundation and Contributors - -All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index e32bddfd51..0000000000 --- a/NuGet.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/build.cmd b/build.cmd deleted file mode 100644 index c0050bda12..0000000000 --- a/build.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' default-build %*; exit $LASTEXITCODE" diff --git a/build.sh b/build.sh deleted file mode 100755 index 98a4b22765..0000000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Call "sync" between "chmod" and execution to prevent "text file busy" error in Docker (aufs) -chmod +x "$DIR/run.sh"; sync -"$DIR/run.sh" default-build "$@" diff --git a/korebuild-lock.txt b/korebuild-lock.txt deleted file mode 100644 index 96fe3217ef..0000000000 --- a/korebuild-lock.txt +++ /dev/null @@ -1,2 +0,0 @@ -version:2.2.0-preview2-20181004.6 -commithash:c04c4b2f5018632647f96210ab01876661302dac diff --git a/korebuild.json b/korebuild.json deleted file mode 100644 index d217d06e3e..0000000000 --- a/korebuild.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/release/2.2/tools/korebuild.schema.json", - "channel": "release/2.2" -} diff --git a/run.cmd b/run.cmd deleted file mode 100644 index d52d5c7e68..0000000000 --- a/run.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE" diff --git a/run.ps1 b/run.ps1 deleted file mode 100644 index 34604c7175..0000000000 --- a/run.ps1 +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env powershell -#requires -version 4 - -<# -.SYNOPSIS -Executes KoreBuild commands. - -.DESCRIPTION -Downloads korebuild if required. Then executes the KoreBuild command. To see available commands, execute with `-Command help`. - -.PARAMETER Command -The KoreBuild command to run. - -.PARAMETER Path -The folder to build. Defaults to the folder containing this script. - -.PARAMETER Channel -The channel of KoreBuild to download. Overrides the value from the config file. - -.PARAMETER DotNetHome -The directory where .NET Core tools will be stored. - -.PARAMETER ToolsSource -The base url where build tools can be downloaded. Overrides the value from the config file. - -.PARAMETER Update -Updates KoreBuild to the latest version even if a lock file is present. - -.PARAMETER Reinstall -Re-installs KoreBuild - -.PARAMETER ConfigFile -The path to the configuration file that stores values. Defaults to korebuild.json. - -.PARAMETER ToolsSourceSuffix -The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores. - -.PARAMETER CI -Sets up CI specific settings and variables. - -.PARAMETER Arguments -Arguments to be passed to the command - -.NOTES -This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be. -When the lockfile is not present, KoreBuild will create one using latest available version from $Channel. - -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 -in the file are overridden by command line parameters. - -.EXAMPLE -Example config file: -```json -{ - "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json", - "channel": "master", - "toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools" -} -``` -#> -[CmdletBinding(PositionalBinding = $false)] -param( - [Parameter(Mandatory = $true, Position = 0)] - [string]$Command, - [string]$Path = $PSScriptRoot, - [Alias('c')] - [string]$Channel, - [Alias('d')] - [string]$DotNetHome, - [Alias('s')] - [string]$ToolsSource, - [Alias('u')] - [switch]$Update, - [switch]$Reinstall, - [string]$ToolsSourceSuffix, - [string]$ConfigFile = $null, - [switch]$CI, - [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$Arguments -) - -Set-StrictMode -Version 2 -$ErrorActionPreference = 'Stop' - -# -# Functions -# - -function Get-KoreBuild { - - $lockFile = Join-Path $Path 'korebuild-lock.txt' - - if (!(Test-Path $lockFile) -or $Update) { - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix - } - - $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1 - if (!$version) { - Write-Error "Failed to parse version from $lockFile. Expected a line that begins with 'version:'" - } - $version = $version.TrimStart('version:').Trim() - $korebuildPath = Join-Paths $DotNetHome ('buildtools', 'korebuild', $version) - - if ($Reinstall -and (Test-Path $korebuildPath)) { - Remove-Item -Force -Recurse $korebuildPath - } - - if (!(Test-Path $korebuildPath)) { - Write-Host -ForegroundColor Magenta "Downloading KoreBuild $version" - New-Item -ItemType Directory -Path $korebuildPath | Out-Null - $remotePath = "$ToolsSource/korebuild/artifacts/$version/korebuild.$version.zip" - - try { - $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip" - Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix - if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) { - # Use built-in commands where possible as they are cross-plat compatible - Microsoft.PowerShell.Archive\Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath - } - else { - # Fallback to old approach for old installations of PowerShell - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory($tmpfile, $korebuildPath) - } - } - catch { - Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore - throw - } - finally { - Remove-Item $tmpfile -ErrorAction Ignore - } - } - - return $korebuildPath -} - -function Join-Paths([string]$path, [string[]]$childPaths) { - $childPaths | ForEach-Object { $path = Join-Path $path $_ } - return $path -} - -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) { - if ($RemotePath -notlike 'http*') { - Copy-Item $RemotePath $LocalPath - return - } - - $retries = 10 - while ($retries -gt 0) { - $retries -= 1 - try { - Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath - return - } - catch { - Write-Verbose "Request failed. $retries retries remaining" - } - } - - Write-Error "Download failed: '$RemotePath'." -} - -# -# Main -# - -# Load configuration or set defaults - -$Path = Resolve-Path $Path -if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' } - -if (Test-Path $ConfigFile) { - try { - $config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json - if ($config) { - if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel } - if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource} - } - } - catch { - Write-Host -ForegroundColor Red $Error[0] - Write-Error "$ConfigFile contains invalid JSON." - exit 1 - } -} - -if (!$DotNetHome) { - $DotNetHome = if ($env:DOTNET_HOME) { $env:DOTNET_HOME } ` - elseif ($env:USERPROFILE) { Join-Path $env:USERPROFILE '.dotnet'} ` - elseif ($env:HOME) {Join-Path $env:HOME '.dotnet'}` - else { Join-Path $PSScriptRoot '.dotnet'} -} - -if (!$Channel) { $Channel = 'master' } -if (!$ToolsSource) { $ToolsSource = 'https://aspnetcore.blob.core.windows.net/buildtools' } - -# Execute - -$korebuildPath = Get-KoreBuild -Import-Module -Force -Scope Local (Join-Path $korebuildPath 'KoreBuild.psd1') - -try { - Set-KoreBuildSettings -ToolsSource $ToolsSource -DotNetHome $DotNetHome -RepoPath $Path -ConfigFile $ConfigFile -CI:$CI - Invoke-KoreBuildCommand $Command @Arguments -} -finally { - Remove-Module 'KoreBuild' -ErrorAction Ignore -} diff --git a/run.sh b/run.sh deleted file mode 100755 index 4c1fed5646..0000000000 --- a/run.sh +++ /dev/null @@ -1,256 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -# -# variables -# - -RESET="\033[0m" -RED="\033[0;31m" -YELLOW="\033[0;33m" -MAGENTA="\033[0;95m" -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet" -verbose=false -update=false -reinstall=false -repo_path="$DIR" -channel='' -tools_source='' -tools_source_suffix='' -ci=false - -# -# Functions -# -__usage() { - echo "Usage: $(basename "${BASH_SOURCE[0]}") command [options] [[--] ...]" - echo "" - echo "Arguments:" - echo " command The command to be run." - echo " ... Arguments passed to the command. Variable number of arguments allowed." - echo "" - echo "Options:" - echo " --verbose Show verbose output." - echo " -c|--channel The channel of KoreBuild to download. Overrides the value from the config file.." - echo " --config-file The path to the configuration file that stores values. Defaults to korebuild.json." - echo " -d|--dotnet-home The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet." - echo " --path The directory to build. Defaults to the directory containing the script." - echo " -s|--tools-source|-ToolsSource The base url where build tools can be downloaded. Overrides the value from the config file." - echo " --tools-source-suffix|-ToolsSourceSuffix The suffix to append to tools-source. Useful for query strings." - echo " -u|--update Update to the latest KoreBuild even if the lock file is present." - echo " --reinstall Reinstall KoreBuild." - echo " --ci Apply CI specific settings and environment variables." - echo "" - echo "Description:" - 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." - echo " When the lockfile is not present, KoreBuild will create one using latest available version from \$channel." - - if [[ "${1:-}" != '--no-exit' ]]; then - exit 2 - fi -} - -get_korebuild() { - local version - local lock_file="$repo_path/korebuild-lock.txt" - if [ ! -f "$lock_file" ] || [ "$update" = true ]; then - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix" - fi - version="$(grep 'version:*' -m 1 "$lock_file")" - if [[ "$version" == '' ]]; then - __error "Failed to parse version from $lock_file. Expected a line that begins with 'version:'" - return 1 - fi - version="$(echo "${version#version:}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - local korebuild_path="$DOTNET_HOME/buildtools/korebuild/$version" - - if [ "$reinstall" = true ] && [ -d "$korebuild_path" ]; then - rm -rf "$korebuild_path" - fi - - { - if [ ! -d "$korebuild_path" ]; then - mkdir -p "$korebuild_path" - local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip" - tmpfile="$(mktemp)" - echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}" - if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then - unzip -q -d "$korebuild_path" "$tmpfile" - fi - rm "$tmpfile" || true - fi - - source "$korebuild_path/KoreBuild.sh" - } || { - if [ -d "$korebuild_path" ]; then - echo "Cleaning up after failed installation" - rm -rf "$korebuild_path" || true - fi - return 1 - } -} - -__error() { - echo -e "${RED}error: $*${RESET}" 1>&2 -} - -__warn() { - echo -e "${YELLOW}warning: $*${RESET}" -} - -__machine_has() { - hash "$1" > /dev/null 2>&1 - return $? -} - -__get_remote_file() { - local remote_path=$1 - local local_path=$2 - local remote_path_suffix=$3 - - if [[ "$remote_path" != 'http'* ]]; then - cp "$remote_path" "$local_path" - return 0 - fi - - local failed=false - if __machine_has wget; then - wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - else - failed=true - fi - - if [ "$failed" = true ] && __machine_has curl; then - failed=false - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true - fi - - if [ "$failed" = true ]; then - __error "Download failed: $remote_path" 1>&2 - return 1 - fi -} - -# -# main -# - -command="${1:-}" -shift - -while [[ $# -gt 0 ]]; do - case $1 in - -\?|-h|--help) - __usage --no-exit - exit 0 - ;; - -c|--channel|-Channel) - shift - channel="${1:-}" - [ -z "$channel" ] && __usage - ;; - --config-file|-ConfigFile) - shift - config_file="${1:-}" - [ -z "$config_file" ] && __usage - if [ ! -f "$config_file" ]; then - __error "Invalid value for --config-file. $config_file does not exist." - exit 1 - fi - ;; - -d|--dotnet-home|-DotNetHome) - shift - DOTNET_HOME="${1:-}" - [ -z "$DOTNET_HOME" ] && __usage - ;; - --path|-Path) - shift - repo_path="${1:-}" - [ -z "$repo_path" ] && __usage - ;; - -s|--tools-source|-ToolsSource) - shift - tools_source="${1:-}" - [ -z "$tools_source" ] && __usage - ;; - --tools-source-suffix|-ToolsSourceSuffix) - shift - tools_source_suffix="${1:-}" - [ -z "$tools_source_suffix" ] && __usage - ;; - -u|--update|-Update) - update=true - ;; - --reinstall|-[Rr]einstall) - reinstall=true - ;; - --ci|-[Cc][Ii]) - ci=true - ;; - --verbose|-Verbose) - verbose=true - ;; - --) - shift - break - ;; - *) - break - ;; - esac - shift -done - -if ! __machine_has unzip; then - __error 'Missing required command: unzip' - exit 1 -fi - -if ! __machine_has curl && ! __machine_has wget; then - __error 'Missing required command. Either wget or curl is required.' - exit 1 -fi - -[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json" -if [ -f "$config_file" ]; then - if __machine_has jq ; then - if jq '.' "$config_file" >/dev/null ; then - config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")" - config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")" - else - __error "$config_file contains invalid JSON." - exit 1 - fi - elif __machine_has python ; then - if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then - 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 '')")" - 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 '')")" - else - __error "$config_file contains invalid JSON." - exit 1 - fi - elif __machine_has python3 ; then - if python3 -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then - 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 '')")" - 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 '')")" - else - __error "$config_file contains invalid JSON." - exit 1 - fi - else - __error 'Missing required command: jq or python. Could not parse the JSON file.' - exit 1 - fi - - [ ! -z "${config_channel:-}" ] && channel="$config_channel" - [ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source" -fi - -[ -z "$channel" ] && channel='master' -[ -z "$tools_source" ] && tools_source='https://aspnetcore.blob.core.windows.net/buildtools' - -get_korebuild -set_korebuildsettings "$tools_source" "$DOTNET_HOME" "$repo_path" "$config_file" "$ci" -invoke_korebuild_command "$command" "$@" diff --git a/.gitignore b/src/MetaPackages/.gitignore similarity index 100% rename from .gitignore rename to src/MetaPackages/.gitignore diff --git a/Directory.Build.props b/src/MetaPackages/Directory.Build.props similarity index 100% rename from Directory.Build.props rename to src/MetaPackages/Directory.Build.props diff --git a/Directory.Build.targets b/src/MetaPackages/Directory.Build.targets similarity index 100% rename from Directory.Build.targets rename to src/MetaPackages/Directory.Build.targets diff --git a/MetaPackages.sln b/src/MetaPackages/MetaPackages.sln similarity index 100% rename from MetaPackages.sln rename to src/MetaPackages/MetaPackages.sln diff --git a/NuGetPackageVerifier.json b/src/MetaPackages/NuGetPackageVerifier.json similarity index 100% rename from NuGetPackageVerifier.json rename to src/MetaPackages/NuGetPackageVerifier.json diff --git a/README.md b/src/MetaPackages/README.md similarity index 100% rename from README.md rename to src/MetaPackages/README.md diff --git a/build/Key.snk b/src/MetaPackages/build/Key.snk similarity index 100% rename from build/Key.snk rename to src/MetaPackages/build/Key.snk diff --git a/build/dependencies.props b/src/MetaPackages/build/dependencies.props similarity index 100% rename from build/dependencies.props rename to src/MetaPackages/build/dependencies.props diff --git a/build/repo.props b/src/MetaPackages/build/repo.props similarity index 100% rename from build/repo.props rename to src/MetaPackages/build/repo.props diff --git a/build/sources.props b/src/MetaPackages/build/sources.props similarity index 100% rename from build/sources.props rename to src/MetaPackages/build/sources.props diff --git a/samples/SampleApp/Program.cs b/src/MetaPackages/samples/SampleApp/Program.cs similarity index 100% rename from samples/SampleApp/Program.cs rename to src/MetaPackages/samples/SampleApp/Program.cs diff --git a/samples/SampleApp/Properties/launchSettings.json b/src/MetaPackages/samples/SampleApp/Properties/launchSettings.json similarity index 100% rename from samples/SampleApp/Properties/launchSettings.json rename to src/MetaPackages/samples/SampleApp/Properties/launchSettings.json diff --git a/samples/SampleApp/SampleApp.csproj b/src/MetaPackages/samples/SampleApp/SampleApp.csproj similarity index 100% rename from samples/SampleApp/SampleApp.csproj rename to src/MetaPackages/samples/SampleApp/SampleApp.csproj diff --git a/samples/SampleApp/Startup.cs b/src/MetaPackages/samples/SampleApp/Startup.cs similarity index 100% rename from samples/SampleApp/Startup.cs rename to src/MetaPackages/samples/SampleApp/Startup.cs diff --git a/samples/SampleApp/appsettings.json b/src/MetaPackages/samples/SampleApp/appsettings.json similarity index 100% rename from samples/SampleApp/appsettings.json rename to src/MetaPackages/samples/SampleApp/appsettings.json diff --git a/samples/SampleApp/wwwroot/htmlpage.html b/src/MetaPackages/samples/SampleApp/wwwroot/htmlpage.html similarity index 100% rename from samples/SampleApp/wwwroot/htmlpage.html rename to src/MetaPackages/samples/SampleApp/wwwroot/htmlpage.html diff --git a/src/Directory.Build.props b/src/MetaPackages/src/Directory.Build.props similarity index 100% rename from src/Directory.Build.props rename to src/MetaPackages/src/Directory.Build.props diff --git a/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs b/src/MetaPackages/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs similarity index 100% rename from src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs rename to src/MetaPackages/src/Microsoft.AspNetCore/HostFilteringStartupFilter.cs diff --git a/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj b/src/MetaPackages/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj similarity index 100% rename from src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj rename to src/MetaPackages/src/Microsoft.AspNetCore/Microsoft.AspNetCore.csproj diff --git a/src/Microsoft.AspNetCore/WebHost.cs b/src/MetaPackages/src/Microsoft.AspNetCore/WebHost.cs similarity index 100% rename from src/Microsoft.AspNetCore/WebHost.cs rename to src/MetaPackages/src/Microsoft.AspNetCore/WebHost.cs diff --git a/src/Microsoft.AspNetCore/baseline.netcore.json b/src/MetaPackages/src/Microsoft.AspNetCore/baseline.netcore.json similarity index 100% rename from src/Microsoft.AspNetCore/baseline.netcore.json rename to src/MetaPackages/src/Microsoft.AspNetCore/baseline.netcore.json diff --git a/test/Directory.Build.props b/src/MetaPackages/test/Directory.Build.props similarity index 100% rename from test/Directory.Build.props rename to src/MetaPackages/test/Directory.Build.props diff --git a/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj b/src/MetaPackages/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj similarity index 100% rename from test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj rename to src/MetaPackages/test/Microsoft.AspNetCore.FunctionalTests/Microsoft.AspNetCore.FunctionalTests.csproj diff --git a/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs b/src/MetaPackages/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs rename to src/MetaPackages/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs diff --git a/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx b/src/MetaPackages/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx similarity index 100% rename from test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx rename to src/MetaPackages/test/Microsoft.AspNetCore.FunctionalTests/testCert.pfx diff --git a/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj b/src/MetaPackages/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj similarity index 100% rename from test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj rename to src/MetaPackages/test/Microsoft.AspNetCore.Tests/Microsoft.AspNetCore.Tests.csproj diff --git a/test/Microsoft.AspNetCore.Tests/WebHostTests.cs b/src/MetaPackages/test/Microsoft.AspNetCore.Tests/WebHostTests.cs similarity index 100% rename from test/Microsoft.AspNetCore.Tests/WebHostTests.cs rename to src/MetaPackages/test/Microsoft.AspNetCore.Tests/WebHostTests.cs diff --git a/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj b/src/MetaPackages/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj similarity index 100% rename from test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj rename to src/MetaPackages/test/TestSites/CreateDefaultBuilderApp/CreateDefaultBuilderApp.csproj diff --git a/test/TestSites/CreateDefaultBuilderApp/Program.cs b/src/MetaPackages/test/TestSites/CreateDefaultBuilderApp/Program.cs similarity index 100% rename from test/TestSites/CreateDefaultBuilderApp/Program.cs rename to src/MetaPackages/test/TestSites/CreateDefaultBuilderApp/Program.cs diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json b/src/MetaPackages/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json similarity index 100% rename from test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json rename to src/MetaPackages/test/TestSites/CreateDefaultBuilderApp/appsettings.Development.json diff --git a/test/TestSites/CreateDefaultBuilderApp/appsettings.json b/src/MetaPackages/test/TestSites/CreateDefaultBuilderApp/appsettings.json similarity index 100% rename from test/TestSites/CreateDefaultBuilderApp/appsettings.json rename to src/MetaPackages/test/TestSites/CreateDefaultBuilderApp/appsettings.json diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj b/src/MetaPackages/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj rename to src/MetaPackages/test/TestSites/CreateDefaultBuilderOfTApp/CreateDefaultBuilderOfTApp.csproj diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs b/src/MetaPackages/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/Program.cs rename to src/MetaPackages/test/TestSites/CreateDefaultBuilderOfTApp/Program.cs diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json b/src/MetaPackages/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json rename to src/MetaPackages/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.Development.json diff --git a/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json b/src/MetaPackages/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json similarity index 100% rename from test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json rename to src/MetaPackages/test/TestSites/CreateDefaultBuilderOfTApp/appsettings.json diff --git a/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj b/src/MetaPackages/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj similarity index 100% rename from test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj rename to src/MetaPackages/test/TestSites/DependencyInjectionApp/DependencyInjectionApp.csproj diff --git a/test/TestSites/DependencyInjectionApp/Program.cs b/src/MetaPackages/test/TestSites/DependencyInjectionApp/Program.cs similarity index 100% rename from test/TestSites/DependencyInjectionApp/Program.cs rename to src/MetaPackages/test/TestSites/DependencyInjectionApp/Program.cs diff --git a/test/TestSites/StartRequestDelegateUrlApp/Program.cs b/src/MetaPackages/test/TestSites/StartRequestDelegateUrlApp/Program.cs similarity index 100% rename from test/TestSites/StartRequestDelegateUrlApp/Program.cs rename to src/MetaPackages/test/TestSites/StartRequestDelegateUrlApp/Program.cs diff --git a/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj b/src/MetaPackages/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj similarity index 100% rename from test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj rename to src/MetaPackages/test/TestSites/StartRequestDelegateUrlApp/StartRequestDelegateUrlApp.csproj diff --git a/test/TestSites/StartRouteBuilderUrlApp/Program.cs b/src/MetaPackages/test/TestSites/StartRouteBuilderUrlApp/Program.cs similarity index 100% rename from test/TestSites/StartRouteBuilderUrlApp/Program.cs rename to src/MetaPackages/test/TestSites/StartRouteBuilderUrlApp/Program.cs diff --git a/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj b/src/MetaPackages/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj similarity index 100% rename from test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj rename to src/MetaPackages/test/TestSites/StartRouteBuilderUrlApp/StartRouteBuilderUrlApp.csproj diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs b/src/MetaPackages/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs similarity index 100% rename from test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs rename to src/MetaPackages/test/TestSites/StartWithIApplicationBuilderUrlApp/Program.cs diff --git a/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj b/src/MetaPackages/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj similarity index 100% rename from test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj rename to src/MetaPackages/test/TestSites/StartWithIApplicationBuilderUrlApp/StartWithIApplicationBuilderUrlApp.csproj diff --git a/version.props b/src/MetaPackages/version.props similarity index 100% rename from version.props rename to src/MetaPackages/version.props