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": { diff --git a/CakeScripts/TargetEnvironment.cake b/CakeScripts/TargetEnvironment.cake index 811351fae..7cad4d748 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() { @@ -32,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()) { @@ -51,8 +71,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 +170,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 +196,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); 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