|
1 | | -######################## |
2 | | -# THE BUILD! |
3 | | -######################## |
4 | | -Push-Location $PSScriptRoot |
5 | | - |
6 | | -function Invoke-DotNetBuild |
7 | | -{ |
8 | | - [cmdletbinding()] |
9 | | - param([string] $DirectoryName) |
10 | | - & dotnet build ("""" + $DirectoryName + """") -c Release; if($LASTEXITCODE -ne 0) { exit 1 } |
11 | | -} |
12 | | - |
13 | | -function Invoke-Tests |
14 | | -{ |
15 | | - [cmdletbinding()] |
16 | | - param([string] $DirectoryName) |
17 | | - & dotnet test ("""" + $DirectoryName + """") -c Release; if($LASTEXITCODE -ne 0) { exit 1 } |
18 | | -} |
19 | | - |
20 | | -function Invoke-DotNetPack |
21 | | -{ |
22 | | - [cmdletbinding()] |
23 | | - param([string] $DirectoryName) |
24 | | - & dotnet pack ("""" + $DirectoryName + """") -c Release -o .\artifacts\packages; if($LASTEXITCODE -ne 0) { exit 1 } |
25 | | -} |
26 | | - |
27 | | -function Remove-PathVariable |
28 | | -{ |
29 | | - [cmdletbinding()] |
30 | | - param([string] $VariableToRemove) |
31 | | - $path = [Environment]::GetEnvironmentVariable("PATH", "User") |
32 | | - $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } |
33 | | - [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") |
34 | | - $path = [Environment]::GetEnvironmentVariable("PATH", "Process") |
35 | | - $newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } |
36 | | - [Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") |
37 | | -} |
38 | | - |
39 | | -# Prepare the dotnet CLI folder |
40 | | -$env:DOTNET_INSTALL_DIR="$(Convert-Path "$PSScriptRoot")\.dotnet\win7-x64" |
41 | | -if (!(Test-Path $env:DOTNET_INSTALL_DIR)) |
42 | | -{ |
43 | | - mkdir $env:DOTNET_INSTALL_DIR | Out-Null |
44 | | -} |
45 | | - |
46 | | -# Download the dotnet CLI install script |
47 | | -if (!(Test-Path .\dotnet\install.ps1)) |
48 | | -{ |
49 | | - Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\.dotnet\dotnet-install.ps1" |
50 | | -} |
51 | | - |
52 | | -# Run the dotnet CLI install |
53 | | -& .\.dotnet\dotnet-install.ps1 |
54 | | - |
55 | | -# Add the dotnet folder path to the process. This gets skipped |
56 | | -# by Install-DotNetCli if it's already installed. |
57 | | -Remove-PathVariable $env:DOTNET_INSTALL_DIR |
58 | | -$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH" |
59 | | - |
60 | | -# Set build number |
61 | | -$env:DOTNET_BUILD_VERSION = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1}[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
62 | | -Write-Host "Build number:" $env:DOTNET_BUILD_VERSION |
63 | | - |
64 | | -# Clean |
65 | | -if(Test-Path .\artifacts) |
66 | | -{ |
67 | | - Remove-Item .\artifacts -Force -Recurse |
68 | | -} |
69 | | - |
70 | | -# Package restore |
71 | | -& dotnet restore |
72 | | - |
73 | | -# Build/package |
74 | | -Get-ChildItem -Path .\src -Filter *.xproj -Recurse | ForEach-Object { Invoke-DotNetPack $_.DirectoryName } |
75 | | -Get-ChildItem -Path .\samples -Filter *.xproj -Recurse | ForEach-Object { Invoke-DotNetBuild $_.DirectoryName } |
76 | | - |
77 | | -# Test |
78 | | -# Get-ChildItem -Path .\tests -Filter *.xproj -Recurse | ForEach-Object { Invoke-Tests $_.DirectoryName } |
79 | | - |
80 | | -Pop-Location |
81 | | - |
82 | | - |
| 1 | +echo "build: Build started" |
| 2 | + |
| 3 | +Push-Location $PSScriptRoot |
| 4 | + |
| 5 | +if(Test-Path .\artifacts) { |
| 6 | + echo "build: Cleaning .\artifacts" |
| 7 | + Remove-Item .\artifacts -Force -Recurse |
| 8 | +} |
| 9 | + |
| 10 | +& dotnet restore --no-cache |
| 11 | + |
| 12 | +$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; |
| 13 | +$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
| 14 | +$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] |
| 15 | + |
| 16 | +echo "build: Version suffix is $suffix" |
| 17 | + |
| 18 | +foreach ($src in ls src/*) { |
| 19 | + Push-Location $src |
| 20 | + |
| 21 | + echo "build: Packaging project in $src" |
| 22 | + |
| 23 | + & dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix |
| 24 | + if($LASTEXITCODE -ne 0) { exit 1 } |
| 25 | + |
| 26 | + Pop-Location |
| 27 | +} |
| 28 | + |
| 29 | + |
| 30 | +Pop-Location |
| 31 | + |
| 32 | + |
0 commit comments