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/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/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 49eea3c..31ff04e 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 @@ -21,5 +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: '7.x' + additionalNetSdkVersions: + - '7.x' includeNetSdkPreviewVersions: 'true' diff --git a/build.ps1 b/build.ps1 index 71e8677..44f47b6 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,68 +101,103 @@ 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 +$SkipTestReport = $true $SkipPackage = $false +$SkipAnalysis = $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 = "" +# +# Temporarily skip the test report +# +$SkipTestReport = $true # Synopsis: Build, Test and Package 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 {}