Thanks to visit codestin.com
Credit goes to github.com

Skip to content

added VSCode launch.json configuration for cake script #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,6 @@ OpenCover/

# macOS metadata
.DS_Store

# created by CSDevKit
.mono/
43 changes: 12 additions & 31 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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/<insert-target-framework-here>/<insert-project-name-here>.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",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
55 changes: 50 additions & 5 deletions CakeScripts/TargetEnvironment.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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())
{
Expand All @@ -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");
Expand Down Expand Up @@ -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.
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var configuration = Argument("Configuration", "Release");

var msbuildsettings = new DotNetMSBuildSettings();
var list = new List<GAssembly>();
var supportedVersionBands = new List<string>() {"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<string>() {"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

Expand Down