Skip to content

Commit

Permalink
Bump Cake to v2.0.0 (#921)
Browse files Browse the repository at this point in the history
* Bump up cake to v2.0.0

* Target the tools to a specific version
  • Loading branch information
eugeneogongo committed Feb 13, 2022
1 parent 98f7429 commit c36712e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
29 changes: 15 additions & 14 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ var configuration = Argument<string>("configuration", "Release");
// EXTERNAL NUGET TOOLS
//////////////////////////////////////////////////////////////////////

#Tool "xunit.runner.console"
#Tool "GitVersion.CommandLine"
#Tool "xunit.runner.console&version=2.4.1"
#Tool "GitVersion.CommandLine&version=5.8.1"

//////////////////////////////////////////////////////////////////////
// EXTERNAL NUGET LIBRARIES
//////////////////////////////////////////////////////////////////////

#addin nuget:?package=Cake.FileHelpers&version=3.3.0
#addin nuget:?package=Cake.Yaml&version=3.1.1
#addin nuget:?package=YamlDotNet&version=5.2.1
#addin nuget:?package=Cake.FileHelpers&version=5.0.0
#addin nuget:?package=Cake.Yaml&version=4.0.0
#addin nuget:?package=Newtonsoft.Json&version=13.0.1
#addin nuget:?package=YamlDotNet&version=11.2.1

///////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
Expand Down Expand Up @@ -94,7 +95,7 @@ Task("__Clean")
foreach(var path in solutionPaths)
{
Information("Cleaning {0}", path);
DotNetCoreClean(path.ToString());
DotNetClean(path.ToString());
}
});

Expand All @@ -104,7 +105,7 @@ Task("__RestoreNugetPackages")
foreach(var solution in solutions)
{
Information("Restoring NuGet Packages for {0}", solution);
DotNetCoreRestore(solution.ToString());
DotNetRestore(solution.ToString());
}
});

Expand Down Expand Up @@ -201,22 +202,22 @@ Task("__BuildSolutions")
{
Information("Building {0}", solution);
var dotNetCoreBuildSettings = new DotNetCoreBuildSettings {
var dotNetCoreBuildSettings = new DotNetBuildSettings {
Configuration = configuration,
Verbosity = DotNetCoreVerbosity.Minimal,
NoRestore = true,
MSBuildSettings = new DotNetCoreMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error }
MSBuildSettings = new DotNetMSBuildSettings { TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error }
};
DotNetCoreBuild(solution.ToString(), dotNetCoreBuildSettings);
DotNetBuild(solution.ToString(), dotNetCoreBuildSettings);
}
});

Task("__RunTests")
.Does(() =>
{
foreach(var specsProj in GetFiles("./src/**/*.Specs.csproj")) {
DotNetCoreTest(specsProj.FullPath, new DotNetCoreTestSettings {
DotNetTest(specsProj.FullPath, new DotNetTestSettings {
Configuration = configuration,
NoBuild = true
});
Expand All @@ -230,13 +231,13 @@ Task("__CreateSignedNugetPackage")
Information("Building {0}.{1}.nupkg", packageName, nugetVersion);
var dotNetCorePackSettings = new DotNetCorePackSettings {
var dotNetCorePackSettings = new DotNetPackSettings {
Configuration = configuration,
NoBuild = true,
OutputDirectory = nupkgDestDir
};
DotNetCorePack($@"{srcDir}\{projectName}.sln", dotNetCorePackSettings);
DotNetPack($@"{srcDir}\{projectName}.sln", dotNetCorePackSettings);
});

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -273,4 +274,4 @@ RunTarget(target);
string ToolsExePath(string exeFileName) {
var exePath = System.IO.Directory.GetFiles(@"./tools", exeFileName, SearchOption.AllDirectories).FirstOrDefault();
return exePath;
}
}
13 changes: 5 additions & 8 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ if($Verbose.IsPresent)

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

# Should we use mono?
$UseMono = "";
Expand Down Expand Up @@ -111,7 +112,7 @@ if(-Not $SkipToolPackageRestore.IsPresent)
# Install just Cake if missing config
else
{
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install Cake -Version 0.38.5 -ExcludeVersion" # Pin Cake version to 0.38.5; see https://github.com/App-vNext/Polly/issues/416
$NuGetOutput = Invoke-Expression "&`"$DOTNET`" tool install Cake.Tool --version 2.0.0"
Write-Verbose ($NuGetOutput | Out-String)
}
Pop-Location
Expand All @@ -121,12 +122,8 @@ if(-Not $SkipToolPackageRestore.IsPresent)
}
}

# Make sure that Cake has been installed.
if (!(Test-Path $CAKE_EXE)) {
Throw "Could not find Cake.exe"
}

# Start Cake
Write-Host "Running build script..."
Invoke-Expression "$CAKE_EXE `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental"
exit $LASTEXITCODE
Invoke-Expression "$CAKE_EXE `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental"
exit $LASTEXITCODE

0 comments on commit c36712e

Please sign in to comment.