From f874996c4cfb32471f91d00f072016328209e785 Mon Sep 17 00:00:00 2001 From: Thomas Mielke Date: Mon, 1 Apr 2024 14:48:34 +0200 Subject: [PATCH 1/4] added VSCode launch.json configuration for cake script --- .gitignore | 3 +++ .vscode/launch.json | 43 ++++++++++++------------------------------- .vscode/tasks.json | 2 +- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 8335b19fc..e014a5263 100755 --- a/.gitignore +++ b/.gitignore @@ -315,3 +315,6 @@ OpenCover/ # macOS metadata .DS_Store + +# created by CSDevKit +.mono/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 84580c985..613cd3c3e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,11 +1,8 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { - "name": ".NET Core Launch (console)", + "name": "Samples", "type": "coreclr", "request": "launch", "preLaunchTask": "build", @@ -16,36 +13,20 @@ "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart" }, - { - "name": ".NET Core Launch (web)", + { // install VSCode Cake extension for source-level debugging of the cake script + "name": "Cake Build Script (InstallWorkload)", "type": "coreclr", "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceFolder}/bin/Debug//.dll", - "args": [], - "cwd": "${workspaceFolder}", + "program": "${env:HOME}/.nuget/packages/cake.tool/2.0.0/tools/net6.0/any/Cake.dll", + "args": [ + "${workspaceRoot}/build.cake", + "--BuildTarget=InstallWorkload", + "--debug", + "--verbosity=diagnostic" + ], + "cwd": "${workspaceRoot}", "stopAtEntry": false, - "internalConsoleOptions": "openOnSessionStart", - "launchBrowser": { - "enabled": true, - "args": "${auto-detect-url}", - "windows": { - "command": "cmd.exe", - "args": "/C start ${auto-detect-url}" - }, - "osx": { - "command": "open" - }, - "linux": { - "command": "xdg-open" - } - }, - "env": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "sourceFileMap": { - "/Views": "${workspaceFolder}/Views" - } + "externalConsole": false }, { "name": ".NET Core Attach", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 10040fd8f..593cd5350 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,7 +5,7 @@ "tasks": [ { "label": "build", - "command": "dotnet build Source/Samples/Samples.csproj", + "command": "dotnet build ${workspaceRoot}/Source/Samples/Samples.csproj", "type": "shell", "group": "build", "presentation": { From 2e1313294f4fd8e8fce993a2156ac2c296768875 Mon Sep 17 00:00:00 2001 From: Thomas Mielke Date: Thu, 4 Apr 2024 17:05:24 +0200 Subject: [PATCH 2/4] 'backport' of trungnt2910's servicing builds fix for Haiku OS Original commit message: fix: Treat servicing builds as stable These builds will choose the stable workload manifests instead of the `.rc` or `.preview` builds. https://github.com/trungnt2910/dotnet-haiku/commit/a325fcb24ddb092cc267dfff6a35f1d84d664c28 It also fixes an issue with reinstalling the workload on Windows (due to Windows ignoring character case in paths). --- CakeScripts/TargetEnvironment.cake | 34 ++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/CakeScripts/TargetEnvironment.cake b/CakeScripts/TargetEnvironment.cake index 811351fae..dc4450de3 100644 --- a/CakeScripts/TargetEnvironment.cake +++ b/CakeScripts/TargetEnvironment.cake @@ -20,6 +20,7 @@ class TargetEnvironment public static string DotNetCliPath { get; private set; } public static string DotNetCliFeatureBand { get; private set; } + public static string DotNetCliFeatureBandWithoutPreview { get; private set; } static TargetEnvironment() { @@ -51,8 +52,33 @@ class TargetEnvironment proc.WaitForExit(); - DotNetCliFeatureBand = proc.StandardOutput.ReadToEnd().Trim(); - DotNetCliFeatureBand = DotNetCliFeatureBand.Substring(0, DotNetCliFeatureBand.Length - 2) + "00"; + var dotnetVersion = proc.StandardOutput.ReadToEnd().Trim(); + var prereleaseStart = dotnetVersion.IndexOf('-'); + + if (prereleaseStart != -1) + { + var firstDot = dotnetVersion.IndexOf('.', prereleaseStart); + var secondDot = dotnetVersion.IndexOf('.', firstDot + 1); + if (secondDot == -1) + { + secondDot = dotnetVersion.Length; + } + DotNetCliFeatureBandWithoutPreview = dotnetVersion.Substring(0, prereleaseStart); + var prereleaseKind = dotnetVersion.Substring(prereleaseStart + 1, firstDot - prereleaseStart - 1); + if (prereleaseKind == "servicing") + { + DotNetCliFeatureBand = dotnetVersion.Substring(0, prereleaseStart - 2) + "00"; + } + else + { + DotNetCliFeatureBand = dotnetVersion.Substring(0, secondDot); + } + } + else + { + DotNetCliFeatureBand = dotnetVersion.Substring(0, dotnetVersion.Length - 2) + "00"; + DotNetCliFeatureBandWithoutPreview = DotNetCliFeatureBand; + } DotNetInstalledWorkloadsMetadataPath = P.Combine(DotNetInstallPath, "metadata", "workloads", DotNetCliFeatureBand, "InstalledWorkloads"); DotNetInstallerTypeMetadataPath = P.Combine(DotNetInstallPath, "metadata", "workloads", DotNetCliFeatureBand, "InstallerType"); @@ -125,7 +151,7 @@ class TargetEnvironment public static void InstallManifests(string manifestName, string manifestPackPath) { - var targetDirectory = P.Combine(DotNetManifestPath, manifestName); + var targetDirectory = P.Combine(DotNetManifestPath, manifestName.ToLowerInvariant()); var tempDirectory = P.Combine(targetDirectory, "temp"); // Delete existing installations to avoid conflict. @@ -151,7 +177,7 @@ class TargetEnvironment public static void UninstallManifests(string manifestName) { - var targetDirectory = P.Combine(DotNetManifestPath, manifestName); + var targetDirectory = P.Combine(DotNetManifestPath, manifestName, manifestName.ToLowerInvariant()); if (D.Exists(targetDirectory)) { D.Delete(targetDirectory, true); From 780a94e4075c33300e8b007e60a157fbb8f9a9fa Mon Sep 17 00:00:00 2001 From: Thomas Mielke Date: Thu, 4 Apr 2024 19:18:13 +0200 Subject: [PATCH 3/4] cake workload: heuristics on Linux in case DOTNET_ROOT env var not set --- CakeScripts/TargetEnvironment.cake | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CakeScripts/TargetEnvironment.cake b/CakeScripts/TargetEnvironment.cake index dc4450de3..7cad4d748 100644 --- a/CakeScripts/TargetEnvironment.cake +++ b/CakeScripts/TargetEnvironment.cake @@ -33,7 +33,26 @@ class TargetEnvironment } else if (OperatingSystem.IsLinux()) { - DotNetInstallPath = "/usr/share/dotnet"; + var userHomeDirectory = Environment.GetEnvironmentVariable("HOME"); + if (userHomeDirectory != null) + { + if (userHomeDirectory != "/root") + DotNetInstallPath = P.Combine(userHomeDirectory, ".dotnet"); // default to user home directory + if (!D.Exists(DotNetInstallPath)) + DotNetInstallPath = null; // SDK not found in user home directory + + if (DotNetInstallPath == null) + { + DotNetInstallPath = "/usr/share/dotnet"; // assume Ubuntu 22.04 when installed from packages.microsoft.com + if (!D.Exists(DotNetInstallPath)) + DotNetInstallPath = "/usr/share/dotnet"; // else try Ubuntu Jammy feed + if (!D.Exists(DotNetInstallPath)) + DotNetInstallPath = null; // SDK not found in both paths + } + } + + if (DotNetInstallPath != null) + Console.WriteLine($"DOTNET_ROOT environment variable wasn't set, using SDK in {DotNetInstallPath}. Setting DOTNET_ROOT is highly recommended."); } else if (OperatingSystem.IsMacOS()) { From 33431d5ede4aeb2b0fb81c060f61694570c2f984 Mon Sep 17 00:00:00 2001 From: Thomas Mielke Date: Sat, 16 Nov 2024 16:41:04 +0100 Subject: [PATCH 4/4] added missing .NET 8 version bands --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 89614e4e0..317b741b2 100644 --- a/build.cake +++ b/build.cake @@ -14,7 +14,7 @@ var configuration = Argument("Configuration", "Release"); var msbuildsettings = new DotNetMSBuildSettings(); var list = new List(); -var supportedVersionBands = new List() {"6.0.100", "6.0.200", "6.0.300", "6.0.400", "7.0.400", "8.0.100", "8.0.200"}; +var supportedVersionBands = new List() {"6.0.100", "6.0.200", "6.0.300", "6.0.400", "7.0.400", "8.0.100", "8.0.200", "8.0.300", "8.0.400"}; // TASKS