Skip to content

Commit

Permalink
Merge pull request #996 from martincostello/xplat-ci
Browse files Browse the repository at this point in the history
Build on Linux and macOS
  • Loading branch information
martincostello committed Jan 6, 2023
2 parents d3c4e1d + 18528b8 commit 977f3e1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 60 deletions.
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"commands": [
"dotnet-cake"
]
},
"GitVersion.Tool": {
"version": "5.11.1",
"commands": [
"dotnet-gitversion"
]
}
}
}
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
matrix:
os: [ windows-latest ]
include:
#- os: macos-latest
# os_name: macos
#- os: ubuntu-latest
# os_name: linux
- os: macos-latest
os_name: macos
- os: ubuntu-latest
os_name: linux
- os: windows-latest
os_name: windows

Expand Down
6 changes: 3 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var configuration = Argument<string>("configuration", "Release");
// EXTERNAL NUGET TOOLS
//////////////////////////////////////////////////////////////////////

#Tool "GitVersion.CommandLine&version=5.11.1"
#Tool "xunit.runner.console&version=2.4.2"

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -113,12 +112,13 @@ Task("__UpdateAssemblyVersionInformation")
.Does(() =>
{
var gitVersionSettings = new ProcessSettings()
.SetRedirectStandardOutput(true);
.SetRedirectStandardOutput(true)
.WithArguments(args => args.Append("gitversion"));
try
{
IEnumerable<string> outputLines;
StartProcess(gitVersionPath, gitVersionSettings, out outputLines);
StartProcess("dotnet", gitVersionSettings, out outputLines);
var output = string.Join("\n", outputLines);
gitVersionOutput = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(output);
Expand Down
58 changes: 6 additions & 52 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<#
.SYNOPSIS
This is a Powershell script to bootstrap a Cake build.
This is a PowerShell script to bootstrap a Cake build.
.DESCRIPTION
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
This PowerShell script will restore NuGet tools (including Cake)
and execute your Cake build script with the parameters you provide.
.PARAMETER Script
Expand All @@ -16,13 +16,9 @@ The build script target to run.
The build configuration to use.
.PARAMETER Verbosity
Specifies the amount of information to be displayed.
.PARAMETER Experimental
Tells Cake to use the latest Roslyn release.
.PARAMETER WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.PARAMETER Mono
Tells Cake to use the Mono scripting engine.
.LINK
http://cakebuild.net
Expand All @@ -34,10 +30,8 @@ Param(
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
[switch]$Experimental,
[Alias("DryRun","Noop")]
[switch]$WhatIf,
[switch]$Mono,
[switch]$SkipToolPackageRestore,
[switch]$Verbose
)
Expand All @@ -54,23 +48,6 @@ if ($Verbose.IsPresent)
}

$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
$DOTNET = "dotnet.exe"

# Should we use mono?
$UseMono = "";
if ($Mono.IsPresent) {
Write-Verbose -Message "Using the Mono based scripting engine."
$UseMono = "-mono"
}

# Should we use the new Roslyn?
$UseExperimental = "";
if ($Experimental.IsPresent -and !($Mono.IsPresent)) {
Write-Verbose -Message "Using experimental version of Roslyn."
$UseExperimental = "-experimental"
}

# Is this a dry run?
$UseDryRun = "";
Expand All @@ -83,20 +60,6 @@ if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
New-Item -Path $TOOLS_DIR -Type directory | out-null
}

# Try download NuGet.exe if not exists
if (!(Test-Path $NUGET_EXE)) {
Write-Verbose -Message "Downloading NuGet.exe..."
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $NUGET_EXE
}

# Make sure NuGet exists where we expect it.
if (!(Test-Path $NUGET_EXE)) {
Throw "Could not find NuGet.exe"
}

# Save nuget.exe path to environment to be available to child processed
$ENV:NUGET_EXE = $NUGET_EXE

# Restore tools from NuGet?
if (-Not $SkipToolPackageRestore.IsPresent)
{
Expand All @@ -106,18 +69,9 @@ if (-Not $SkipToolPackageRestore.IsPresent)

Write-Verbose -Message "Restoring tools from NuGet..."

# Restore packages
if (Test-Path $PACKAGES_CONFIG)
{
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion"
Write-Verbose ($NuGetOutput | Out-String)
}
# Install just Cake if missing config
else
{
$NuGetOutput = Invoke-Expression "&`"$DOTNET`" tool install Cake.Tool --version 3.0.0"
Write-Verbose ($NuGetOutput | Out-String)
}
$NuGetOutput = Invoke-Expression "& dotnet tool restore"
Write-Verbose ($NuGetOutput | Out-String)

Pop-Location
if ($LASTEXITCODE -ne 0)
{
Expand All @@ -127,5 +81,5 @@ if (-Not $SkipToolPackageRestore.IsPresent)

# Start Cake
Write-Host "Running build script..."
Invoke-Expression "dotnet dotnet-cake `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental"
Invoke-Expression "dotnet dotnet-cake `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseDryRun"
exit $LASTEXITCODE
2 changes: 1 addition & 1 deletion src/Polly.Specs/Polly.Specs.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(TargetFrameworks);net472</TargetFrameworks>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
Expand Down

0 comments on commit 977f3e1

Please sign in to comment.