Skip to content

Commit

Permalink
Updated build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ravensorb committed Jan 6, 2020
1 parent 9d051df commit b5e891a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 27 deletions.
56 changes: 35 additions & 21 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ try {
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
# installed (.NET 4.5 is an in-place upgrade).
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
if (-not $IsCoreCLR) {
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
}
} catch {
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
}
Expand Down Expand Up @@ -93,7 +96,7 @@ function GetProxyEnabledWebClient
{
$wc = New-Object System.Net.WebClient
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$wc.Proxy = $proxy
return $wc
}
Expand All @@ -118,13 +121,13 @@ $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
# Make sure tools folder exists
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
Write-Verbose -Message "Creating tools directory..."
New-Item -Path $TOOLS_DIR -Type directory | out-null
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
}

# Make sure that packages.config exist.
if (!(Test-Path $PACKAGES_CONFIG)) {
Write-Verbose -Message "Downloading packages.config..."
try {
Write-Verbose -Message "Downloading packages.config..."
try {
$wc = GetProxyEnabledWebClient
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG)
} catch {
Expand Down Expand Up @@ -155,24 +158,30 @@ if (!(Test-Path $NUGET_EXE)) {
}

# Save nuget.exe path to environment to be available to child processed
$ENV:NUGET_EXE = $NUGET_EXE
$env:NUGET_EXE = $NUGET_EXE
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
"mono `"$NUGET_EXE`""
} else {
"`"$NUGET_EXE`""
}

# Restore tools from NuGet?
if(-Not $SkipToolPackageRestore.IsPresent) {
Push-Location
Set-Location $TOOLS_DIR

# Check for changes in packages.config and remove installed tools if true.
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
Write-Verbose -Message "Missing or changed package.config hash..."
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery,settingsUtils.cake,versionUtils.cake,CredentialProvider.VSS.exe,VSS.NuGet.AuthHelper.exe |
Remove-Item -Recurse
Remove-Item -Recurse -Force
}

Write-Verbose -Message "Restoring tools from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""

$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet tools."
Expand All @@ -181,7 +190,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
{
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
}
Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
Expand All @@ -192,13 +201,13 @@ if (Test-Path $ADDINS_PACKAGES_CONFIG) {
Set-Location $ADDINS_DIR

Write-Verbose -Message "Restoring addins from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet addins."
}

Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
Expand All @@ -209,13 +218,13 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) {
Set-Location $MODULES_DIR

Write-Verbose -Message "Restoring modules from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet modules."
}

Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)

Pop-Location
}
Expand All @@ -225,11 +234,16 @@ if (!(Test-Path $CAKE_EXE)) {
Throw "Could not find Cake.exe at $CAKE_EXE"
}

$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
"mono `"$CAKE_EXE`""
} else {
"`"$CAKE_EXE`""
}


# Build Cake arguments
$cakeArguments = @("$Script");
if ($Target) { $cakeArguments += "-target=$Target" }
# Build an array (not a string) of Cake arguments to be joined later
$cakeArguments = @()
if ($Script) { $cakeArguments += "`"$Script`"" }
if ($Target) { $cakeArguments += "-target=`"$Target`"" }
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
if ($ShowDescription) { $cakeArguments += "-showdescription" }
Expand All @@ -238,5 +252,5 @@ $cakeArguments += $ScriptArgs

# Start Cake
Write-Host "Running build script..."
&$CAKE_EXE $cakeArguments
exit $LASTEXITCODE
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
exit $LASTEXITCODE
7 changes: 3 additions & 4 deletions build.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
},
"test": {
"SourcePath": "./tests",
"ResultsPath": "./artifacts",
"AssemblyFileSpec": "*.UnitTests.dll",
"Framework": "NUnit3"
"ResultsPath": "./artifacts/tests",
"FileSpec": "*.csproj",
"Framework": "DotNetCore"
},
"nuget": {
"BuildType": "dotnetcore",
"NuGetConfig": "./src/.nuget/NuGet.config",
"FeedUrl": "https://api.nuget.org/v3/index.json",
"FeedAPIKey": "NUGETAPIKEY",
"ArtifactsPath": "./artifacts/packages",
Expand Down
2 changes: 1 addition & 1 deletion build.version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"major":1,"minor":1,"build":10,"preRelease":1,"releaseNotes":["Added support for .NET Core"]}
{"Major":1,"Minor":1,"Build":10,"PreRelease":1,"ReleaseNotes":["Added support for .NET Core"],"Semantic":null,"Milestone":null,"CakeVersion":"0.33.0.0","IsPreRelease":true}
Binary file modified tools/nuget.exe
Binary file not shown.
12 changes: 11 additions & 1 deletion tools/settingsUtils.cake
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public class SettingsUtils
obj.NuGet.PublishType = context.Argument<string>("PublishType", obj.NuGet.PublishType);
obj.NuGet.FeedUrl = context.Argument<string>("nugetFeed", obj.NuGet.FeedUrl);
obj.NuGet.FeedUrl = context.Argument<string>("nugetFeedUrl", obj.NuGet.FeedUrl);
obj.NuGet.ArtifactsPath = context.Argument<string>("Artifacts", obj.NuGet.ArtifactsPath);
obj.NuGet.ArtifactsPath = context.Argument<string>("ArtifactsPath", obj.NuGet.ArtifactsPath);
obj.NuGet.NuSpecPath = context.Argument<string>("NuSpec", obj.NuGet.NuSpecPath);
obj.NuGet.NuSpecPath = context.Argument<string>("NuSpecPath", obj.NuGet.NuSpecPath);
obj.NuGet.NuGetConfig = context.Argument<string>("NuGetConfig", obj.NuGet.NuGetConfig);

obj.NuGet.FeedApiKey = context.Argument<string>("nugetApiKey", obj.NuGet.FeedApiKey);

Expand Down Expand Up @@ -105,6 +110,11 @@ public class SettingsUtils

return settingsPath;
}

private static string ExpandEnvironmentVariables(ICakeContext context, string variableName, string defaultValue)
{
return null;
}

public static void DisplayHelp(ICakeContext context)
{
Expand Down Expand Up @@ -303,7 +313,7 @@ public class TestSettings
context.Information("Test Settings:");
context.Information("\tSource Path: {0}", SourcePath);
context.Information("\tResults Path: {0}", ResultsPath);
context.Information("\tTest Assemploes File Spec: {0}", FileSpec);
context.Information("\tTest File Spec: {0}", FileSpec);
}
}

Expand Down

0 comments on commit b5e891a

Please sign in to comment.