diff --git a/build.ps1 b/build.ps1 index 9f0c4bd..85d1599 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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' } @@ -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 } @@ -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 { @@ -155,7 +158,12 @@ 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) { @@ -163,16 +171,17 @@ if(-Not $SkipToolPackageRestore.IsPresent) { 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." @@ -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 } @@ -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 } @@ -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 } @@ -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" } @@ -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 \ No newline at end of file diff --git a/build.settings.json b/build.settings.json index bcfa667..8f8070f 100644 --- a/build.settings.json +++ b/build.settings.json @@ -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", diff --git a/build.version.json b/build.version.json index 0f9799f..d539b47 100644 --- a/build.version.json +++ b/build.version.json @@ -1 +1 @@ -{"major":1,"minor":1,"build":10,"preRelease":1,"releaseNotes":["Added support for .NET Core"]} \ No newline at end of file +{"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} \ No newline at end of file diff --git a/tools/nuget.exe b/tools/nuget.exe index 7d8aeb3..4cbab24 100644 Binary files a/tools/nuget.exe and b/tools/nuget.exe differ diff --git a/tools/settingsUtils.cake b/tools/settingsUtils.cake index 07137b7..3243176 100644 --- a/tools/settingsUtils.cake +++ b/tools/settingsUtils.cake @@ -75,6 +75,11 @@ public class SettingsUtils obj.NuGet.PublishType = context.Argument("PublishType", obj.NuGet.PublishType); obj.NuGet.FeedUrl = context.Argument("nugetFeed", obj.NuGet.FeedUrl); obj.NuGet.FeedUrl = context.Argument("nugetFeedUrl", obj.NuGet.FeedUrl); + obj.NuGet.ArtifactsPath = context.Argument("Artifacts", obj.NuGet.ArtifactsPath); + obj.NuGet.ArtifactsPath = context.Argument("ArtifactsPath", obj.NuGet.ArtifactsPath); + obj.NuGet.NuSpecPath = context.Argument("NuSpec", obj.NuGet.NuSpecPath); + obj.NuGet.NuSpecPath = context.Argument("NuSpecPath", obj.NuGet.NuSpecPath); + obj.NuGet.NuGetConfig = context.Argument("NuGetConfig", obj.NuGet.NuGetConfig); obj.NuGet.FeedApiKey = context.Argument("nugetApiKey", obj.NuGet.FeedApiKey); @@ -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) { @@ -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); } }