From 48ab511a743f3a8f5bb38979cab5a818d04a7848 Mon Sep 17 00:00:00 2001 From: James Dawson Date: Tue, 27 Sep 2022 18:15:56 +0100 Subject: [PATCH 1/7] Updated build --- .gitignore | 3 +- build.ps1 | 86 ++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 66 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 3699d25..bad3b67 100644 --- a/.gitignore +++ b/.gitignore @@ -346,4 +346,5 @@ coverage.cobertura.xml # Scripted build artifacts /_codeCoverage -/_packages \ No newline at end of file +/_packages +*.sbom.* \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 71e8677..ed0970c 100644 --- a/build.ps1 +++ b/build.ps1 @@ -30,6 +30,12 @@ The path to import the Endjin.RecommendedPractices.Build module from. This is useful when testing pre-release versions of the Endjin.RecommendedPractices.Build that are not yet available in the PowerShell Gallery. +.PARAMETER BuildModuleVersion + The version of the Endjin.RecommendedPractices.Build module to import. This is useful when + testing pre-release versions of the Endjin.RecommendedPractices.Build that are not yet + available in the PowerShell Gallery. +.PARAMETER InvokeBuildModuleVersion + The version of the InvokeBuild module to be used. #> [CmdletBinding()] param ( @@ -37,7 +43,7 @@ param ( [string[]] $Tasks = @("."), [Parameter()] - [string] $Configuration = "Release", + [string] $Configuration = "Debug", [Parameter()] [string] $BuildRepositoryUri = "", @@ -62,17 +68,23 @@ param ( [switch] $Clean, [Parameter()] - [string] $BuildModulePath + [string] $BuildModulePath, + + [Parameter()] + [version] $BuildModuleVersion = "0.2.10", + + [Parameter()] + [version] $InvokeBuildModuleVersion = "5.7.1" ) $ErrorActionPreference = $ErrorActionPreference ? $ErrorActionPreference : 'Stop' -$InformationPreference = $InformationAction ? $InformationAction : 'Continue' +$InformationPreference = 'Continue' $here = Split-Path -Parent $PSCommandPath #region InvokeBuild setup if (!(Get-Module -ListAvailable InvokeBuild)) { - Install-Module InvokeBuild -RequiredVersion 5.7.1 -Scope CurrentUser -Force -Repository PSGallery + Install-Module InvokeBuild -RequiredVersion $InvokeBuildModuleVersion -Scope CurrentUser -Force -Repository PSGallery } Import-Module InvokeBuild # This handles calling the build engine when this file is run like a normal PowerShell script @@ -89,54 +101,57 @@ if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') { } #endregion -# Import shared tasks and initialise build framework +#region Import shared tasks and initialise build framework if (!($BuildModulePath)) { - if (!(Get-Module -ListAvailable Endjin.RecommendedPractices.Build)) { + if (!(Get-Module -ListAvailable Endjin.RecommendedPractices.Build | ? { $_.Version -eq $BuildModuleVersion })) { Write-Information "Installing 'Endjin.RecommendedPractices.Build' module..." - Install-Module Endjin.RecommendedPractices.Build -RequiredVersion 0.1.1 -AllowPrerelease -Scope CurrentUser -Force -Repository PSGallery + Install-Module Endjin.RecommendedPractices.Build -RequiredVersion $BuildModuleVersion -Scope CurrentUser -Force -Repository PSGallery } $BuildModulePath = "Endjin.RecommendedPractices.Build" } else { Write-Information "BuildModulePath: $BuildModulePath" } -Import-Module $BuildModulePath -Force +Import-Module $BuildModulePath -RequiredVersion $BuildModuleVersion -Force # Load the build process & tasks . Endjin.RecommendedPractices.Build.tasks +#endregion + # # Build process control options # +$SkipInit = $false $SkipVersion = $false $SkipBuild = $false -$CleanBuild = $false +$CleanBuild = $Clean $SkipTest = $false $SkipTestReport = $false $SkipPackage = $false -# Advanced build settings -$EnableGitVersionAdoVariableWorkaround = $false # # Build process configuration # -$SolutionToBuild = (Resolve-Path (Join-Path $here ".\Solutions\Corvus.JsonSchema.sln")).Path - +$SolutionToBuild = (Resolve-Path (Join-Path $here ".\Solutions\Corvus.UriTemplates.sln")).Path +$ProjectsToPublish = @( + # "Solutions/MySolution/MyWebSite/MyWebSite.csproj" +) +$NuSpecFilesToPackage = @( + # "Solutions/MySolution/MyProject/MyProject.nuspec" +) # # Update to the latest report generator versions -# $ReportGeneratorToolVersion = "5.1.10" # -# Temporarily skip the test report -# -$SkipTestReport = $true - -# -# Specify files to exclude from test coverage +# Specify files to exclude from code coverage # This option is for excluding generated code +# - Use file path or directory path with globbing (e.g dir1/*.cs) +# - Use single or multiple paths (separated by comma) (e.g. **/dir1/class1.cs,**/dir2/*.cs,**/dir3/**/*.cs) +# $ExcludeFilesFromCodeCoverage = "" @@ -145,12 +160,39 @@ task . FullBuild # build extensibility tasks +task RunFirst {} +task PreInit { + Write-Host "Initialising submodule" + exec { & git submodule init } + exec { & git submodule update } +} +task PostInit {} +task PreVersion {} +task PostVersion {} task PreBuild {} task PostBuild {} -task PreTest {} -task PostTest {} +task PreTest { + # .net 7 bug workaround - ref: https://github.com/microsoft/vstest/issues/4014 + Write-Host "Set temporary ENV vars for MSBuild" + $env:CollectCoverage = $EnableCoverage + $env:CoverletOutputFormat = "cobertura" +} +task PostTest { + Get-ChildItem env:/CollectCoverage + Get-ChildItem env:/CoverletOutputFormat + + # cleanup .net 7 bug workaround + Write-Host "Clean-up temporary ENV vars for MSBuild" + Remove-Item env:/CollectCoverage + Remove-Item env:/CoverletOutputFormat +} task PreTestReport {} task PostTestReport {} +task PreAnalysis {} +task PostAnalysis {} task PrePackage {} task PostPackage {} +task PrePublish {} +task PostPublish {} +task RunLast {} From 33a854ab324dcf5876688cacccee06eaa14490bc Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Wed, 28 Sep 2022 09:32:13 +0100 Subject: [PATCH 2/7] Temporarily opt out of code coverage reporting. --- .../packages.lock.json | 20 ------------------- build.ps1 | 4 ++++ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json b/Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json index 3158952..d4010b9 100644 --- a/Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json +++ b/Solutions/Corvus.UriTemplate.Benchmarking/packages.lock.json @@ -58,21 +58,6 @@ "Microsoft.SourceLink.GitHub": "1.1.1" } }, - "Roslynator.Analyzers": { - "type": "Direct", - "requested": "[4.1.1, )", - "resolved": "4.1.1", - "contentHash": "3cPVlrB1PytlO1ztZZBOExDKQWpMZgI15ZDa0BqLu0l6xv+xIRfEpqjNRcpvUy3aLxWTkPgSKZbbaO+VoFEJ1g==" - }, - "StyleCop.Analyzers": { - "type": "Direct", - "requested": "[1.2.0-beta.435, )", - "resolved": "1.2.0-beta.435", - "contentHash": "TADk7vdGXtfTnYCV7GyleaaRTQjfoSfZXprQrVMm7cSJtJbFc1QIbWPyLvrgrfGdfHbGmUPvaN4ODKNxg2jgPQ==", - "dependencies": { - "StyleCop.Analyzers.Unstable": "1.2.0.435" - } - }, "Tavis.UriTemplates": { "type": "Direct", "requested": "[1.1.1, )", @@ -383,11 +368,6 @@ "Microsoft.NETCore.Targets": "1.0.1" } }, - "StyleCop.Analyzers.Unstable": { - "type": "Transitive", - "resolved": "1.2.0.435", - "contentHash": "ouwPWZxbOV3SmCZxIRqHvljkSzkCyi1tDoMzQtDb/bRP8ctASV/iRJr+A2Gdj0QLaLmWnqTWDrH82/iP+X80Lg==" - }, "System.AppContext": { "type": "Transitive", "resolved": "4.1.0", diff --git a/build.ps1 b/build.ps1 index ed0970c..657a9d8 100644 --- a/build.ps1 +++ b/build.ps1 @@ -154,6 +154,10 @@ $ReportGeneratorToolVersion = "5.1.10" # $ExcludeFilesFromCodeCoverage = "" +# +# Temporarily skip the test report +# +$SkipTestReport = $true # Synopsis: Build, Test and Package task . FullBuild From 78af2c5dd9a473f3ba8a006a24aa824fca6baad6 Mon Sep 17 00:00:00 2001 From: James Dawson Date: Wed, 28 Sep 2022 10:23:47 +0100 Subject: [PATCH 3/7] Test updated ADO build template --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 49eea3c..5ccc0fd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,6 +13,7 @@ resources: type: github name: endjin/Endjin.RecommendedPractices.AzureDevopsPipelines.GitHub endpoint: corvus-dotnet-github + ref: refs/heads/feature/scripted-build-support-custom-tasks jobs: - template: templates/build.and.release.scripted.yml@recommended_practices From 9cb101151e9e70e555162b9a50588d6ea9fa3df6 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Wed, 28 Sep 2022 13:10:51 +0100 Subject: [PATCH 4/7] Added support for multiple SDK versions. --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 49eea3c..8f18a16 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,4 +22,6 @@ jobs: service_connection_github: $(Endjin_Service_Connection_GitHub) solution_to_build: $(Endjin_Solution_To_Build) netSdkVersion: '7.x' + additionalNetSdkVersions: + - '6.x' includeNetSdkPreviewVersions: 'true' From 6d242036145c0cb776fbdaca85e86a55667c656d Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Wed, 28 Sep 2022 13:27:25 +0100 Subject: [PATCH 5/7] Updated pipeline --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8f18a16..e7c1e5c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,7 +21,7 @@ jobs: service_connection_nuget_org: $(Endjin_Service_Connection_NuGet_Org) service_connection_github: $(Endjin_Service_Connection_GitHub) solution_to_build: $(Endjin_Solution_To_Build) - netSdkVersion: '7.x' additionalNetSdkVersions: - '6.x' + - '7.x' includeNetSdkPreviewVersions: 'true' From 3b936a8ed5c0ca055416116a97d2b0f26cece9dc Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Wed, 28 Sep 2022 13:34:30 +0100 Subject: [PATCH 6/7] Removed 6.x from the list of additional versions so it only gets installed once. --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fae6c4f..33b5dc7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,7 +22,7 @@ jobs: service_connection_nuget_org: $(Endjin_Service_Connection_NuGet_Org) service_connection_github: $(Endjin_Service_Connection_GitHub) solution_to_build: $(Endjin_Solution_To_Build) + netSdkVersion: '6.x' additionalNetSdkVersions: - - '6.x' - '7.x' includeNetSdkPreviewVersions: 'true' From a9854a486ae97e7dcac397ae8881c54e91f66b29 Mon Sep 17 00:00:00 2001 From: James Dawson Date: Wed, 28 Sep 2022 13:43:42 +0100 Subject: [PATCH 7/7] More builds updates --- .../Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj | 1 + azure-pipelines.yml | 1 - build.ps1 | 3 ++- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Solutions/Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj b/Solutions/Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj index ba5391b..c503766 100644 --- a/Solutions/Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj +++ b/Solutions/Corvus.UriTemplate.TavisApi.Tests/UriTemplateTests.csproj @@ -16,6 +16,7 @@ + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 33b5dc7..31ff04e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,7 +22,6 @@ jobs: service_connection_nuget_org: $(Endjin_Service_Connection_NuGet_Org) service_connection_github: $(Endjin_Service_Connection_GitHub) solution_to_build: $(Endjin_Solution_To_Build) - netSdkVersion: '6.x' additionalNetSdkVersions: - '7.x' includeNetSdkPreviewVersions: 'true' diff --git a/build.ps1 b/build.ps1 index 657a9d8..44f47b6 100644 --- a/build.ps1 +++ b/build.ps1 @@ -127,8 +127,9 @@ $SkipVersion = $false $SkipBuild = $false $CleanBuild = $Clean $SkipTest = $false -$SkipTestReport = $false +$SkipTestReport = $true $SkipPackage = $false +$SkipAnalysis = $false #