From 70f528b767c6a1b49a0738dcc98f61efa324073c Mon Sep 17 00:00:00 2001 From: Pratik Sanglikar Date: Thu, 14 Jul 2022 22:12:24 -0700 Subject: [PATCH] Add .net6 to targets (#334) Fixes #290 --- .pipelines/pipeline.user.windows.yml | 17 ++++++++++++----- build.cmd | 7 ------- build.ps1 | 5 +++-- build/CallPowerShell.cmd | 1 + build/ChoosePowerShell.cmd | 18 ------------------ build/install-dotnet.ps1 | 6 ++++++ build/resolve-dotnet.ps1 | 15 +++++++++++++++ pack.cmd | 7 ------- pack.ps1 | 3 ++- ...ft.Azure.AppConfiguration.AspNetCore.csproj | 2 +- ...re.AppConfiguration.Functions.Worker.csproj | 2 +- test.cmd | 5 ----- test.ps1 | 9 +++++++++ ...sts.AzureAppConfiguration.AspNetCore.csproj | 2 +- ...ureAppConfiguration.Functions.Worker.csproj | 2 +- .../Tests.AzureAppConfiguration.csproj | 2 +- 16 files changed, 53 insertions(+), 50 deletions(-) delete mode 100644 build.cmd create mode 100644 build/CallPowerShell.cmd delete mode 100644 build/ChoosePowerShell.cmd create mode 100644 build/install-dotnet.ps1 create mode 100644 build/resolve-dotnet.ps1 delete mode 100644 pack.cmd delete mode 100644 test.cmd create mode 100644 test.ps1 diff --git a/.pipelines/pipeline.user.windows.yml b/.pipelines/pipeline.user.windows.yml index 28c87dcb..4750d66c 100644 --- a/.pipelines/pipeline.user.windows.yml +++ b/.pipelines/pipeline.user.windows.yml @@ -7,16 +7,21 @@ environment: restore: commands: + - !!defaultcommand + name: 'Install .NET' + command: 'build/CallPowerShell.cmd' + arguments: 'build/install-dotnet.ps1 -RestoreOnly' - !!defaultcommand name: 'Restore' - command: 'build.cmd' - arguments: '-RestoreOnly' + command: 'build/CallPowerShell.cmd' + arguments: 'build.ps1 -RestoreOnly' build: commands: - !!buildcommand name: 'Dotnet Build' - command: 'build.cmd' + command: 'build/CallPowerShell.cmd' + arguments: 'build.ps1' logs: - from: 'buildlogs' to: 'Build Logs' @@ -32,7 +37,8 @@ package: commands: - !!buildcommand name: 'Dotnet Pack' - command: 'pack.cmd' + command: 'build/CallPowerShell.cmd' + arguments: 'pack.ps1' logs: - from: 'buildlogs' to: 'Build Logs' @@ -48,7 +54,8 @@ test: commands: - !!testcommand name: 'Dotnet Test' - command: 'test.cmd' + command: 'build/CallPowerShell.cmd' + arguments: 'test.ps1' fail_on_stderr: false testresults: - title: 'Unit Tests' diff --git a/build.cmd b/build.cmd deleted file mode 100644 index c5e5f9c2..00000000 --- a/build.cmd +++ /dev/null @@ -1,7 +0,0 @@ -call %~dp0build\ChoosePowerShell.cmd - -IF %ERRORLEVEL% NEQ 0 ( - exit /B 1 -) - -%PowerShell% "%~dp0build.ps1" %* \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 379ca0b9..82f5e196 100644 --- a/build.ps1 +++ b/build.ps1 @@ -20,6 +20,7 @@ $ErrorActionPreference = "Stop" $LogDirectory = "$PSScriptRoot\buildlogs" $Solution = "$PSScriptRoot\Microsoft.Extensions.Configuration.AzureAppConfiguration.sln" +$dotnet = & "$PSScriptRoot/build/resolve-dotnet.ps1" # Create the log directory. if ((Test-Path -Path $LogDirectory) -ne $true) { @@ -28,11 +29,11 @@ if ((Test-Path -Path $LogDirectory) -ne $true) { if ($RestoreOnly) { - dotnet restore "$Solution" + & $dotnet restore "$Solution" } else { - dotnet build -c $BuildConfig "$Solution" | Tee-Object -FilePath "$LogDirectory\build.log" + & $dotnet build -c $BuildConfig "$Solution" | Tee-Object -FilePath "$LogDirectory\build.log" } exit $LASTEXITCODE diff --git a/build/CallPowerShell.cmd b/build/CallPowerShell.cmd new file mode 100644 index 00000000..efb8cfc8 --- /dev/null +++ b/build/CallPowerShell.cmd @@ -0,0 +1 @@ +PowerShell %~dp0..\%* \ No newline at end of file diff --git a/build/ChoosePowerShell.cmd b/build/ChoosePowerShell.cmd deleted file mode 100644 index 2d15abd9..00000000 --- a/build/ChoosePowerShell.cmd +++ /dev/null @@ -1,18 +0,0 @@ -:: where.exe does not exist in windows container, application specific test must be used to check for existence - -pwsh -Command Write-Host "a" - -IF %ERRORLEVEL% == 0 ( - set PowerShell=pwsh - exit /B 0 -) - -PowerShell -Command Write-Host "a" - -IF %ERRORLEVEL% == 0 ( - set PowerShell=PowerShell - exit /B 0 -) - -echo Could not find a suitable PowerShell executable. -EXIT /B 1 diff --git a/build/install-dotnet.ps1 b/build/install-dotnet.ps1 new file mode 100644 index 00000000..0c92b8b8 --- /dev/null +++ b/build/install-dotnet.ps1 @@ -0,0 +1,6 @@ +# Installs .NET 6 for CI/CD environment +# see: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#examples + +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; + +&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 6.0.301 \ No newline at end of file diff --git a/build/resolve-dotnet.ps1 b/build/resolve-dotnet.ps1 new file mode 100644 index 00000000..c27b8dcf --- /dev/null +++ b/build/resolve-dotnet.ps1 @@ -0,0 +1,15 @@ +# Resolves dotnet execution path +# Locations considered include dotnet install script default location and somewhere on path + +$CI_CD_INSTALL_PATH = "$env:LOCALAPPDATA\Microsoft\dotnet\dotnet.exe" + +if (Test-Path $CI_CD_INSTALL_PATH) +{ + $CI_CD_INSTALL_PATH + + return +} + +$dotnet = Get-Command dotnet.exe -ErrorAction Stop + +$dotnet.Source \ No newline at end of file diff --git a/pack.cmd b/pack.cmd deleted file mode 100644 index b0f8a074..00000000 --- a/pack.cmd +++ /dev/null @@ -1,7 +0,0 @@ -call %~dp0build\ChoosePowerShell.cmd - -IF %ERRORLEVEL% NEQ 0 ( - exit /B 1 -) - -%PowerShell% "%~dp0pack.ps1" %* \ No newline at end of file diff --git a/pack.ps1 b/pack.ps1 index d2038711..f563fe91 100644 --- a/pack.ps1 +++ b/pack.ps1 @@ -16,6 +16,7 @@ $ErrorActionPreference = "Stop" $PublishRelativePath = "bin\PackageOutput" $LogDirectory = "$PSScriptRoot\buildlogs" +$dotnet = & "$PSScriptRoot/build/resolve-dotnet.ps1" $targetProjects = @( "Microsoft.Extensions.Configuration.AzureAppConfiguration", @@ -33,7 +34,7 @@ foreach ($project in $targetProjects) $projectPath = "$PSScriptRoot\src\$project\$project.csproj" $outputPath = "$PSScriptRoot\src\$project\$PublishRelativePath" - dotnet pack -c $BuildConfig -o "$outputPath" "$projectPath" --no-build | Tee-Object -FilePath "$LogDirectory\build.log" + & $dotnet pack -c $BuildConfig -o "$outputPath" "$projectPath" --no-build | Tee-Object -FilePath "$LogDirectory\build.log" } exit $LASTEXITCODE diff --git a/src/Microsoft.Azure.AppConfiguration.AspNetCore/Microsoft.Azure.AppConfiguration.AspNetCore.csproj b/src/Microsoft.Azure.AppConfiguration.AspNetCore/Microsoft.Azure.AppConfiguration.AspNetCore.csproj index f7c947c3..107a87ec 100644 --- a/src/Microsoft.Azure.AppConfiguration.AspNetCore/Microsoft.Azure.AppConfiguration.AspNetCore.csproj +++ b/src/Microsoft.Azure.AppConfiguration.AspNetCore/Microsoft.Azure.AppConfiguration.AspNetCore.csproj @@ -2,7 +2,7 @@ - netstandard2.0;netcoreapp3.1;net5.0 + netstandard2.0;netcoreapp3.1;net5.0;net6.0 Microsoft.Azure.AppConfiguration.AspNetCore allows developers to use Microsoft Azure App Configuration service as a configuration source in their applications. This package adds additional features for ASP.NET Core applications to the existing package Microsoft.Extensions.Configuration.AzureAppConfiguration. true false diff --git a/src/Microsoft.Azure.AppConfiguration.Functions.Worker/Microsoft.Azure.AppConfiguration.Functions.Worker.csproj b/src/Microsoft.Azure.AppConfiguration.Functions.Worker/Microsoft.Azure.AppConfiguration.Functions.Worker.csproj index e1a2db5c..313d4401 100644 --- a/src/Microsoft.Azure.AppConfiguration.Functions.Worker/Microsoft.Azure.AppConfiguration.Functions.Worker.csproj +++ b/src/Microsoft.Azure.AppConfiguration.Functions.Worker/Microsoft.Azure.AppConfiguration.Functions.Worker.csproj @@ -2,7 +2,7 @@ - net5.0 + net5.0;net6.0 Microsoft.Azure.AppConfiguration.Functions.Worker allows developers to use the Microsoft Azure App Configuration service as a configuration source in their applications. This package adds additional features to the existing package Microsoft.Extensions.Configuration.AzureAppConfiguration for .NET Azure Functions running in an isolated process. true false diff --git a/test.cmd b/test.cmd deleted file mode 100644 index 695c564c..00000000 --- a/test.cmd +++ /dev/null @@ -1,5 +0,0 @@ -cd /D "%~dp0" - -dotnet test tests\Tests.AzureAppConfiguration\Tests.AzureAppConfiguration.csproj --logger trx || exit /b 1 -dotnet test tests\Tests.AzureAppConfiguration.AspNetCore\Tests.AzureAppConfiguration.AspNetCore.csproj --logger trx || exit /b 1 -dotnet test tests\Tests.AzureAppConfiguration.Functions.Worker\Tests.AzureAppConfiguration.Functions.Worker.csproj --logger trx || exit /b 1 diff --git a/test.ps1 b/test.ps1 new file mode 100644 index 00000000..19c80dff --- /dev/null +++ b/test.ps1 @@ -0,0 +1,9 @@ +$ErrorActionPreference = "Stop" + +$dotnet = & "$PSScriptRoot/build/resolve-dotnet.ps1" + +& $dotnet test "$PSScriptRoot\tests\Tests.AzureAppConfiguration\Tests.AzureAppConfiguration.csproj" --logger trx +& $dotnet test "$PSScriptRoot\tests\Tests.AzureAppConfiguration.AspNetCore\Tests.AzureAppConfiguration.AspNetCore.csproj" --logger trx +& $dotnet test "$PSScriptRoot\tests\Tests.AzureAppConfiguration.Functions.Worker\Tests.AzureAppConfiguration.Functions.Worker.csproj" --logger trx + +exit $LASTEXITCODE \ No newline at end of file diff --git a/tests/Tests.AzureAppConfiguration.AspNetCore/Tests.AzureAppConfiguration.AspNetCore.csproj b/tests/Tests.AzureAppConfiguration.AspNetCore/Tests.AzureAppConfiguration.AspNetCore.csproj index 0ee2b452..6a04aaa9 100644 --- a/tests/Tests.AzureAppConfiguration.AspNetCore/Tests.AzureAppConfiguration.AspNetCore.csproj +++ b/tests/Tests.AzureAppConfiguration.AspNetCore/Tests.AzureAppConfiguration.AspNetCore.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;netcoreapp3.1;net5.0 + netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 8.0 false true diff --git a/tests/Tests.AzureAppConfiguration.Functions.Worker/Tests.AzureAppConfiguration.Functions.Worker.csproj b/tests/Tests.AzureAppConfiguration.Functions.Worker/Tests.AzureAppConfiguration.Functions.Worker.csproj index 24445051..d4f87588 100644 --- a/tests/Tests.AzureAppConfiguration.Functions.Worker/Tests.AzureAppConfiguration.Functions.Worker.csproj +++ b/tests/Tests.AzureAppConfiguration.Functions.Worker/Tests.AzureAppConfiguration.Functions.Worker.csproj @@ -1,7 +1,7 @@  - net5.0 + net5.0;net6.0 8.0 false true diff --git a/tests/Tests.AzureAppConfiguration/Tests.AzureAppConfiguration.csproj b/tests/Tests.AzureAppConfiguration/Tests.AzureAppConfiguration.csproj index 8a2c280d..05284d04 100644 --- a/tests/Tests.AzureAppConfiguration/Tests.AzureAppConfiguration.csproj +++ b/tests/Tests.AzureAppConfiguration/Tests.AzureAppConfiguration.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;netcoreapp3.1;net5.0 + netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 8.0 false true