Created
November 30, 2016 17:50
-
-
Save galvesribeiro/68a4d39fb2228828382510bf787aa024 to your computer and use it in GitHub Desktop.
Partial Build.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
$OSPlatform = [System.Runtime.InteropServices.OSPlatform] | |
$IsLinux = $Runtime::IsOSPlatform($OSPlatform::Linux) | |
$IsOSX = $Runtime::IsOSPlatform($OSPlatform::OSX) | |
$IsWindows = $Runtime::IsOSPlatform($OSPlatform::Windows) | |
} catch { | |
# If these are already set, then they're read-only and we're done | |
try { | |
$IsLinux = $false | |
$IsOSX = $false | |
$IsWindows = $true | |
} | |
catch { } | |
} | |
$WORKDIR = (Get-Location).Path | |
function LoadVersionFile([string]$filePath) | |
{ | |
$VERSIONFILE = $filePath | |
if(Test-Path $VERSIONFILE) | |
{ | |
Write-Host "Using version number from file $VERSIONFILE" | |
$PRODUCTVERSION = Get-Content $VERSIONFILE -ErrorAction SilentlyContinue | Select-String '^(\d+\.)?(\d+\.)?(\*|\d+)$' | |
} | |
else | |
{ | |
Write-Warning "ERROR: Unable to read version number from file $VERSIONFILE" | |
$PRODUCTVERSION = "1.0" | |
} | |
Write-Host "PRODUCT VERSION $PRODUCTVERSION" | |
} | |
function NETFXBuild([string]$configuration) | |
{ | |
LoadVersionFile $WORKDIR\src\Build\Version.txt | |
if($IsWindows -eq $false) | |
{ | |
Write-Error "Unable to build Orleans Full CLR on non-Windows systems" | |
exit | |
} | |
if($MSBUILDEXE -eq "" -or (Test-Path $MSBUILDEXE) -eq $false) | |
{ | |
Write-Error "Could not find MSBuild in the system. Cannot continue." | |
exit | |
} | |
Write-Host "MSBuild Location = " $MSBUILDEXE | |
$PROJECT = "$WORKDIR\src\Orleans.sln" | |
Write-Host "===== Building $PROJECT =====" | |
Write-Host "Build $configuration ==============================" | |
$buildRoot = "$WORKDIR\src" | |
$env:OutDir = "$WORKDIR\Binaries\$configuration" | |
$buildParams = @("/nr:False", "/m", "/p:Configuration=$configuration", "$buildRoot\Orleans.sln") | |
#$buildProcess = Start-Process -FilePath $MSBUILDEXE -WorkingDirectory $buildRoot -ArgumentList $buildParams -NoNewWindow -Wait | |
Invoke-Expression "&`"$MSBUILDEXE`" $buildParams" | |
if($LASTEXITCODE -ne 0) | |
{ | |
Write-Error "Failure building $PROJECT with configuration $configuration" | |
exit | |
} | |
else | |
{ | |
Write-Host "Successfuly built $PROJECT with configuration $configuration" | |
} | |
} | |
function VNEXTBuild() | |
{ | |
Write-Host "VNEXT" | |
return 0 | |
} | |
function ALLBuild() | |
{ | |
NETFXBuild | |
VNEXTBuild | |
return 0 | |
} | |
# If we are on Windows, we need to set Visual Studio env variables | |
# and MSBuild since we will build .Net full CLR assemblies | |
if($IsWindows) | |
{ | |
$vsdevCMD = ${env:VS140COMNTOOLS} + "\vsvars32.bat" | |
if($env:VisualStudioVersion -eq "") | |
{ | |
Write-Error "Could not determine Visual Studio version in the system. Cannot continue." | |
exit | |
} | |
Write-Host "VisualStudioVersion =" $env:VisualStudioVersion | |
if(Test-Path ${env:ProgramFiles}\MSBuild\14.0\bin) | |
{ | |
$MSBUILDEXE = ${env:ProgramFiles} + "\MSBuild\14.0\bin\MSBuild.exe" | |
} | |
if(Test-Path ${env:ProgramFiles(x86)}\MSBuild\14.0\bin) | |
{ | |
$MSBUILDEXE = ${env:ProgramFiles(x86)} + "\MSBuild\14.0\bin\MSBuild.exe" | |
} | |
} | |
$buildType = [string]$args[0] | |
if($buildType -eq "" -or $buildType -eq "NETFX") | |
{ | |
NETFXBuild "Debug" | |
#NETFXBuild "Release" | |
} | |
if($buildType -eq "" -or $buildType -eq "netstandard") | |
{ | |
return VNEXTBuild | |
} | |
if($buildType -eq "" -or $buildType -eq "all") | |
{ | |
return ALLBuild | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment