1 Star 1 Fork 1

麦禾/Dapper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.ps1 3.33 KB
一键复制 编辑 原始数据 按行查看 历史
[CmdletBinding(PositionalBinding=$false)]
param(
[string] $Version,
[string] $BuildNumber,
[bool] $CreatePackages,
[bool] $RunTests = $true,
[string] $PullRequestNumber
)
function CalculateVersion() {
if ($version) {
return $version
}
$semVersion = '';
$path = $pwd;
while (!$semVersion) {
if (Test-Path (Join-Path $path "semver.txt")) {
$semVersion = Get-Content (Join-Path $path "semver.txt")
break
}
if ($PSScriptRoot -eq $path) {
break
}
$path = Split-Path $path -Parent
}
if (!$semVersion) {
Write-Error "semver.txt was not found in $pwd or any parent directory"
Exit 1
}
return "$semVersion-$BuildNumber"
}
Write-Host "Run Parameters:" -ForegroundColor Cyan
Write-Host "Version: $Version"
Write-Host "BuildNumber: $BuildNumber"
Write-Host "CreatePackages: $CreatePackages"
Write-Host "RunTests: $RunTests"
Write-Host "Base Version: $(CalculateVersion)"
$packageOutputFolder = "$PSScriptRoot\.nupkgs"
$projectsToBuild =
'Dapper',
'Dapper.StrongName',
'Dapper.Contrib',
'Dapper.EntityFramework',
'Dapper.EntityFramework.StrongName',
'Dapper.Rainbow',
'Dapper.SqlBuilder'
$testsToRun =
'Dapper.Tests',
'Dapper.Tests.Contrib'
if (!$Version -and !$BuildNumber) {
Write-Host "ERROR: You must supply either a -Version or -BuildNumber argument. `
Use -Version `"4.0.0`" for explicit version specification, or `
Use -BuildNumber `"12345`" for generation using <semver.txt>-<buildnumber>" -ForegroundColor Yellow
Exit 1
}
if ($PullRequestNumber) {
Write-Host "Building for a pull request (#$PullRequestNumber), skipping packaging." -ForegroundColor Yellow
$CreatePackages = $false
}
if ($RunTests) {
dotnet restore /ConsoleLoggerParameters:Verbosity=Quiet
foreach ($project in $testsToRun) {
Write-Host "Running tests: $project (all frameworks)" -ForegroundColor "Magenta"
Push-Location "$project"
dotnet xunit
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Pop-Location
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
Pop-Location
}
}
if ($CreatePackages) {
mkdir -Force $packageOutputFolder | Out-Null
Write-Host "Clearing existing $packageOutputFolder..." -NoNewline
Get-ChildItem $packageOutputFolder | Remove-Item
Write-Host "done." -ForegroundColor "Green"
Write-Host "Building all packages" -ForegroundColor "Green"
}
foreach ($project in $projectsToBuild) {
Write-Host "Working on $project`:" -ForegroundColor "Magenta"
Push-Location ".\$project"
$semVer = CalculateVersion
Write-Host " Restoring and packing $project... (Version:" -NoNewline -ForegroundColor "Magenta"
Write-Host $semVer -NoNewline -ForegroundColor "Cyan"
Write-Host ")" -ForegroundColor "Magenta"
$targets = "Restore"
if ($CreatePackages) {
$targets += ";Pack"
}
dotnet msbuild "/t:$targets" "/p:Configuration=Release" "/p:Version=$semVer" "/p:PackageOutputPath=$packageOutputFolder" "/p:CI=true" "/p:NuGetBuildTasksPackTargets='000'"
Pop-Location
Write-Host "Done." -ForegroundColor "Green"
Write-Host ""
}
Write-Host "Build Complete." -ForegroundColor "Green"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nuizi/Dapper.git
git@gitee.com:nuizi/Dapper.git
nuizi
Dapper
Dapper
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385