Skip to content
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

Change from "sln" to "solution" as primary, and add "sln" as alias #43607

Merged
merged 23 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8ea8db8
Change to make "solution" the primary command for SlnCommand and "sln…
SourceCodeWhen Sep 20, 2024
75ae26a
Add additional command test change to fit new primary command name.
SourceCodeWhen Sep 20, 2024
0b0a886
Update top level command test
SourceCodeWhen Sep 20, 2024
50d5ad3
Add change for solution in show help code.
SourceCodeWhen Sep 20, 2024
69627b6
Telemetry change to solution as hashed value. Possible issue with thi…
SourceCodeWhen Sep 21, 2024
b592f4b
Add in sln so the alias gets correctly represented in desired topleve…
SourceCodeWhen Sep 21, 2024
8748c88
Merge branch 'main' into ChangeSlnToSolutionWithAlias
SourceCodeWhen Sep 25, 2024
99df58a
Merge branch 'dotnet:main' into ChangeSlnToSolutionWithAlias
SourceCodeWhen Sep 28, 2024
4dedcc9
Fix: Remove unnecessary for loop
Sep 28, 2024
73bea80
Added extra parameterse for solution command to existing tests
Sep 28, 2024
c21feac
Add parameters for solution command to existing tests
Sep 28, 2024
ef56395
Added new parameters to tests for solution command
Sep 28, 2024
dc99c17
Fix: Modify test filenames to point to correct place
Sep 28, 2024
be0969d
Merge branch 'main' into ChangeSlnToSolutionWithAlias
nagilson Oct 1, 2024
9057d37
Merge branch 'main' into ChangeSlnToSolutionWithAlias
nagilson Oct 2, 2024
9771993
Merge branch 'main' into ChangeSlnToSolutionWithAlias
SourceCodeWhen Oct 3, 2024
9a09b89
Merge branch 'main' into ChangeSlnToSolutionWithAlias
nagilson Oct 8, 2024
4f68719
Fix: test parameters passed to copytestasset
Oct 9, 2024
522cf0e
Fix: test parameters passed to copytestasset
Oct 9, 2024
cc86058
Merge branch 'main' into ChangeSlnToSolutionWithAlias
SourceCodeWhen Oct 9, 2024
48553c1
Merge branch 'main' into ChangeSlnToSolutionWithAlias
SourceCodeWhen Oct 15, 2024
600e6d6
Merge branch 'main' into ChangeSlnToSolutionWithAlias
nagilson Oct 15, 2024
528ec3d
Merge branch 'main' into ChangeSlnToSolutionWithAlias
nagilson Oct 18, 2024
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
6 changes: 3 additions & 3 deletions src/BuiltInTools/dotnet-watch/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal sealed class CommandLineOptions
"restore",
"run",
"sdk",
"sln",
"solution",
"store",
"test",
"tool",
Expand Down Expand Up @@ -179,7 +179,7 @@ internal sealed class CommandLineOptions
BuildProperties = ParseBuildProperties(parseResult.GetValue(propertyOption) ?? []).ToArray(),
};

// Parses name=value pairs passed to --property. Skips invalid input.
// Parses name=value pairs passed to --property. Skips invalid input.
// We don't report error here as it will be reported by dotnet run.
static IEnumerable<(string key, string value)> ParseBuildProperties(string[] properties)
=> from property in properties
Expand Down Expand Up @@ -240,7 +240,7 @@ private static IReadOnlyList<string> GetCommandArguments(
{
explicitCommand = token;
}
else
else
{
if (!dashDashInserted && i >= unmatchedTokensBeforeDashDash)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet-new3/Dotnet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal static Dotnet AddProjectsToSolution(string solutionFile, IReadOnlyList<
{
List<string> allArgs = new()
{
"sln",
"solution",
solutionFile,
"add"
};
Expand Down
10 changes: 5 additions & 5 deletions src/Cli/dotnet/ReleasePropertyProjectLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public IEnumerable<string> GetCustomDefaultConfigurationValueIfSpecified()
}
}
}
return null; // If nothing can be found: that's caught by MSBuild XMake::ProcessProjectSwitch -- don't change the behavior by failing here.
return null; // If nothing can be found: that's caught by MSBuild XMake::ProcessProjectSwitch -- don't change the behavior by failing here.
}

/// <returns>An arbitrary existant project in a solution file. Returns null if no projects exist.
Expand Down Expand Up @@ -205,7 +205,7 @@ public IEnumerable<string> GetCustomDefaultConfigurationValueIfSpecified()
/// <summary>
/// Returns an arbitrary project for the solution. Relies on the .NET SDK PrepareForPublish or _VerifyPackReleaseConfigurations MSBuild targets to catch conflicting values of a given property, like PublishRelease or PackRelease.
/// </summary>
/// <param name="sln">The solution to get an arbitrary project from.</param>
/// <param name="solution">The solution to get an arbitrary project from.</param>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't change if the sln parameter on this function is not changing.

/// <param name="globalProps">The global properties to load into the project.</param>
/// <returns>null if no project exists in the solution that can be evaluated properly. Else, the first project in the solution that can be.</returns>
private ProjectInstance? GetSingleProjectFromSolution(SlnFile sln, Dictionary<string, string> globalProps)
Expand Down Expand Up @@ -253,13 +253,13 @@ private bool IsUnanalyzableProjectInSolution(SlnProject project, string projectF
return null;
}

/// <returns>Returns true if the path exists and is a project file type.</returns>
/// <returns>Returns true if the path exists and is a project file type.</returns>
private bool IsValidProjectFilePath(string path)
{
return File.Exists(path) && Path.GetExtension(path).EndsWith("proj");
}

/// <returns>Returns true if the path exists and is a sln file type.</returns>
/// <returns>Returns true if the path exists and is a sln file type.</returns>
private bool IsValidSlnFilePath(string path)
{
return File.Exists(path) && Path.GetExtension(path).EndsWith("sln");
Expand All @@ -271,7 +271,7 @@ private Dictionary<string, string> GetUserSpecifiedExplicitMSBuildProperties()
Dictionary<string, string> globalProperties = new(StringComparer.OrdinalIgnoreCase);

string[]? globalPropEnumerable = _parseResult.GetValue(CommonOptions.PropertiesOption);

if ( globalPropEnumerable != null )
{
foreach (var keyEqValString in globalPropEnumerable)
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Telemetry/TelemetryFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public IEnumerable<ApplicationInsightsEntryFormat> Filter(object objectToFilter)
private static List<IParseResultLogRule> ParseResultLogRules => new()
{
new AllowListToSendFirstArgument(new HashSet<string> {"new", "help"}),
new AllowListToSendFirstAppliedOptions(new HashSet<string> {"add", "remove", "list", "sln", "nuget"}),
new AllowListToSendFirstAppliedOptions(new HashSet<string> {"add", "remove", "list", "solution", "nuget"}),
new TopLevelCommandNameAndOptionToLog
(
topLevelCommandName: new HashSet<string> {"build", "publish"},
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/commands/dotnet-help/HelpUsageText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static class HelpUsageText
restore {LocalizableStrings.RestoreDefinition}
run {LocalizableStrings.RunDefinition}
sdk {LocalizableStrings.SdkDefinition}
sln {LocalizableStrings.SlnDefinition}
solution {LocalizableStrings.SlnDefinition}
store {LocalizableStrings.StoreDefinition}
test {LocalizableStrings.TestDefinition}
tool {LocalizableStrings.ToolDefinition}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal static bool AddProjectsToSolution(string solutionPath, IReadOnlyList<st
{
PathUtility.EnsureAllPathsExist(new[] { solutionPath }, CommonLocalizableStrings.FileNotFound, allowDirectories: false);
PathUtility.EnsureAllPathsExist(projectsToAdd, CommonLocalizableStrings.FileNotFound, allowDirectories: false);
IEnumerable<string> commandArgs = new[] { "sln", solutionPath, "add" }.Concat(projectsToAdd);
IEnumerable<string> commandArgs = new[] { "solution", solutionPath, "add" }.Concat(projectsToAdd);
if (!string.IsNullOrWhiteSpace(solutionFolder))
{
commandArgs = commandArgs.Append(SlnAddParser.SolutionFolderOption.Name).Append(solutionFolder);
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/commands/dotnet-sln/SlnArgumentValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void ParseAndValidateArguments(string _fileOrDirectory, IReadOnlyC
{
string.Format(CommonLocalizableStrings.SolutionArgumentMisplaced, slnFile),
CommonLocalizableStrings.DidYouMean,
$" dotnet sln {slnFile} {command} {args}{projectArgs}"
$" dotnet solution {slnFile} {command} {args}{projectArgs}"
});
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/Cli/dotnet/commands/dotnet-sln/SlnCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.CommandLine;
using NuGet.Packaging;
using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings;

namespace Microsoft.DotNet.Cli
Expand All @@ -10,6 +11,8 @@ internal static class SlnCommandParser
{
public static readonly string DocsLink = "https://aka.ms/dotnet-sln";

public static readonly string CommandName = "solution";
public static readonly string CommandAlias = "sln";
public static readonly CliArgument<string> SlnArgument = new CliArgument<string>(LocalizableStrings.SolutionArgumentName)
{
HelpName = LocalizableStrings.SolutionArgumentName,
Expand All @@ -26,7 +29,9 @@ public static CliCommand GetCommand()

private static CliCommand ConstructCommand()
{
DocumentedCommand command = new("sln", DocsLink, LocalizableStrings.AppFullName);
DocumentedCommand command = new(CommandName, DocsLink, LocalizableStrings.AppFullName);

command.Aliases.Add(CommandAlias);

command.Arguments.Add(SlnArgument);
command.Subcommands.Add(SlnAddParser.GetCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ remove Remove a package or reference from a .NET project.
restore Restore dependencies specified in a .NET project.
run Build and run a .NET project output.
sdk Manage .NET SDK installation.
sln Modify Visual Studio solution files.
solution Modify Visual Studio solution files.
store Store the specified assemblies in the runtime package store.
test Run unit tests using the test runner specified in a .NET project.
tool Install or manage tools that extend the .NET experience.
Expand Down
Loading