Skip to content
Closed
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
4 changes: 4 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
<PackageVersion Include="runtime.linux-musl-x64.Microsoft.NETCore.DotNetHostResolver" Version="$(MicrosoftNETCoreDotNetHostResolverPackageVersion)" />
<PackageVersion Include="runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver" Version="$(MicrosoftNETCoreDotNetHostResolverPackageVersion)" />
<PackageVersion Include="runtime.osx-x64.Microsoft.NETCore.DotNetHostResolver" Version="$(MicrosoftNETCoreDotNetHostResolverPackageVersion)" />
<PackageVersion Include="Semver" Version="2.2.0" />
<PackageVersion Include="Spectre.Console" Version="0.49.1" />
<PackageVersion Include="Spectre.Console.Testing" Version="0.46.0" />
<PackageVersion Include="StyleCop.Analyzers" Version="$(StyleCopAnalyzersPackageVersion)" />
<PackageVersion Include="System.CodeDom" Version="$(SystemCodeDomPackageVersion)" />
<PackageVersion Include="System.CommandLine" Version="$(SystemCommandLineVersion)" />
Expand Down Expand Up @@ -125,6 +128,7 @@
<PackageVersion Include="xunit" Version="$(XUnitVersion)" />
<PackageVersion Include="Xunit.Combinatorial" Version="$(XunitCombinatorialVersion)" />
<PackageVersion Include="xunit.console" Version="$(XUnitVersion)" />
<PackageVersion Include="zio" Version="0.20.0" />
</ItemGroup>

<!-- Use different versions of Microsoft.Build.* depending on whether the output will be used in
Expand Down
1 change: 1 addition & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
<!-- mstest dependencies -->
<add key="test-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json" />
<add key="dnceng-trial" value="https://pkgs.dev.azure.com/noahgilson0593/_packaging/dnceng-trial/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down
21 changes: 20 additions & 1 deletion sdk.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.31903.286
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down Expand Up @@ -546,6 +547,23 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.ApiDiff.Te
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.ApiDiff", "src\Compatibility\ApiDiff\Microsoft.DotNet.ApiDiff\Microsoft.DotNet.ApiDiff.csproj", "{4F23A9C8-945A-A4F4-51E9-FCA215943C0D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DNVM", "DNVM", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
ProjectSection(SolutionItems) = preProject
src\DNVM\Channel.cs = src\DNVM\Channel.cs
src\DNVM\dnvm.csproj = src\DNVM\dnvm.csproj
src\DNVM\DnvmEnv.cs = src\DNVM\DnvmEnv.cs
src\DNVM\DotnetReleasesIndex.cs = src\DNVM\DotnetReleasesIndex.cs
src\DNVM\InstallCommand.cs = src\DNVM\InstallCommand.cs
src\DNVM\ListCommand.cs = src\DNVM\ListCommand.cs
src\DNVM\Logger.cs = src\DNVM\Logger.cs
src\DNVM\ManifestUtils.cs = src\DNVM\ManifestUtils.cs
src\DNVM\Program.cs = src\DNVM\Program.cs
src\DNVM\ScalarDeserializer.cs = src\DNVM\ScalarDeserializer.cs
src\DNVM\SelectCommand.cs = src\DNVM\SelectCommand.cs
src\DNVM\UninstallCommand.cs = src\DNVM\UninstallCommand.cs
src\DNVM\UpdateCommand.cs = src\DNVM\UpdateCommand.cs
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1237,6 +1255,7 @@ Global
{3F0093BF-A64D-4EE8-8A2A-22800BB25CFF} = {C66B5859-B05E-5DF4-58E9-78CA919DB89A}
{A57B724D-D12B-483E-82F2-2183DEA2DFA7} = {AFA55F45-CFCB-9821-A210-2D3496088416}
{4F23A9C8-945A-A4F4-51E9-FCA215943C0D} = {C66B5859-B05E-5DF4-58E9-78CA919DB89A}
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {22AB674F-ED91-4FBC-BFEE-8A1E82F9F05E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FB8F26CE-4DE6-433F-B32A-79183020BBD6}
Expand Down
32 changes: 32 additions & 0 deletions src/Cli/dotnet/Commands/DNVM/DnvmCommandParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.CommandLine;
using Microsoft.DotNet.Cli.Extensions;

namespace Microsoft.DotNet.Cli.Commands.DNVM;

internal static class DnvmCommandParser
{
public static readonly string DocsLink = "https://aka.ms/dotnet-dnvm";

private static readonly Command Command = ConstructCommand();

public static Command GetCommand()
{
return Command;
}

private static Command ConstructCommand()
{
DocumentedCommand command = new("dnvm", DocsLink, "The .NET version manager");
command.Subcommands.Add(InstallCommandParser.GetCommand());
command.Subcommands.Add(UninstallCommandParser.GetCommand());

command.SetAction((parseResult) => parseResult.HandleMissingCommand());

return command;
}
}
55 changes: 55 additions & 0 deletions src/Cli/dotnet/Commands/DNVM/InstallCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System;
using System.CommandLine;
using System.Threading.Tasks;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.DNVM;
using Semver;

namespace Microsoft.DotNet.Cli.Commands.DNVM;

public class InstallCommand
{
public static int Run(ParseResult parseResult)
{
parseResult.HandleDebugSwitch();
parseResult.ShowHelpOrErrorIfAppropriate();

return RunAsync(parseResult).GetAwaiter().GetResult();
}

private static async Task<int> RunAsync(ParseResult parseResult)
{
// Map command line options to DNVM InstallCommand.Options
var sdkVersion = parseResult.GetValue(InstallCommandParser.SdkVersionOption);
var force = parseResult.GetValueForOption(InstallCommandParser.ForceOption);
var sdkDirString = parseResult.GetValueForOption(InstallCommandParser.SdkDirOption);
var verbose = parseResult.GetValueForOption(InstallCommandParser.VerboseOption);

var env = DnvmEnv.Create();
var logger = new Logger(verbose ? LogLevel.Info : LogLevel.Standard);

SdkDirName? sdkDir = null;
if (!string.IsNullOrEmpty(sdkDirString))
{
sdkDir = new SdkDirName(sdkDirString);
}

var options = new Microsoft.DotNet.DNVM.InstallCommand.Options
{
SdkVersion = sdkVersion,
Force = force,
SdkDir = sdkDir,
Verbose = verbose
};

var result = await Microsoft.DotNet.DNVM.InstallCommand.Run(env, logger, options);

return (int)result;
}
}
50 changes: 50 additions & 0 deletions src/Cli/dotnet/Commands/DNVM/InstallCommandParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.CommandLine;
using Semver;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.DNVM;

namespace Microsoft.DotNet.Cli.Commands.DNVM;

internal static class InstallCommandParser
{
public static readonly string DocsLink = "https://aka.ms/dotnet-install";

public static readonly Option<SemVersion> SdkVersionOption =
new("--sdk-version", "The version of the SDK to install") { IsRequired = true };

public static readonly Option<bool> ForceOption =
new("--force", "Force installation even if the SDK is already installed");

public static readonly Option<string> SdkDirOption =
new("--sdk-dir", "The directory to install the SDK into");

public static readonly Option<bool> VerboseOption =
new("--verbose", "Enable verbose logging");

private static readonly Command Command = ConstructCommand();

public static Command GetCommand()
{
return Command;
}

private static Command ConstructCommand()
{
var installCommand = new DocumentedCommand("install", DocsLink)
{
SdkVersionOption,
ForceOption,
SdkDirOption,
VerboseOption
};

installCommand.SetAction((parseResult) => InstallCommand.Run(parseResult));

return installCommand;
}
}
42 changes: 42 additions & 0 deletions src/Cli/dotnet/Commands/DNVM/UninstallCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.CommandLine;
using System.Threading.Tasks;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.DNVM;
using Semver;

namespace Microsoft.DotNet.Cli.Commands.DNVM;

public class UninstallCommand
{
public static int Run(ParseResult parseResult)
{
parseResult.HandleDebugSwitch();
parseResult.ShowHelpOrErrorIfAppropriate();

return RunAsync(parseResult).GetAwaiter().GetResult();
}

private static async Task<int> RunAsync(ParseResult parseResult)
{
var sdkVersion = parseResult.GetValue(UninstallCommandParser.SdkVersionArgument);
var sdkDirString = parseResult.GetValueForOption(UninstallCommandParser.SdkDirOption);

var env = DnvmEnv.Create();
var logger = new Logger(LogLevel.Standard);

// Convert sdk-dir option from string to SdkDirName if provided
SdkDirName? sdkDir = null;
if (!string.IsNullOrEmpty(sdkDirString))
{
sdkDir = new SdkDirName(sdkDirString);
}

return await Microsoft.DotNet.DNVM.UninstallCommand.Run(env, logger, sdkVersion, sdkDir);
}
}
42 changes: 42 additions & 0 deletions src/Cli/dotnet/Commands/DNVM/UninstallCommandParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.CommandLine;
using Semver;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.DNVM;

namespace Microsoft.DotNet.Cli.Commands.DNVM;

internal static class UninstallCommandParser
{
public static readonly string DocsLink = "https://aka.ms/dotnet-dnvm";

public static readonly Argument<SemVersion> SdkVersionArgument =
new("sdk-version", "The version of the SDK to uninstall");

public static readonly Option<string> SdkDirOption =
new("--sdk-dir", "Uninstall the SDK from the given directory");

private static readonly Command Command = ConstructCommand();

public static Command GetCommand()
{
return Command;
}

private static Command ConstructCommand()
{
var uninstallCommand = new DocumentedCommand("uninstall", DocsLink)
{
SdkVersionArgument,
SdkDirOption
};

uninstallCommand.SetAction((parseResult) => UninstallCommand.Run(parseResult));

return uninstallCommand;
}
}
2 changes: 2 additions & 0 deletions src/Cli/dotnet/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
using Microsoft.DotNet.Cli.Commands.VSTest;
using Microsoft.DotNet.Cli.Commands.Workload;
using Microsoft.DotNet.Cli.Commands.Workload.Search;
using Microsoft.DotNet.Cli.Commands.DNVM;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Cli.Utils.Extensions;
Expand Down Expand Up @@ -89,6 +90,7 @@ public static class Parser
VSTestCommandParser.GetCommand(),
HelpCommandParser.GetCommand(),
SdkCommandParser.GetCommand(),
DnvmCommandParser.GetCommand(),
InstallSuccessCommand,
WorkloadCommandParser.GetCommand(),
new System.CommandLine.StaticCompletions.CompletionsCommand()
Expand Down
1 change: 1 addition & 0 deletions src/Cli/dotnet/dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<ProjectReference Include="../../Resolvers\Microsoft.DotNet.NativeWrapper\Microsoft.DotNet.NativeWrapper.csproj" />
<ProjectReference Include="../../Microsoft.Win32.Msi/Microsoft.Win32.Msi.csproj" />
<ProjectReference Include="..\Microsoft.TemplateEngine.Cli\Microsoft.TemplateEngine.Cli.csproj" />
<ProjectReference Include="..\..\DNVM\dnvm.csproj" />
<ProjectReference Include="..\..\System.CommandLine.StaticCompletions\System.CommandLine.StaticCompletions.csproj" />
</ItemGroup>

Expand Down
Loading
Loading