Skip to content

Commit f76985c

Browse files
author
Henry Roeland
committed
(Trying to) Fix the build on Linux by upgrading to newest Cake version.
1 parent ace5feb commit f76985c

File tree

6 files changed

+44
-190
lines changed

6 files changed

+44
-190
lines changed

.config/dotnet-tools.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"cake.tool": {
6+
"version": "3.0.0",
7+
"commands": [
8+
"dotnet-cake"
9+
]
10+
}
11+
}
12+
}

build.cake

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
if ( isRunningOnWindows )
2-
{
3-
#tool nuget:?package=NuGet.CommandLine&version=5.9.1
4-
}
5-
61
var target = Argument("target", "Default");
72
var projectName = "AngleSharp";
83
var solutionName = "AngleSharp.Core";

build.ps1

+9-77
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,13 @@
1-
Param(
2-
[string]$Script = "build.cake",
3-
[string]$Target = "Default",
4-
[ValidateSet("Release", "Debug")]
5-
[string]$Configuration = "Release",
6-
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
7-
[string]$Verbosity = "Verbose",
8-
[switch]$Experimental,
9-
[switch]$WhatIf,
10-
[switch]$Mono,
11-
[switch]$SkipToolPackageRestore,
12-
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
13-
[string[]]$ScriptArgs
14-
)
1+
$ErrorActionPreference = 'Stop'
152

16-
$PSScriptRoot = split-path -parent $MyInvocation.MyCommand.Definition;
17-
$UseDryRun = "";
18-
$UseMono = "";
19-
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
20-
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
21-
$NUGET_OLD_EXE = Join-Path $TOOLS_DIR "nuget_old.exe"
22-
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
23-
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
24-
$NUGET_OLD_URL = "https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe"
3+
Set-Location -LiteralPath $PSScriptRoot
254

26-
# Should we use experimental build of Roslyn?
27-
$UseExperimental = "";
28-
if ($Experimental.IsPresent) {
29-
$UseExperimental = "--experimental"
30-
}
5+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
6+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
7+
$env:DOTNET_NOLOGO = '1'
318

32-
# Is this a dry run?
33-
if ($WhatIf.IsPresent) {
34-
$UseDryRun = "--dryrun"
35-
}
9+
dotnet tool restore
10+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
3611

37-
# Should we use mono?
38-
if ($Mono.IsPresent) {
39-
$UseMono = "--mono"
40-
}
41-
42-
# Try download NuGet.exe if do not exist.
43-
if (!(Test-Path $NUGET_EXE)) {
44-
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
45-
}
46-
47-
# Try download NuGet.exe if do not exist.
48-
if (!(Test-Path $NUGET_OLD_URL)) {
49-
(New-Object System.Net.WebClient).DownloadFile($NUGET_OLD_URL, $NUGET_OLD_EXE)
50-
}
51-
52-
# Make sure NuGet (latest) exists where we expect it.
53-
if (!(Test-Path $NUGET_EXE)) {
54-
Throw "Could not find nuget.exe"
55-
}
56-
57-
# Make sure NuGet (v3.5.0) exists where we expect it.
58-
if (!(Test-Path $NUGET_OLD_EXE)) {
59-
Throw "Could not find nuget_old.exe"
60-
}
61-
62-
# Restore tools from NuGet?
63-
if (-Not $SkipToolPackageRestore.IsPresent)
64-
{
65-
Push-Location
66-
Set-Location $TOOLS_DIR
67-
Invoke-Expression "$NUGET_EXE install -ExcludeVersion"
68-
Pop-Location
69-
if ($LASTEXITCODE -ne 0) {
70-
exit $LASTEXITCODE
71-
}
72-
}
73-
74-
# Make sure that Cake has been installed.
75-
if (!(Test-Path $CAKE_EXE)) {
76-
Throw "Could not find Cake.exe"
77-
}
78-
79-
# Start Cake
80-
Invoke-Expression "$CAKE_EXE `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
81-
exit $LASTEXITCODE
12+
dotnet cake @args
13+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

build.sh

+7-88
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,12 @@
11
#!/usr/bin/env bash
2-
###############################################################
3-
# This is the Cake bootstrapper script that is responsible for
4-
# downloading Cake and all specified tools from NuGet.
5-
###############################################################
2+
set -euox pipefail
63

7-
# Define directories.
8-
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
9-
TOOLS_DIR=$SCRIPT_DIR/tools
10-
NUGET_EXE=$TOOLS_DIR/nuget.exe
11-
NUGET_OLD_EXE=$TOOLS_DIR/nuget_old.exe
12-
CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
4+
cd "$(dirname "${BASH_SOURCE[0]}")"
135

14-
# Define default arguments.
15-
SCRIPT="build.cake"
16-
TARGET="Default"
17-
CONFIGURATION="Release"
18-
VERBOSITY="verbose"
19-
DRYRUN=
20-
SHOW_VERSION=false
21-
SCRIPT_ARGUMENTS=()
6+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
7+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
8+
export DOTNET_NOLOGO=1
229

23-
# Parse arguments.
24-
for i in "$@"; do
25-
case $1 in
26-
-s|--script) SCRIPT="$2"; shift ;;
27-
-t|--target) TARGET="$2"; shift ;;
28-
-c|--configuration) CONFIGURATION="$2"; shift ;;
29-
-v|--verbosity) VERBOSITY="$2"; shift ;;
30-
-d|--dryrun) DRYRUN="--dryrun" ;;
31-
--version) SHOW_VERSION=true ;;
32-
--) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
33-
*) SCRIPT_ARGUMENTS+=("$1") ;;
34-
esac
35-
shift
36-
done
10+
dotnet tool restore
3711

38-
# Make sure the tools folder exist.
39-
if [ ! -d $TOOLS_DIR ]; then
40-
mkdir $TOOLS_DIR
41-
fi
42-
43-
# Make sure that packages.config exist.
44-
if [ ! -f $TOOLS_DIR/packages.config ]; then
45-
echo "Downloading packages.config..."
46-
curl -Lsfo $TOOLS_DIR/packages.config http://cakebuild.net/bootstrapper/packages
47-
if [ $? -ne 0 ]; then
48-
echo "An error occured while downloading packages.config."
49-
exit 1
50-
fi
51-
fi
52-
53-
# Download NuGet (v3.5.0) if it does not exist.
54-
if [ ! -f $NUGET_OLD_EXE ]; then
55-
echo "Downloading NuGet..."
56-
curl -Lsfo $NUGET_OLD_EXE https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe
57-
if [ $? -ne 0 ]; then
58-
echo "An error occured while downloading nuget.exe."
59-
exit 1
60-
fi
61-
fi
62-
63-
# Download NuGet (latest) if it does not exist.
64-
if [ ! -f $NUGET_EXE ]; then
65-
echo "Downloading NuGet..."
66-
curl -Lsfo $NUGET_EXE https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
67-
if [ $? -ne 0 ]; then
68-
echo "An error occured while downloading nuget.exe."
69-
exit 1
70-
fi
71-
fi
72-
73-
# Restore tools from NuGet.
74-
pushd $TOOLS_DIR >/dev/null
75-
mono $NUGET_EXE install -ExcludeVersion
76-
if [ $? -ne 0 ]; then
77-
echo "Could not restore NuGet packages."
78-
exit 1
79-
fi
80-
popd >/dev/null
81-
82-
# Make sure that Cake has been installed.
83-
if [ ! -f $CAKE_EXE ]; then
84-
echo "Could not find Cake.exe at '$CAKE_EXE'."
85-
exit 1
86-
fi
87-
88-
# Start Cake
89-
if $SHOW_VERSION; then
90-
exec mono $CAKE_EXE --version
91-
else
92-
exec mono $CAKE_EXE $SCRIPT --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
93-
fi
12+
dotnet cake "$@"

src/AngleSharp.nuspec

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
<dependency id="System.Buffers" version="4.5.1" />
2727
<dependency id="System.Text.Encoding.CodePages" version="6.0.0" />
2828
</group>
29+
<group targetFramework="net60">
30+
<dependency id="System.Buffers" version="4.5.1" />
31+
<dependency id="System.Text.Encoding.CodePages" version="7.0.0" />
32+
</group>
33+
<group targetFramework="net70">
34+
<dependency id="System.Buffers" version="4.5.1" />
35+
<dependency id="System.Text.Encoding.CodePages" version="7.0.0" />
36+
</group>
2937
</dependencies>
3038
</metadata>
3139
</package>

tools/anglesharp.cake

+8-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#addin nuget:?package=Cake.FileHelpers&version=3.2.0
2-
#addin nuget:?package=Octokit&version=0.32.0
1+
#addin nuget:?package=Cake.FileHelpers&version=5.0.0
2+
#addin nuget:?package=Octokit&version=4.0.1
33
using Octokit;
44

55
var configuration = Argument("configuration", "Release");
@@ -57,40 +57,28 @@ Task("Restore-Packages")
5757
.IsDependentOn("Clean")
5858
.Does(() =>
5959
{
60-
if ( isRunningOnWindows )
61-
{
62-
NuGetRestore($"./src/{solutionName}.sln", new NuGetRestoreSettings
63-
{
64-
ToolPath = "tools/NuGet.CommandLine.5.9.1/tools/nuget.exe",
65-
});
66-
}
67-
else
68-
{
69-
NuGetRestore($"./src/{solutionName}.sln", new NuGetRestoreSettings
70-
{
71-
ToolPath = EnvironmentVariable("NUGET_EXE"),
72-
});
73-
}
60+
NuGetRestore($"./src/{solutionName}.sln");
7461
});
7562

7663
Task("Build")
7764
.IsDependentOn("Restore-Packages")
7865
.Does(() =>
7966
{
8067
ReplaceRegexInFiles("./src/Directory.Build.props", "(?<=<Version>)(.+?)(?=</Version>)", version);
81-
DotNetCoreBuild($"./src/{solutionName}.sln", new DotNetCoreBuildSettings
68+
DotNetBuild($"./src/{solutionName}.sln", new DotNetBuildSettings
8269
{
8370
Configuration = configuration,
84-
MSBuildSettings = new DotNetCoreMSBuildSettings()
71+
MSBuildSettings = new DotNetMSBuildSettings()
8572
.WithProperty("ContinuousIntegrationBuild", BuildSystem.IsLocalBuild ? "false" : "true")
8673
});
8774
});
8875

8976
Task("Run-Unit-Tests")
9077
.IsDependentOn("Build")
78+
.ContinueOnError()
9179
.Does(() =>
9280
{
93-
var settings = new DotNetCoreTestSettings
81+
var settings = new DotNetTestSettings
9482
{
9583
Configuration = configuration,
9684
};
@@ -100,7 +88,7 @@ Task("Run-Unit-Tests")
10088
settings.Loggers.Add("GitHubActions");
10189
}
10290

103-
DotNetCoreTest($"./src/{solutionName}.Tests/", settings);
91+
DotNetTest($"./src/{solutionName}.Tests/", settings);
10492
});
10593

10694
Task("Copy-Files")

0 commit comments

Comments
 (0)