Skip to content

Commit

Permalink
Add a wrapper script for the CI to use
Browse files Browse the repository at this point in the history
ILDasm and ILAsm must be invoked from a VS Developer Command Prompt, or
they will silently fail. CI will call build.cmd in order to set the
appropriate environment before executing the build. Locally, you must
either call build.cmd yourself, or use a developer command prompt.
build.ps1 is not intended to be called directly, but can be if you ensure
that the correct environment variables are set (i.e. from a VS Developer
Command Prompt). Even then, you should just call build.cmd to be safe.
  • Loading branch information
mellinoe committed Apr 27, 2016
1 parent a4837f7 commit a5c5c1d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
17 changes: 17 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@echo off
setlocal

:: Invoke VS Developer Command Prompt batch file.
:: This sets up some environment variables needed to use ILDasm and ILAsm.
if not defined VisualStudioVersion (
if defined VS140COMNTOOLS (
call "%VS140COMNTOOLS%\VsDevCmd.bat"
goto :Build
)

echo Error: cibuild.cmd requires Visual Studio 2015.
exit /b 1
)

:Build
powershell -NoProfile %~dp0scripts\build.ps1 %*
2 changes: 1 addition & 1 deletion netci.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def branch = GithubBranchName
def newJobName = Utilities.getFullJobName(project, configuration, isPR)

// Define build string
def buildString = """call powershell -NoProfile ./build.ps1 -Configuration ${configuration}"""
def buildString = """call build.cmd ${configuration}"""

// Create a new job with the specified name. The brace opens a new closure
// and calls made within that closure apply to the newly created job.
Expand Down
22 changes: 12 additions & 10 deletions build.ps1 → scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,28 @@ Write-Host "Commencing full build for Configuration=$Configuration."

if (!(Test-Path "dotnet\dotnet.exe")) {
Write-Host "dotnet.exe not installed, downloading and installing."
.\install-dotnet.ps1
Invoke-Expression -Command "$PSScriptRoot\install-dotnet.ps1 -InstallDir $PSScriptRoot\..\dotnet"
if (!$?) {
Write-Error "Failed to install dotnet.exe, aborting build."
exit -1
}
}

$dotnetExePath="$PSScriptRoot\..\dotnet\dotnet.exe"

Write-Host "Restoring all packages"
.\dotnet\dotnet.exe restore src tests
if (!$?) {
Write-Error "Failed to restore packages."
exit -1
}
Invoke-Expression "$dotnetExePath restore src tests"
if (!$?) {
Write-Error "Failed to restore packages."
exit -1
}

$errorsEncountered = 0
$projectsFailed = New-Object System.Collections.Generic.List[String]

foreach ($file in [System.IO.Directory]::EnumerateFiles(".\src", "project.json", "AllDirectories")) {
foreach ($file in [System.IO.Directory]::EnumerateFiles("$PSScriptRoot\..\src", "project.json", "AllDirectories")) {
Write-Host "Building $file..."
.\dotnet\dotnet.exe build $file -c $Configuration
Invoke-Expression "$dotnetExePath build $file -c $Configuration"

if (!$?) {
Write-Error "Failed to build project $file"
Expand All @@ -34,9 +36,9 @@ foreach ($file in [System.IO.Directory]::EnumerateFiles(".\src", "project.json",
}
}

foreach ($file in [System.IO.Directory]::EnumerateFiles(".\tests", "project.json", "AllDirectories")) {
foreach ($file in [System.IO.Directory]::EnumerateFiles("$PSScriptRoot\..\tests", "project.json", "AllDirectories")) {
Write-Host "Building and running tests for project $file..."
.\dotnet\dotnet.exe test $file -c $Configuration -notrait category=performance -notrait category=outerloop
Invoke-Expression "$dotnetExePath test $file -c $Configuration -notrait category=performance -notrait category=outerloop"

if (!$?) {
Write-Error "Some tests failed in project $file"
Expand Down
File renamed without changes.

0 comments on commit a5c5c1d

Please sign in to comment.