1
- $root = " $PSScriptRoot \.."
1
+ $root = " $PSScriptRoot \.."
2
2
$artifactsDir = " $root \Artifacts"
3
3
$nugetOutDir = " $root \Artifacts\NuGet"
4
4
$testReportDir = " $root \Artifacts\Logs"
5
5
$nuget = " $root \Tools\NuGet.exe"
6
-
7
- function Start-NugetRestore {
8
- write-host - foreground blue " Restore nugets...`n "
9
- dotnet restore " $root \UnitsNet.sln"
10
-
11
- # This project type is not supported by dotnet CLI yet
12
- & $nuget restore " $root \UnitsNet.WindowsRuntimeComponent.sln"
13
- write-host - foreground blue " Restore nugets...END`n "
6
+ $vswhere = " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe"
7
+ $msbuild = & $vswhere - latest - products * - requires Microsoft.Component.MSBuild - property installationPath
8
+ if ($msbuild ) {
9
+ $msbuild = join-path $msbuild ' MSBuild\15.0\Bin\MSBuild.exe'
14
10
}
15
11
16
12
function Remove-ArtifactsDir {
@@ -30,28 +26,47 @@ function Update-GeneratedCode {
30
26
write-host - foreground blue " Generate code...END`n "
31
27
}
32
28
33
- function Start-Build {
29
+ function Start-Build ([ boolean ] $skipUWP = $false ) {
34
30
write-host - foreground blue " Start-Build...`n ---"
35
- dotnet build -- configuration Release " $root \UnitsNet.sln"
36
- if ($lastexitcode -ne 0 ) { exit 1 }
37
31
38
- # dontnet CLI does not support WindowsRuntimeComponent project type yet
39
- write-host - foreground yellow " WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead"
40
- & msbuild " $root \UnitsNet.WindowsRuntimeComponent.sln" / verbosity:minimal / p:Configuration= Release
32
+ $fileLoggerArg = " /logger:FileLogger,Microsoft.Build;logfile=$testReportDir \UnitsNet.msbuild.log"
33
+
34
+ $appVeyorLoggerDll = " C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
35
+ $appVeyorLoggerNetCoreDll = " C:\Program Files\AppVeyor\BuildAgent\dotnetcore\Appveyor.MSBuildLogger.dll"
36
+ $appVeyorLoggerArg = if (Test-Path " $appVeyorLoggerNetCoreDll " ) { " /logger:$appVeyorLoggerNetCoreDll " } else { " " }
37
+
38
+ dotnet build -- configuration Release " $root \UnitsNet.sln" $fileLoggerArg $appVeyorLoggerArg
41
39
if ($lastexitcode -ne 0 ) { exit 1 }
42
40
41
+ if ($skipUWP -eq $true )
42
+ {
43
+ write-host - foreground yellow " Skipping WindowsRuntimeComponent build by user-specified flag."
44
+ }
45
+ else
46
+ {
47
+ $fileLoggerArg = " /logger:FileLogger,Microsoft.Build;logfile=$testReportDir \UnitsNet.WindowsRuntimeComponent.msbuild.log"
48
+ $appVeyorLoggerArg = if (Test-Path " $appVeyorLoggerDll " ) { " /logger:$appVeyorLoggerDll " } else { " " }
49
+
50
+ # dontnet CLI does not support WindowsRuntimeComponent project type yet
51
+ # msbuild does not auto-restore nugets for this project type
52
+ write-host - foreground yellow " WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead"
53
+ & " $msbuild " " $root \UnitsNet.WindowsRuntimeComponent.sln" / verbosity:minimal / p:Configuration= Release / t:restore
54
+ & " $msbuild " " $root \UnitsNet.WindowsRuntimeComponent.sln" / verbosity:minimal / p:Configuration= Release $fileLoggerArg $appVeyorLoggerArg
55
+ if ($lastexitcode -ne 0 ) { exit 1 }
56
+ }
57
+
43
58
write-host - foreground blue " Start-Build...END`n "
44
59
}
45
60
46
61
function Start-Tests {
47
62
$projectPaths = @ (
48
63
" UnitsNet.Tests\UnitsNet.Tests.NetCore.csproj" ,
49
- " UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.NetCore.csproj"
50
- " UnitsNet.Tests.WindowsRuntimeComponent \UnitsNet.Tests.WindowsRuntimeComponent .csproj"
64
+ " UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.NetCore.csproj" ,
65
+ " UnitsNet.Serialization.JsonNet.CompatibilityTests \UnitsNet.Serialization.JsonNet.CompatibilityTests.NetCore .csproj"
51
66
)
52
67
53
68
# Parent dir must exist before xunit tries to write files to it
54
- new-item - type directory $testReportDir 1> $null
69
+ new-item - type directory - force $testReportDir 1> $null
55
70
56
71
write-host - foreground blue " Run tests...`n ---"
57
72
foreach ($projectPath in $projectPaths ) {
@@ -63,7 +78,7 @@ function Start-Tests {
63
78
# https://github.com/xunit/xunit/issues/1216
64
79
push-location $projectDir
65
80
# -nobuild <-- this gives an error, but might want to use this to avoid extra builds
66
- dotnet xunit - configuration Release - framework netcoreapp1. 1 - xml $reportFile - nobuild
81
+ dotnet xunit - configuration Release - framework netcoreapp2. 0 - xml $reportFile - nobuild
67
82
if ($lastexitcode -ne 0 ) { exit 1 }
68
83
pop-location
69
84
}
@@ -73,19 +88,18 @@ function Start-Tests {
73
88
74
89
function Start-PackNugets {
75
90
$projectPaths = @ (
76
- " UnitsNet\UnitsNet.NetStandard10.csproj" ,
77
- " UnitsNet\UnitsNet.NetStandard10.Signed.csproj" ,
78
- " UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj" ,
79
- " UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.Signed.csproj"
91
+ " UnitsNet\UnitsNet.csproj" ,
92
+ " UnitsNet.Serialization.JsonNet\UnitsNet.Serialization.JsonNet.csproj"
80
93
)
81
94
82
95
write-host - foreground blue " Pack nugets...`n ---"
83
96
foreach ($projectPath in $projectPaths ) {
84
97
dotnet pack -- configuration Release - o $nugetOutDir " $root \$projectPath "
85
98
if ($lastexitcode -ne 0 ) { exit 1 }
86
99
}
87
- write-host - foreground yellow " WindowsRuntimeComponent project not yet supported by dotnet CLI, using NuGex.exe instead"
88
- & $nuget pack " $root \UnitsNet\UnitsNet.WindowsRuntimeComponent.nuspec" - Verbosity detailed - OutputDirectory " $nugetOutDir " - Symbols
100
+
101
+ write-host - foreground yellow " WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead"
102
+ & $nuget pack " $root \UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" - Verbosity detailed - OutputDirectory " $nugetOutDir "
89
103
90
104
write-host - foreground blue " Pack nugets...END`n "
91
105
}
@@ -110,4 +124,4 @@ function Compress-ArtifactsAsZip {
110
124
write-host - foreground blue " Zip artifacts...END`n "
111
125
}
112
126
113
- export-modulemember - function Start-NugetRestore , Remove-ArtifactsDir , Update-GeneratedCode , Start-Build , Start-SignedBuild , Start-Tests , Start-PackNugets , Compress-ArtifactsAsZip
127
+ export-modulemember - function Start-NugetRestore , Remove-ArtifactsDir , Update-GeneratedCode , Start-Build , Start-SignedBuild , Start-Tests , Start-PackNugets , Compress-ArtifactsAsZip
0 commit comments