Skip to content

Commit 8467f28

Browse files
committed
Use dotnet-cake for performing the build
1 parent 42e49b4 commit 8467f28

File tree

6 files changed

+34
-46
lines changed

6 files changed

+34
-46
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "1.1.0",
6+
"version": "3.0.0",
77
"commands": [
88
"dotnet-cake"
99
]
1010
}
1111
}
12-
}
12+
}

build.cake

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Task("GitVersion")
6060
/// </summary>
6161
Task("Setup")
6262
.IsDependentOn("ValidateMono")
63-
.IsDependentOn("InstallDotNetCoreSdk");
63+
.IsDependentOn("InstallDotNetSdk");
6464

6565
void InstallDotNetSdk(BuildEnvironment env, BuildPlan plan, string version, string installFolder, bool sharedRuntime = false, bool noPath = false)
6666
{
@@ -73,10 +73,7 @@ void InstallDotNetSdk(BuildEnvironment env, BuildPlan plan, string version, stri
7373
var scriptFilePath = CombinePaths(installFolder, scriptFileName);
7474
var url = $"{plan.DotNetInstallScriptURL}/{scriptFileName}";
7575

76-
using (var client = new WebClient())
77-
{
78-
client.DownloadFile(url, scriptFilePath);
79-
}
76+
DownloadFile(url, File(scriptFilePath));
8077

8178
if (!Platform.Current.IsWindows)
8279
{
@@ -110,7 +107,7 @@ void InstallDotNetSdk(BuildEnvironment env, BuildPlan plan, string version, stri
110107
Run(env.ShellCommand, $"{env.ShellArgument} {scriptFilePath} {string.Join(" ", argList)}").ExceptionOnError($"Failed to Install .NET Core SDK {version}");
111108
}
112109

113-
Task("InstallDotNetCoreSdk")
110+
Task("InstallDotNetSdk")
114111
.Does(() =>
115112
{
116113
if (!useGlobalDotNetSdk)
@@ -157,21 +154,21 @@ Task("PrepareTestAssets:CommonTestAssets")
157154
var folder = CombinePaths(env.Folders.TestAssets, "test-projects", project);
158155

159156
try {
160-
DotNetCoreBuild(folder, new DotNetCoreBuildSettings()
157+
DotNetBuild(folder, new DotNetBuildSettings()
161158
{
162159
ToolPath = env.DotNetCommand,
163160
WorkingDirectory = folder,
164-
Verbosity = DotNetCoreVerbosity.Minimal
161+
Verbosity = DotNetVerbosity.Minimal
165162
});
166163
} catch {
167164
// ExternalAlias has issues once in a while, try building again to get it working.
168165
if (project == "ExternAlias") {
169166

170-
DotNetCoreBuild(folder, new DotNetCoreBuildSettings()
167+
DotNetBuild(folder, new DotNetBuildSettings()
171168
{
172169
ToolPath = env.DotNetCommand,
173170
WorkingDirectory = folder,
174-
Verbosity = DotNetCoreVerbosity.Minimal
171+
Verbosity = DotNetVerbosity.Minimal
175172
});
176173
}
177174
}
@@ -185,11 +182,11 @@ Task("PrepareTestAssets:RestoreOnlyTestAssets")
185182

186183
var folder = CombinePaths(env.Folders.TestAssets, "test-projects", project);
187184

188-
DotNetCoreRestore(new DotNetCoreRestoreSettings()
185+
DotNetRestore(new DotNetRestoreSettings()
189186
{
190187
ToolPath = env.DotNetCommand,
191188
WorkingDirectory = folder,
192-
Verbosity = DotNetCoreVerbosity.Minimal
189+
Verbosity = DotNetVerbosity.Minimal
193190
});
194191
});
195192

@@ -202,11 +199,11 @@ Task("PrepareTestAssets:WindowsOnlyTestAssets")
202199

203200
var folder = CombinePaths(env.Folders.TestAssets, "test-projects", project);
204201

205-
DotNetCoreBuild(folder, new DotNetCoreBuildSettings()
202+
DotNetBuild(folder, new DotNetBuildSettings()
206203
{
207204
ToolPath = env.DotNetCommand,
208205
WorkingDirectory = folder,
209-
Verbosity = DotNetCoreVerbosity.Minimal
206+
Verbosity = DotNetVerbosity.Minimal
210207
});
211208
});
212209

@@ -238,14 +235,15 @@ void BuildWithDotNetCli(BuildEnvironment env, string configuration)
238235
? MSBuildBinaryLogImports.Embed
239236
: MSBuildBinaryLogImports.None;
240237

241-
var settings = new DotNetCoreMSBuildSettings
238+
var settings = new DotNetMSBuildSettings
242239
{
243240
WorkingDirectory = env.WorkingDirectory,
244241

245242
ArgumentCustomization = args =>
246243
args.Append("/restore")
247244
.Append($"/bl:{logFileNameBase}.binlog;ProjectImports={projectImports}")
248245
.Append($"/v:{Verbosity.Minimal.GetMSBuildVerbosityName()}")
246+
.Append("/tl")
249247
};
250248

251249
settings.AddFileLogger(
@@ -268,7 +266,7 @@ void BuildWithDotNetCli(BuildEnvironment env, string configuration)
268266
.WithProperty("RuntimeFrameworkVersion", "6.0.0-preview.7.21317.1") // Set the minimum runtime to a .NET 6 prerelease so that prerelease SDKs will be considered during rollForward.
269267
.WithProperty("RollForward", "LatestMajor");
270268

271-
DotNetCoreMSBuild("OmniSharp.sln", settings);
269+
DotNetMSBuild("OmniSharp.sln", settings);
272270
}
273271

274272
Task("Build")
@@ -570,15 +568,15 @@ string PublishBuild(string project, BuildEnvironment env, BuildPlan plan, string
570568

571569
try
572570
{
573-
var publishSettings = new DotNetCorePublishSettings()
571+
var publishSettings = new DotNetPublishSettings()
574572
{
575573
Framework = framework,
576574
Runtime = rid, // TODO: With everything today do we need to publish this with a rid? This appears to be legacy bit when we used to push for all supported dotnet core rids.
577575
PublishReadyToRun = true, // Improve startup performance by applying some AOT compilation
578576
SelfContained = false, // Since we are specifying a runtime identifier this defaults to true. We don't need to ship a runtime for net6 because we require the .NET SDK to be installed.
579577
Configuration = configuration,
580578
OutputDirectory = outputFolder,
581-
MSBuildSettings = new DotNetCoreMSBuildSettings()
579+
MSBuildSettings = new DotNetMSBuildSettings()
582580
.WithProperty("PackageVersion", env.VersionInfo.NuGetVersion)
583581
.WithProperty("AssemblyVersion", env.VersionInfo.AssemblySemVer)
584582
.WithProperty("FileVersion", env.VersionInfo.AssemblySemVer)
@@ -587,9 +585,9 @@ string PublishBuild(string project, BuildEnvironment env, BuildPlan plan, string
587585
.WithProperty("RollForward", "LatestMajor"),
588586
ToolPath = env.DotNetCommand,
589587
WorkingDirectory = env.WorkingDirectory,
590-
Verbosity = DotNetCoreVerbosity.Minimal,
588+
Verbosity = DotNetVerbosity.Minimal,
591589
};
592-
DotNetCorePublish(projectFileName, publishSettings);
590+
DotNetPublish(projectFileName, publishSettings);
593591
}
594592
catch
595593
{
@@ -645,12 +643,12 @@ Task("PublishWindowsBuilds")
645643
});
646644

647645
Task("PublishNuGet")
648-
.IsDependentOn("InstallDotNetCoreSdk")
646+
.IsDependentOn("InstallDotNetSdk")
649647
.Does(() => {
650-
DotNetCorePack(".", new DotNetCorePackSettings() {
648+
DotNetPack(".", new DotNetPackSettings() {
651649
Configuration = "Release",
652650
OutputDirectory = "./artifacts/nuget/",
653-
MSBuildSettings = new DotNetCoreMSBuildSettings()
651+
MSBuildSettings = new DotNetMSBuildSettings()
654652
.SetConfiguration(configuration)
655653
.WithProperty("PackageVersion", env.VersionInfo.NuGetVersion)
656654
.WithProperty("AssemblyVersion", env.VersionInfo.AssemblySemVer)

build.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) {
214214
Pop-Location
215215
}
216216

217+
Invoke-Expression "&dotnet tool restore"
218+
217219
# Make sure that Cake has been installed.
218220
if (!(Test-Path $CAKE_EXE)) {
219221
Throw "Could not find Cake.exe at $CAKE_EXE"
@@ -235,5 +237,6 @@ $cakeArguments += $ScriptArgs
235237

236238
# Start Cake
237239
Write-Host "Running build script..."
238-
&$CAKE_EXE $cakeArguments
240+
# &$CAKE_EXE $cakeArguments
241+
dotnet cake $cakeArguments
239242
exit $LASTEXITCODE

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100-preview.4.23260.5",
3+
"version": "8.0.100-preview.3.23178.7",
44
"rollForward": "patch"
55
}
66
}

scripts/cake-bootstrap.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5"
8787

8888
popd >/dev/null
8989

90+
dotnet tool restore
91+
9092
# Make sure that Cake has been installed.
9193
if [ ! -f "$CAKE_EXE" ]; then
9294
echo "Could not find Cake.exe at '$CAKE_EXE'."
@@ -95,7 +97,9 @@ fi
9597

9698
# Start Cake
9799
if $SHOW_VERSION; then
98-
exec mono "$CAKE_EXE" --version
100+
# exec mono "$CAKE_EXE" --version
101+
dotnet cake --version
99102
else
100-
exec mono "$CAKE_EXE" $SCRIPT --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
103+
# exec mono "$CAKE_EXE" $SCRIPT --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
104+
dotnet cake $SCRIPT --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
101105
fi

scripts/common.cake

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
using Newtonsoft.Json;
77
using Newtonsoft.Json.Linq;
8-
using System.Net;
98

109
public static class Log
1110
{
@@ -121,22 +120,6 @@ string CombinePaths(params string[] paths)
121120
return PathHelper.Combine(paths);
122121
}
123122

124-
void DownloadFileAndUnzip(string url, string folder)
125-
{
126-
DirectoryHelper.ForceCreate(folder);
127-
var zipFileName = CombinePaths(folder, "temp.zip");
128-
129-
Information("Downloading {0}", url);
130-
131-
using (var client = new WebClient())
132-
{
133-
client.DownloadFile(url, zipFileName);
134-
}
135-
136-
Unzip(zipFileName, folder);
137-
FileHelper.Delete(zipFileName);
138-
}
139-
140123
public class Folders
141124
{
142125
public string DotNetSdk { get; }

0 commit comments

Comments
 (0)