1- $root = $ (Get-Item $ ($MyInvocation.MyCommand.Path )).DirectoryName
2-
3- function Install-Dnvm
4- {
5- & where.exe dnvm 2>&1 | Out-Null
6- if (($LASTEXITCODE -ne 0 ) -Or ((Test-Path Env:\APPVEYOR) -eq $true ))
7- {
8- Write-Host " DNVM not found"
9- & {$Branch = ' dev' ;iex ((New-Object net.webclient).DownloadString(' https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1' ))}
10-
11- # Normally this happens automatically during install but AppVeyor has
12- # an issue where you may need to manually re-run setup from within this process.
13- if ($env: DNX_HOME -eq $NULL )
14- {
15- Write-Host " Initial DNVM environment setup failed; running manual setup"
16- $tempDnvmPath = Join-Path $env: TEMP " dnvminstall"
17- $dnvmSetupCmdPath = Join-Path $tempDnvmPath " dnvm.ps1"
18- & $dnvmSetupCmdPath setup
19- }
20- }
21- }
22-
23- function Get-DnxVersion
24- {
25- $globalJson = Join-Path $PSScriptRoot " global.json"
26- $jsonData = Get-Content - Path $globalJson - Raw | ConvertFrom-JSON
27- return $jsonData.sdk.version
28- }
29-
30- function Restore-Packages
31- {
32- param ([string ] $DirectoryName )
33- & dnu restore (" "" " + $DirectoryName + " "" " )
34- }
35-
36- function Build-Projects
37- {
38- param ($Directory , $pack )
39-
40- $DirectoryName = $Directory.DirectoryName
41- $artifactsFolder = join-path $root " artifacts"
42- $projectsFolder = join-path $artifactsFolder $Directory.Name
43- $buildFolder = join-path $projectsFolder " testbin"
44- $packageFolder = join-path $projectsFolder " packages"
45-
46- & dnu build (" "" " + $DirectoryName + " "" " ) -- configuration Release -- out $buildFolder ; if ($LASTEXITCODE -ne 0 ) { exit 1 }
47-
48- if ($pack ){
49- & dnu pack (" "" " + $DirectoryName + " "" " ) -- configuration Release -- out $packageFolder ; if ($LASTEXITCODE -ne 0 ) { exit 1 }
50- }
51- }
52-
53- function Test-Projects
54- {
55- param ([string ] $DirectoryName )
56- & dnx - p (" "" " + $DirectoryName + " "" " ) test; if ($LASTEXITCODE -ne 0 ) { exit 2 }
57- }
58-
59- function Remove-PathVariable
60- {
61- param ([string ] $VariableToRemove )
62- $path = [Environment ]::GetEnvironmentVariable(" PATH" , " User" )
63- $newItems = $path.Split (' ;' ) | Where-Object { $_.ToString () -inotlike $VariableToRemove }
64- [Environment ]::SetEnvironmentVariable(" PATH" , [System.String ]::Join(' ;' , $newItems ), " User" )
65- $path = [Environment ]::GetEnvironmentVariable(" PATH" , " Process" )
66- $newItems = $path.Split (' ;' ) | Where-Object { $_.ToString () -inotlike $VariableToRemove }
67- [Environment ]::SetEnvironmentVariable(" PATH" , [System.String ]::Join(' ;' , $newItems ), " Process" )
68- }
69-
701Push-Location $PSScriptRoot
712
72- $dnxVersion = Get-DnxVersion
73-
74- # Clean
753if (Test-Path .\artifacts) { Remove-Item .\artifacts - Force - Recurse }
764
77- # Remove the installed DNVM from the path and force use of
78- # per-user DNVM (which we can upgrade as needed without admin permissions)
79- Remove-PathVariable " *Program Files\Microsoft DNX\DNVM*"
80-
81- # Make sure per-user DNVM is installed
82- Install-Dnvm
83-
84- # Install DNX
85- dnvm install $dnxVersion - r CoreCLR - NoNative
86- dnvm install $dnxVersion - r CLR - NoNative
87- dnvm use $dnxVersion - r CLR
88-
89- # Package restore
90- Get-ChildItem - Path . - Filter * .xproj - Recurse | ForEach-Object { Restore-Packages $_.DirectoryName }
91-
92- # Set build number
93- $env: DNX_BUILD_VERSION = @ { $true = $env: APPVEYOR_BUILD_NUMBER ; $false = 1 }[$env: APPVEYOR_BUILD_NUMBER -ne $NULL ];
94- Write-Host " Build number: " $env: DNX_BUILD_VERSION
95-
96- # Build/package
97- Get-ChildItem - Path .\src - Filter * .xproj - Recurse | ForEach-Object { Build-Projects $_ $true }
98- Get-ChildItem - Path .\test - Filter * .xproj - Recurse | ForEach-Object { Build-Projects $_ $false }
5+ & dotnet restore
996
100- # Test
101- Get-ChildItem - Path .\test - Filter * .xproj - Recurse | ForEach-Object { Test-Projects $_.DirectoryName }
7+ $revision = @ { $true = $env: APPVEYOR_BUILD_NUMBER ; $false = 1 }[$env: APPVEYOR_BUILD_NUMBER -ne $NULL ];
1028
103- # Switch to Core CLR
104- dnvm use $dnxVersion - r CoreCLR
9+ Push-Location src/ Serilog.Sinks.Console
10510
106- # Test again
107- Get-ChildItem - Path .\test - Filter * .xproj - Recurse | ForEach-Object { Test-Projects $_ .DirectoryName }
11+ & dotnet pack - c Release - o ..\..\.\artifacts -- version - suffix = $revision
12+ if ( $LASTEXITCODE -ne 0 ) { exit 1 }
10813
10914Pop-Location
15+ Pop-Location
0 commit comments