Skip to content

Commit

Permalink
Change build script to opt-in to WRC
Browse files Browse the repository at this point in the history
  • Loading branch information
angularsen committed Feb 12, 2019
1 parent e3d356a commit 9982831
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
23 changes: 17 additions & 6 deletions Build/build-functions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if ($msbuild) {

function Remove-ArtifactsDir {
write-host -foreground blue "Clean up...`n"
rm $artifactsDir -Recurse -ErrorAction Ignore
rm $artifactsDir -Recurse -Force -ErrorAction Stop
write-host -foreground blue "Clean up...END`n"
}

Expand All @@ -23,10 +23,17 @@ function Update-GeneratedCode {
& "$root\UnitsNet\Scripts\GenerateUnits.ps1"
if ($lastexitcode -ne 0) { exit 1 }

if (-not $IncludeWindowsRuntimeComponent) {
write-host -foreground yellow "Skipping WindowsRuntimeComponent code regen."
} else {
& "$root\UnitsNet.WindowsRuntimeComponent\Scripts\GenerateUnits.ps1"
if ($lastexitcode -ne 0) { exit 1 }
}

write-host -foreground blue "Generate code...END`n"
}

function Start-Build([boolean] $skipUWP = $false) {
function Start-Build([boolean] $IncludeWindowsRuntimeComponent = $false) {
write-host -foreground blue "Start-Build...`n---"

$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.msbuild.log"
Expand All @@ -38,9 +45,9 @@ function Start-Build([boolean] $skipUWP = $false) {
dotnet build --configuration Release "$root\UnitsNet.sln" $fileLoggerArg $appVeyorLoggerArg
if ($lastexitcode -ne 0) { exit 1 }

if ($skipUWP -eq $true)
if (-not $IncludeWindowsRuntimeComponent)
{
write-host -foreground yellow "Skipping WindowsRuntimeComponent build by user-specified flag."
write-host -foreground yellow "Skipping WindowsRuntimeComponent build."
}
else
{
Expand Down Expand Up @@ -98,8 +105,12 @@ function Start-PackNugets {
if ($lastexitcode -ne 0) { exit 1 }
}

write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead"
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
if (-not $IncludeWindowsRuntimeComponent) {
write-host -foreground yellow "Skipping WindowsRuntimeComponent nuget pack."
} else {
write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead"
& $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir"
}

write-host -foreground blue "Pack nugets...END`n"
}
Expand Down
4 changes: 2 additions & 2 deletions Build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#>
[CmdletBinding()]
Param(
[switch] $skipUWP
[switch] $IncludeWindowsRuntimeComponent
)

remove-module build-functions -ErrorAction SilentlyContinue
Expand All @@ -29,7 +29,7 @@ import-module $PSScriptRoot\build-functions.psm1
try {
Remove-ArtifactsDir
Update-GeneratedCode
Start-Build $skipUWP
Start-Build -IncludeWindowsRuntimeComponent $IncludeWindowsRuntimeComponent
Start-Tests
Start-PackNugets
Compress-ArtifactsAsZip
Expand Down
2 changes: 1 addition & 1 deletion build-skip-uwp.bat → build-with-wrc.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
powershell -ExecutionPolicy Bypass -NoProfile -File %~dp0\Build\build.ps1 -skipUWP
powershell -ExecutionPolicy Bypass -NoProfile -File %~dp0\Build\build.ps1 -IncludeWindowsRuntimeComponent

0 comments on commit 9982831

Please sign in to comment.