tasks/building.tasks.ps1
# Control flags $CleanBuild = $false # Options $FoldersToClean = @("bin", "obj", "TestResults", "_codeCoverage", "_packages") # Synopsis: Clean .NET solution task CleanSolution -If {$CleanBuild} { exec { dotnet clean $SolutionToBuild ` --configuration $Configuration ` --verbosity $LogLevel } # Delete output folders Write-Build White "Deleting output folders..." $FoldersToClean | ForEach-Object { Get-ChildItem -Path (Split-Path -Parent $SolutionToBuild) ` -Filter $_ ` -Recurse ` | Where-Object { $_.PSIsContainer } } | Remove-Item -Recurse -Force } # Synopsis: Build .NET solution task BuildSolution GitVersion,CleanSolution,RestorePackages,{ exec { dotnet build $SolutionToBuild ` --no-restore ` --configuration $Configuration ` /p:Version="$(($script:GitVersion).SemVer)" ` /p:EndjinRepositoryUrl="$BuildRepositoryUri" ` --verbosity $LogLevel } } task RestorePackages CleanSolution,{ exec { dotnet restore $SolutionToBuild ` --verbosity $LogLevel } } # Synopsis: Build .NET solution packages task BuildSolutionPackages GitVersion,{ exec { dotnet pack $SolutionToBuild ` --configuration $Configuration ` --no-build ` --no-restore ` --output $PackagesDir ` /p:EndjinRepositoryUrl="$BuildRepositoryUri" ` /p:PackageVersion="$(($script:GitVersion).SemVer)" ` --verbosity $LogLevel } } |