Skip to content

Commit 5ca0b5c

Browse files
committed
Try using uninstall commands
1 parent ec96336 commit 5ca0b5c

18 files changed

+105
-32
lines changed

src/dotnet-bootstrapper/BootstrapperCommandParser.cs

+7-19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.CommandLine.Invocation;
88
using System.CommandLine.Parsing;
99
using System.Reflection;
10+
using Microsoft.DotNet.Tools.Uninstall.Shared.Configs;
1011

1112
namespace Microsoft.DotNet.Tools.Bootstrapper
1213
{
@@ -15,30 +16,17 @@ internal static class BootstrapperCommandParser
1516
public static Parser BootstrapParser;
1617

1718
public static RootCommand BootstrapperRootCommand = new RootCommand("dotnet bootstrapper");
18-
19-
public static readonly Command VersionCommand = new Command("--version");
20-
21-
private static readonly Lazy<string> _assemblyVersion =
22-
new Lazy<string>(() =>
23-
{
24-
var assembly = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
25-
var assemblyVersionAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
26-
if (assemblyVersionAttribute == null)
27-
{
28-
return assembly.GetName().Version.ToString();
29-
}
30-
else
31-
{
32-
return assemblyVersionAttribute.InformationalVersion;
33-
}
34-
});
19+
public static readonly Command HelpCommand = new("--help");
3520

3621
static BootstrapperCommandParser()
3722
{
38-
BootstrapperRootCommand.AddCommand(VersionCommand);
23+
BootstrapperRootCommand.AddCommand(CommandLineConfigs.VersionSubcommand);
24+
BootstrapperRootCommand.AddCommand(CommandLineConfigs.ListCommand);
25+
BootstrapperRootCommand.AddCommand(CommandLineConfigs.RemoveCommand);
26+
BootstrapperRootCommand.AddCommand(HelpCommand);
3927
VersionCommand.Handler = CommandHandler.Create(() =>
4028
{
41-
Console.WriteLine(_assemblyVersion.Value);
29+
Console.WriteLine(LocalizableStrings.BootstrapperHelp);
4230
});
4331

4432
BootstrapParser = new CommandLineBuilder(BootstrapperRootCommand)

src/dotnet-bootstrapper/LocalizableStrings.resx

+3
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,7 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<data name="BootstrapperHelp" xml:space="preserve">
121+
<value>Bootstrapper help text</value>
122+
</data>
120123
</root>

src/dotnet-bootstrapper/dotnet-bootstrapper.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
2626
<PackageReference Include="System.CommandLine.Rendering" Version="0.3.0-alpha.20574.7" />
2727
<PackageReference Include="System.Resources.Extensions" Version="8.0.0" />
28+
<ProjectReference Include="..\dotnet-core-uninstall\dotnet-core-uninstall.csproj"/>
2829
</ItemGroup>
2930

3031
<ItemGroup>

src/dotnet-bootstrapper/xlf/LocalizableStrings.cs.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.de.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.es.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.fr.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.it.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.ja.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.ko.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.pl.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.pt-BR.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.ru.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.tr.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.zh-Hans.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-bootstrapper/xlf/LocalizableStrings.zh-Hant.xlf

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet-core-uninstall/Shared/Configs/CommandLineConfigs.cs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal static class CommandLineConfigs
2828
private static readonly string DryRunCommandName = "dry-run";
2929
private static readonly string WhatIfCommandName = "whatif";
3030
private static readonly string RemoveCommandName = "remove";
31+
private static readonly string UninstallCommandName = "uninstall";
3132

3233
public static readonly RootCommand UninstallRootCommand = new RootCommand(
3334
RuntimeInfo.RunningOnWindows ? LocalizableStrings.UninstallNoOptionDescriptionWindows
@@ -220,6 +221,7 @@ static CommandLineConfigs()
220221
UninstallRootCommand.AddCommand(ListCommand);
221222
UninstallRootCommand.AddCommand(DryRunCommand);
222223
UninstallRootCommand.AddCommand(RemoveCommand);
224+
RemoveCommand.Aliases.Add(UninstallCommandName); // The verbiage that makes the most sense from the bootstrapper would be 'uninstall', so just adding an alias permits more code sharing
223225
UninstallRootCommand.AddCommand(VersionSubcommand);
224226

225227
if (RuntimeInfo.RunningOnOSX)

src/dotnet-core-uninstall/dotnet-core-uninstall.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<AssemblyName>dotnet-core-uninstall</AssemblyName>
44
<OutputType>Exe</OutputType>
5+
<SelfContained>true</SelfContained>
56
<RuntimeIdentifiers>win-x86;osx-x64;osx-arm64</RuntimeIdentifiers>
67
<SignAssembly>true</SignAssembly>
78
<TargetFramework>net8.0</TargetFramework>

0 commit comments

Comments
 (0)