Skip to content

Commit

Permalink
Updated build
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesDawson committed Sep 27, 2022
1 parent 860fc55 commit 48ab511
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,5 @@ coverage.cobertura.xml

# Scripted build artifacts
/_codeCoverage
/_packages
/_packages
*.sbom.*
86 changes: 64 additions & 22 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@
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 (
[Parameter(Position=0)]
[string[]] $Tasks = @("."),

[Parameter()]
[string] $Configuration = "Release",
[string] $Configuration = "Debug",

[Parameter()]
[string] $BuildRepositoryUri = "",
Expand All @@ -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
Expand All @@ -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 = ""


Expand All @@ -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 {}

0 comments on commit 48ab511

Please sign in to comment.