From b962a6091c643a7c8d445a49f025f006ce47e685 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Fri, 3 Apr 2020 22:07:05 +0800 Subject: [PATCH 01/10] Update version to 2.1.0 --- build/version.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/version.props b/build/version.props index 604d2156..7dc91a1e 100644 --- a/build/version.props +++ b/build/version.props @@ -1,7 +1,7 @@ 2 - 0 + 1 0 $(VersionMajor).$(VersionMinor).$(VersionPatch) From 42fa52af53c1c9c19a6bb9a6aa3846ef63843635 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 16:21:00 +0800 Subject: [PATCH 02/10] Add ServiceProviderOptions --- build/version.props | 2 +- .../DynamicProxyServiceProviderFactory.cs | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/build/version.props b/build/version.props index d705cb49..5f50de5e 100644 --- a/build/version.props +++ b/build/version.props @@ -1,7 +1,7 @@ 2 - 2 + 3 0 $(VersionMajor).$(VersionMinor).$(VersionPatch) diff --git a/src/AspectCore.Extensions.DependencyInjection/DynamicProxyServiceProviderFactory.cs b/src/AspectCore.Extensions.DependencyInjection/DynamicProxyServiceProviderFactory.cs index 01a2c703..e68a4d1f 100644 --- a/src/AspectCore.Extensions.DependencyInjection/DynamicProxyServiceProviderFactory.cs +++ b/src/AspectCore.Extensions.DependencyInjection/DynamicProxyServiceProviderFactory.cs @@ -5,6 +5,24 @@ namespace AspectCore.Extensions.DependencyInjection { public class DynamicProxyServiceProviderFactory : IServiceProviderFactory { + private ServiceProviderOptions _serviceProviderOptions; + + + public DynamicProxyServiceProviderFactory() + : this(null) + { + } + + public DynamicProxyServiceProviderFactory(bool validateScopes) + : this(new ServiceProviderOptions() {ValidateScopes = validateScopes}) + { + } + + public DynamicProxyServiceProviderFactory(ServiceProviderOptions serviceProviderOptions) + { + _serviceProviderOptions = serviceProviderOptions; + } + public IServiceCollection CreateBuilder(IServiceCollection services) { return services; @@ -12,7 +30,9 @@ public IServiceCollection CreateBuilder(IServiceCollection services) public IServiceProvider CreateServiceProvider(IServiceCollection containerBuilder) { - return containerBuilder.BuildDynamicProxyProvider(); + return _serviceProviderOptions == null + ? containerBuilder.BuildDynamicProxyProvider() + : containerBuilder.BuildDynamicProxyProvider(_serviceProviderOptions); } } -} +} \ No newline at end of file From 08307b7fc2409b803e8aed60ec9efb03d1224ceb Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 16:39:40 +0800 Subject: [PATCH 03/10] Fix cake argument --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 7526d9fe..dea8beed 100644 --- a/build.ps1 +++ b/build.ps1 @@ -179,5 +179,5 @@ if (!(Test-Path $CAKE_EXE)) { # Start Cake Write-Host "Running build script..." -Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" +Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" exit $LASTEXITCODE From 641dbeb69975044c6e213a347f88c8e59eb48eec Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 16:57:12 +0800 Subject: [PATCH 04/10] Fix cake argument --- build.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index dea8beed..5516d4e1 100644 --- a/build.ps1 +++ b/build.ps1 @@ -91,20 +91,20 @@ $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" $UseMono = ""; if($Mono.IsPresent) { Write-Verbose -Message "Using the Mono based scripting engine." - $UseMono = "-mono" + $UseMono = "--mono" } # Should we use the new Roslyn? $UseExperimental = ""; if($Experimental.IsPresent -and !($Mono.IsPresent)) { Write-Verbose -Message "Using experimental version of Roslyn." - $UseExperimental = "-experimental" + $UseExperimental = "--experimental" } # Is this a dry run? $UseDryRun = ""; if($WhatIf.IsPresent) { - $UseDryRun = "-dryrun" + $UseDryRun = "--dryrun" } # Make sure tools folder exists From 62d157144f8e7ae6b133a0dd82679d68146e4749 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 17:04:23 +0800 Subject: [PATCH 05/10] Remove un used cake argument --- build.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.ps1 b/build.ps1 index 5516d4e1..a95f03cf 100644 --- a/build.ps1 +++ b/build.ps1 @@ -91,20 +91,20 @@ $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" $UseMono = ""; if($Mono.IsPresent) { Write-Verbose -Message "Using the Mono based scripting engine." - $UseMono = "--mono" + $UseMono = "--mono=true" } # Should we use the new Roslyn? $UseExperimental = ""; if($Experimental.IsPresent -and !($Mono.IsPresent)) { Write-Verbose -Message "Using experimental version of Roslyn." - $UseExperimental = "--experimental" + $UseExperimental = "--experimental=true" } # Is this a dry run? $UseDryRun = ""; if($WhatIf.IsPresent) { - $UseDryRun = "--dryrun" + $UseDryRun = "--dryrun=true" } # Make sure tools folder exists @@ -179,5 +179,5 @@ if (!(Test-Path $CAKE_EXE)) { # Start Cake Write-Host "Running build script..." -Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" +Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $ScriptArgs" exit $LASTEXITCODE From 8feb5c9c3d58dbb43ef1de0e66c5cb3c8dfb2834 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 17:06:30 +0800 Subject: [PATCH 06/10] Remove all cake argument --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index a95f03cf..6bce6308 100644 --- a/build.ps1 +++ b/build.ps1 @@ -179,5 +179,5 @@ if (!(Test-Path $CAKE_EXE)) { # Start Cake Write-Host "Running build script..." -Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $ScriptArgs" +Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" $ScriptArgs" exit $LASTEXITCODE From a3a7c1e02cc9654d2d8372f5ec08b7508ba674a0 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 17:19:18 +0800 Subject: [PATCH 07/10] Use new cake script --- build.ps1 | 186 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 141 insertions(+), 45 deletions(-) diff --git a/build.ps1 b/build.ps1 index 6bce6308..f8dbd4d5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,3 +1,9 @@ +########################################################################## +# This is the Cake bootstrapper script for PowerShell. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## + <# .SYNOPSIS @@ -15,20 +21,17 @@ The build script target to run. The build configuration to use. .PARAMETER Verbosity Specifies the amount of information to be displayed. -.PARAMETER Experimental -Tells Cake to use the latest Roslyn release. -.PARAMETER WhatIf -Performs a dry run of the build script. -No tasks will be executed. -.PARAMETER Mono -Tells Cake to use the Mono scripting engine. +.PARAMETER ShowDescription +Shows description about tasks. +.PARAMETER DryRun +Performs a dry run. .PARAMETER SkipToolPackageRestore Skips restoring of packages. .PARAMETER ScriptArgs Remaining arguments are added here. .LINK -http://cakebuild.net +https://cakebuild.net #> @@ -36,19 +39,39 @@ http://cakebuild.net Param( [string]$Script = "build.cake", [string]$Target = "Default", - [ValidateSet("Release", "Debug")] [string]$Configuration = "Debug", [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] [string]$Verbosity = "Normal", - [switch]$Experimental = $true, - [Alias("DryRun","Noop")] - [switch]$WhatIf, - [switch]$Mono, + [switch]$ShowDescription, + [Alias("WhatIf", "Noop")] + [switch]$DryRun, [switch]$SkipToolPackageRestore, [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] [string[]]$ScriptArgs ) +# This is an automatic variable in PowerShell Core, but not in Windows PowerShell 5.x +if (-not (Test-Path variable:global:IsCoreCLR)) { + $IsCoreCLR = $false +} + +# Attempt to set highest encryption available for SecurityProtocol. +# PowerShell will not set this by default (until maybe .NET 4.6.x). This +# will typically produce a message for PowerShell v2 (just an info +# message though) +try { + # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48) + # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't + # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is + # installed (.NET 4.5 is an in-place upgrade). + # PowerShell Core already has support for TLS 1.2 so we can skip this if running in that. + if (-not $IsCoreCLR) { + [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48 + } + } catch { + Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3' + } + [Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null function MD5HashFile([string] $filePath) { @@ -71,52 +94,60 @@ function MD5HashFile([string] $filePath) { $file.Dispose() } + + if ($md5 -ne $null) + { + $md5.Dispose() + } } } +function GetProxyEnabledWebClient +{ + $wc = New-Object System.Net.WebClient + $proxy = [System.Net.WebRequest]::GetSystemWebProxy() + $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + $wc.Proxy = $proxy + return $wc +} + Write-Host "Preparing to run build script..." if(!$PSScriptRoot){ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } +if(!$Script){ + $Script = Join-Path $PSScriptRoot "build.cake" +} $TOOLS_DIR = Join-Path $PSScriptRoot "tools" +$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" +$MODULES_DIR = Join-Path $TOOLS_DIR "Modules" $NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" $CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" $NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" $PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" +$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" +$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" -# Should we use mono? -$UseMono = ""; -if($Mono.IsPresent) { - Write-Verbose -Message "Using the Mono based scripting engine." - $UseMono = "--mono=true" -} - -# Should we use the new Roslyn? -$UseExperimental = ""; -if($Experimental.IsPresent -and !($Mono.IsPresent)) { - Write-Verbose -Message "Using experimental version of Roslyn." - $UseExperimental = "--experimental=true" -} - -# Is this a dry run? -$UseDryRun = ""; -if($WhatIf.IsPresent) { - $UseDryRun = "--dryrun=true" -} +$env:CAKE_PATHS_TOOLS = $TOOLS_DIR +$env:CAKE_PATHS_ADDINS = $ADDINS_DIR +$env:CAKE_PATHS_MODULES = $MODULES_DIR # Make sure tools folder exists if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { Write-Verbose -Message "Creating tools directory..." - New-Item -Path $TOOLS_DIR -Type directory | out-null + New-Item -Path $TOOLS_DIR -Type Directory | Out-Null } # Make sure that packages.config exist. if (!(Test-Path $PACKAGES_CONFIG)) { Write-Verbose -Message "Downloading packages.config..." - try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { + try { + $wc = GetProxyEnabledWebClient + $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) + } catch { Throw "Could not download packages.config." } } @@ -124,7 +155,7 @@ if (!(Test-Path $PACKAGES_CONFIG)) { # Try find NuGet.exe in path if not exists if (!(Test-Path $NUGET_EXE)) { Write-Verbose -Message "Trying to find nuget.exe in PATH..." - $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) } + $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." @@ -136,14 +167,26 @@ if (!(Test-Path $NUGET_EXE)) { if (!(Test-Path $NUGET_EXE)) { Write-Verbose -Message "Downloading NuGet.exe..." try { - (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE) + $wc = GetProxyEnabledWebClient + $wc.DownloadFile($NUGET_URL, $NUGET_EXE) } catch { Throw "Could not download NuGet.exe." } } +# These are automatic variables in PowerShell Core, but not in Windows PowerShell 5.x +if (-not (Test-Path variable:global:ismacos)) { + $IsLinux = $false + $IsMacOS = $false +} + # Save nuget.exe path to environment to be available to child processed -$ENV:NUGET_EXE = $NUGET_EXE +$env:NUGET_EXE = $NUGET_EXE +$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { + "mono `"$NUGET_EXE`"" +} else { + "`"$NUGET_EXE`"" +} # Restore tools from NuGet? if(-Not $SkipToolPackageRestore.IsPresent) { @@ -151,24 +194,61 @@ if(-Not $SkipToolPackageRestore.IsPresent) { Set-Location $TOOLS_DIR # Check for changes in packages.config and remove installed tools if true. - [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) + [string] $md5Hash = MD5HashFile $PACKAGES_CONFIG if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or - ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { Write-Verbose -Message "Missing or changed package.config hash..." - Remove-Item * -Recurse -Exclude packages.config,nuget.exe + Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery | + Remove-Item -Recurse -Force } Write-Verbose -Message "Restoring tools from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" + + $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" if ($LASTEXITCODE -ne 0) { - Throw "An error occured while restoring NuGet tools." + Throw "An error occurred while restoring NuGet tools." } else { $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" } - Write-Verbose -Message ($NuGetOutput | out-string) + Write-Verbose -Message ($NuGetOutput | Out-String) + + Pop-Location +} + +# Restore addins from NuGet +if (Test-Path $ADDINS_PACKAGES_CONFIG) { + Push-Location + Set-Location $ADDINS_DIR + + Write-Verbose -Message "Restoring addins from NuGet..." + $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet addins." + } + + Write-Verbose -Message ($NuGetOutput | Out-String) + + Pop-Location +} + +# Restore modules from NuGet +if (Test-Path $MODULES_PACKAGES_CONFIG) { + Push-Location + Set-Location $MODULES_DIR + + Write-Verbose -Message "Restoring modules from NuGet..." + $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" + + if ($LASTEXITCODE -ne 0) { + Throw "An error occurred while restoring NuGet modules." + } + + Write-Verbose -Message ($NuGetOutput | Out-String) + Pop-Location } @@ -177,7 +257,23 @@ if (!(Test-Path $CAKE_EXE)) { Throw "Could not find Cake.exe at $CAKE_EXE" } +$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { + "mono `"$CAKE_EXE`"" +} else { + "`"$CAKE_EXE`"" +} + + # Build an array (not a string) of Cake arguments to be joined later +$cakeArguments = @() +if ($Script) { $cakeArguments += "`"$Script`"" } +if ($Target) { $cakeArguments += "--target=`"$Target`"" } +if ($Configuration) { $cakeArguments += "--configuration=$Configuration" } +if ($Verbosity) { $cakeArguments += "--verbosity=$Verbosity" } +if ($ShowDescription) { $cakeArguments += "--showdescription" } +if ($DryRun) { $cakeArguments += "--dryrun" } +$cakeArguments += $ScriptArgs + # Start Cake Write-Host "Running build script..." -Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" $ScriptArgs" -exit $LASTEXITCODE +Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")" +exit $LASTEXITCODE \ No newline at end of file From 655a0438e0c78c160bb2fe5a6d3286e7787f2095 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 17:30:46 +0800 Subject: [PATCH 08/10] Remove argument --- build.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index f8dbd4d5..cdffd240 100644 --- a/build.ps1 +++ b/build.ps1 @@ -38,10 +38,10 @@ https://cakebuild.net [CmdletBinding()] Param( [string]$Script = "build.cake", - [string]$Target = "Default", - [string]$Configuration = "Debug", + [string]$Target, + [string]$Configuration, [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] - [string]$Verbosity = "Normal", + [string]$Verbosity, [switch]$ShowDescription, [Alias("WhatIf", "Noop")] [switch]$DryRun, From 75e27578f9afbb3b12d9fae1cf917bf99867d4d4 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 17:33:18 +0800 Subject: [PATCH 09/10] Remove argument --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index cdffd240..e81a4597 100644 --- a/build.ps1 +++ b/build.ps1 @@ -37,7 +37,7 @@ https://cakebuild.net [CmdletBinding()] Param( - [string]$Script = "build.cake", + [string]$Script, [string]$Target, [string]$Configuration, [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] From 187eb0a307f4e969a0ca37159d908abb3249e075 Mon Sep 17 00:00:00 2001 From: liuhaoyang Date: Thu, 25 Feb 2021 17:36:40 +0800 Subject: [PATCH 10/10] Fix DeleteDirectory --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index d21b6adf..de1af1de 100644 --- a/build.cake +++ b/build.cake @@ -12,7 +12,7 @@ Task("Clean") { if (DirectoryExists("./artifacts")) { - DeleteDirectory("./artifacts", true); + DeleteDirectory("./artifacts", new DeleteDirectorySettings(){ Force = true }); } });