Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ internal void GenerateDepsJsonFile(
string? stdOut;
string? stdErr;

var msbuildArgs = MSBuildArgs.AnalyzeMSBuildArguments([..args], CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, BuildCommandParser.TargetOption, BuildCommandParser.VerbosityOption);
var msbuildArgs = MSBuildArgs.AnalyzeMSBuildArguments([.. args], CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, BuildCommandParser.TargetOption, BuildCommandParser.VerbosityOption);
var forwardingAppWithoutLogging = new MSBuildForwardingAppWithoutLogging(msbuildArgs, msBuildExePath);
if (forwardingAppWithoutLogging.ExecuteMSBuildOutOfProc)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Build/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class BuildCommand
{
public static CommandBase FromArgs(string[] args, string? msbuildPath = null)
{
var parseResult = Parser.Parse(["dotnet", "build", ..args]);
var parseResult = Parser.Parse(["dotnet", "build", .. args]);
return FromParseResult(parseResult, msbuildPath);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Cli/dotnet/Commands/Clean/CleanCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CleanCommand(MSBuildArgs msbuildArgs, string? msbuildPath = null) :
{
public static CommandBase FromArgs(string[] args, string? msbuildPath = null)
{
var result = Parser.Parse(["dotnet", "clean", ..args]);
var result = Parser.Parse(["dotnet", "clean", .. args]);
return FromParseResult(result, msbuildPath);
}

Expand All @@ -33,7 +33,7 @@ public static CommandBase FromParseResult(ParseResult result, string? msbuildPat
NoWriteBuildMarkers = true,
},
static (msbuildArgs, msbuildPath) => new CleanCommand(msbuildArgs, msbuildPath),
[ CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, CleanCommandParser.TargetOption, CleanCommandParser.VerbosityOption ],
[CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, CleanCommandParser.TargetOption, CleanCommandParser.VerbosityOption],
result,
msbuildPath
);
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Format/FormatCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class FormatCommand(IEnumerable<string> argsToForward) : FormatForwarding
{
public static FormatCommand FromArgs(string[] args)
{
var result = Parser.Parse(["dotnet", "format", ..args]);
var result = Parser.Parse(["dotnet", "format", .. args]);
return FromParseResult(result);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Hidden/Complete/CompleteCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static int Run(ParseResult parseResult)

public static int RunWithReporter(string[] args, IReporter reporter)
{
var result = Parser.Parse(["dotnet", "complete", ..args]);
var result = Parser.Parse(["dotnet", "complete", .. args]);
return RunWithReporter(result, reporter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static int Run(ParseResult parseResult)

public static void ProcessInputAndSendTelemetry(string[] args, ITelemetry telemetry)
{
var result = Parser.Parse(["dotnet", "internal-reportinstallsuccess", ..args]);
var result = Parser.Parse(["dotnet", "internal-reportinstallsuccess", .. args]);
ProcessInputAndSendTelemetry(result, telemetry);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Cli/dotnet/Commands/MSBuild/MSBuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ namespace Microsoft.DotNet.Cli.Commands.MSBuild;
public class MSBuildCommand(
IEnumerable<string> msbuildArgs,
string? msbuildPath = null
) : MSBuildForwardingApp(MSBuildArgs.AnalyzeMSBuildArguments([..msbuildArgs], CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, MSBuildCommandParser.TargetOption, CommonOptions.VerbosityOption()), msbuildPath, includeLogo: true)
) : MSBuildForwardingApp(MSBuildArgs.AnalyzeMSBuildArguments([.. msbuildArgs], CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, MSBuildCommandParser.TargetOption, CommonOptions.VerbosityOption()), msbuildPath, includeLogo: true)
{
public static MSBuildCommand FromArgs(string[] args, string? msbuildPath = null)
{
var result = Parser.Parse(["dotnet", "msbuild", ..args]);
var result = Parser.Parse(["dotnet", "msbuild", .. args]);
return FromParseResult(result, msbuildPath);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Cli/dotnet/Commands/Pack/PackCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class PackCommand(
{
public static CommandBase FromArgs(string[] args, string? msbuildPath = null)
{
var parseResult = Parser.Parse(["dotnet", "pack", ..args]);
var parseResult = Parser.Parse(["dotnet", "pack", .. args]);
return FromParseResult(parseResult, msbuildPath);
}

Expand Down Expand Up @@ -92,14 +92,14 @@ public static int RunPackCommand(ParseResult parseResult)

if (args.Count != 1)
{
Console.Error.WriteLine(CliStrings.PackCmd_OneNuspecAllowed);
Console.Error.WriteLine(CliStrings.PackCmd_OneNuspecAllowed);
return 1;
}

var nuspecPath = args[0];

var packArgs = new PackArgs()
{
{
Logger = new NuGetConsoleLogger(),
Exclude = new List<string>(),
OutputDirectory = parseResult.GetValue(PackCommandParser.OutputOption),
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/dotnet/Commands/Package/List/PackageListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#nullable disable

using System.CommandLine;
using System.Globalization;
using Microsoft.DotNet.Cli.Commands.Hidden.List;
using Microsoft.DotNet.Cli.Commands.MSBuild;
using Microsoft.DotNet.Cli.Commands.NuGet;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.Utils;
using System.Globalization;
using Microsoft.DotNet.Cli.Commands.MSBuild;

namespace Microsoft.DotNet.Cli.Commands.Package.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#nullable disable

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

namespace Microsoft.DotNet.Cli.Commands.Package.Search;

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Publish/PublishCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private PublishCommand(

public static CommandBase FromArgs(string[] args, string? msbuildPath = null)
{
var parseResult = Parser.Parse(["dotnet", "publish", ..args]);
var parseResult = Parser.Parse(["dotnet", "publish", .. args]);
return FromParseResult(parseResult);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Restore/RestoreCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class RestoreCommand
{
public static CommandBase FromArgs(string[] args, string? msbuildPath = null)
{
var result = Parser.Parse(["dotnet", "restore", ..args]);
var result = Parser.Parse(["dotnet", "restore", .. args]);
return FromParseResult(result, msbuildPath);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Cli/dotnet/Commands/Restore/RestoringCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public RestoringCommand(
string? msbuildPath = null,
string? userProfileDir = null,
bool? advertiseWorkloadUpdates = null)
: base(GetCommandArguments(msbuildArgs, noRestore), msbuildPath)
: base(GetCommandArguments(msbuildArgs, noRestore), msbuildPath)
{
userProfileDir = CliFolderPathCalculator.DotnetUserProfileFolderPath;
Task.Run(() => WorkloadManifestUpdater.BackgroundUpdateAdvertisingManifestsAsync(userProfileDir));
Expand Down Expand Up @@ -122,13 +122,13 @@ private static MSBuildArgs GetCommandArguments(
ReadOnlyDictionary<string, string> restoreProperties =
msbuildArgs.GlobalProperties?
.Where(kvp => !IsPropertyExcludedFromRestore(kvp.Key))?
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value, StringComparer.OrdinalIgnoreCase) is { } filteredList ? new(filteredList): ReadOnlyDictionary<string, string>.Empty;
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value, StringComparer.OrdinalIgnoreCase) is { } filteredList ? new(filteredList) : ReadOnlyDictionary<string, string>.Empty;
var restoreMSBuildArgs =
MSBuildArgs.FromProperties(RestoreOptimizationProperties)
.CloneWithAdditionalTargets("Restore")
.CloneWithExplicitArgs([.. newArgumentsToAdd, .. existingArgumentsToForward])
.CloneWithAdditionalProperties(restoreProperties);
if (msbuildArgs.Verbosity is {} verbosity)
if (msbuildArgs.Verbosity is { } verbosity)
{
restoreMSBuildArgs = restoreMSBuildArgs.CloneWithVerbosity(verbosity);
}
Expand Down Expand Up @@ -175,7 +175,7 @@ private static bool HasPropertyToExcludeFromRestore(MSBuildArgs msbuildArgs)

private static readonly List<string> FlagsThatTriggerSilentSeparateRestore = [.. ComputeFlags(FlagsThatTriggerSilentRestore)];

private static readonly List<string> PropertiesToExcludeFromSeparateRestore = [ .. PropertiesToExcludeFromRestore ];
private static readonly List<string> PropertiesToExcludeFromSeparateRestore = [.. PropertiesToExcludeFromRestore];

/// <summary>
/// We investigate the arguments we're about to send to a separate restore call and filter out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static LaunchSettingsApplyResult TryApplyLaunchSettings(string launchSett
{
if (prop.Value.TryGetProperty(CommandNameKey, out var commandNameElement) && commandNameElement.ValueKind == JsonValueKind.String)
{
if (commandNameElement.GetString() is { } commandNameElementKey && _providers.ContainsKey(commandNameElementKey))
if (commandNameElement.GetString() is { } commandNameElementKey && _providers.ContainsKey(commandNameElementKey))
{
profileObject = prop.Value;
break;
Expand Down Expand Up @@ -120,7 +120,7 @@ public static LaunchSettingsApplyResult TryApplyLaunchSettings(string launchSett
}
}

private static bool TryLocateHandler(string? commandName, [NotNullWhen(true)]out ILaunchSettingsProvider? provider)
private static bool TryLocateHandler(string? commandName, [NotNullWhen(true)] out ILaunchSettingsProvider? provider)
{
if (commandName == null)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Cli/dotnet/Commands/Run/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -824,11 +824,11 @@ private void SendProjectBasedTelemetry(ProjectLaunchSettingsModel? launchSetting
{
Debug.Assert(ProjectFileFullPath != null);
var projectIdentifier = RunTelemetry.GetProjectBasedIdentifier(ProjectFileFullPath, GetRepositoryRoot(), Sha256Hasher.Hash);

// Get package and project reference counts for project-based apps
int packageReferenceCount = 0;
int projectReferenceCount = 0;

// Try to get project information for telemetry if we built the project
if (ShouldBuild)
{
Expand All @@ -837,10 +837,10 @@ private void SendProjectBasedTelemetry(ProjectLaunchSettingsModel? launchSetting
var globalProperties = MSBuildArgs.GlobalProperties?.ToDictionary() ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
globalProperties[Constants.EnableDefaultItems] = "false";
globalProperties[Constants.MSBuildExtensionsPath] = AppContext.BaseDirectory;

using var collection = new ProjectCollection(globalProperties: globalProperties);
var project = collection.LoadProject(ProjectFileFullPath).CreateProjectInstance();

packageReferenceCount = RunTelemetry.CountPackageReferences(project);
projectReferenceCount = RunTelemetry.CountProjectReferences(project);
}
Expand Down Expand Up @@ -869,10 +869,10 @@ private void SendProjectBasedTelemetry(ProjectLaunchSettingsModel? launchSetting
{
try
{
var currentDir = ProjectFileFullPath != null
var currentDir = ProjectFileFullPath != null
? Path.GetDirectoryName(ProjectFileFullPath)
: Directory.GetCurrentDirectory();

while (currentDir != null)
{
if (Directory.Exists(Path.Combine(currentDir, ".git")))
Expand All @@ -886,7 +886,7 @@ private void SendProjectBasedTelemetry(ProjectLaunchSettingsModel? launchSetting
{
// Ignore errors when trying to find repo root
}

return null;
}
}
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Run/RunTelemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,4 @@ private static bool IsDefaultProfile(string? profileName)
// The default profile name at this point is "(Default)"
return profileName.Equals("(Default)", StringComparison.OrdinalIgnoreCase);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public override int Execute()
{
ConvertToSlnxAsync(slnFileFullPath, slnxFileFullPath, CancellationToken.None).Wait();
return 0;
} catch (Exception ex) {
}
catch (Exception ex)
{
throw new GracefulException(ex.Message, ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private static async Task RemoveProjectsAsync(string solutionFileFullPath, IEnum
{
solution.RemoveFolder(folder);
// After removal, adjust index and continue to avoid skipping folders after removal
i--;
i--;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Store/StoreCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private StoreCommand(IEnumerable<string> msbuildArgs, string msbuildPath = null)

public static StoreCommand FromArgs(string[] args, string msbuildPath = null)
{
var result = Parser.Parse(["dotnet", "store", ..args]);
var result = Parser.Parse(["dotnet", "store", .. args]);
return FromParseResult(result, msbuildPath);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Concurrent;
using Microsoft.TemplateEngine.Cli.Help;
using System.Globalization;
using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis;
using Microsoft.Testing.Platform.OutputDevice.Terminal;
using Microsoft.DotNet.Cli.Commands.Test.IPC.Models;
using Microsoft.TemplateEngine.Cli.Help;
using Microsoft.Testing.Platform.OutputDevice.Terminal;

namespace Microsoft.DotNet.Cli.Commands.Test.Terminal;

Expand Down Expand Up @@ -801,7 +801,7 @@ void AppendOutputWhenPresent(string description, string? output)
private static void AppendAssemblySummary(TestProgressState assemblyRun, ITerminal terminal)
{
terminal.ResetColor();

AppendAssemblyLinkTargetFrameworkAndArchitecture(terminal, assemblyRun.Assembly, assemblyRun.TargetFramework, assemblyRun.Architecture);
terminal.Append(' ');
AppendAssemblyResult(terminal, assemblyRun);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private async Task Read(BuildOptions buildOptions, TestOptions testOptions, Term
{
result = ExitCode.GenericFailure;
}

lock (_lock)
{
if (_aggregateExitCode is null)
Expand Down
7 changes: 4 additions & 3 deletions src/Cli/dotnet/Commands/Test/VSTest/TestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static int ForwardToVSTestConsole(ParseResult parseResult, string[] args

public static TestCommand FromArgs(string[] args, string? testSessionCorrelationId = null, string? msbuildPath = null)
{
var parseResult = Parser.Parse(["dotnet", "test", ..args]);
var parseResult = Parser.Parse(["dotnet", "test", .. args]);

// settings parameters are after -- (including --), these should not be considered by the parser
string[] settings = [.. args.SkipWhile(a => a != "--")];
Expand Down Expand Up @@ -240,9 +240,10 @@ private static TestCommand FromParseResult(ParseResult result, string[] settings
}
}


Dictionary<string, string> variables = VSTestForwardingApp.GetVSTestRootVariables();
foreach (var (rootVariableName, rootValue) in variables) {
foreach (var (rootVariableName, rootValue) in variables)
{
testCommand.EnvironmentVariable(rootVariableName, rootValue);
VSTestTrace.SafeWriteTrace(() => $"Root variable set {rootVariableName}:{rootValue}");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Test/VSTest/VSTestForwardingApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public VSTestForwardingApp(IEnumerable<string> argsToForward)
WithEnvironmentVariable(rootVariableName, rootValue);
VSTestTrace.SafeWriteTrace(() => $"Root variable set {rootVariableName}:{rootValue}");
}

VSTestTrace.SafeWriteTrace(() => $"Forwarding to '{GetVSTestExePath()}' with args \"{argsToForward?.Aggregate((a, b) => $"{a} | {b}")}\"");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.CommandLine;
using Microsoft.DotNet.Cli.Commands.Tool.List;
using Microsoft.DotNet.Cli.Commands.Tool.Uninstall;
using Microsoft.DotNet.Cli.Commands.Tool.Update;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.NuGetPackageDownloader;
using Microsoft.DotNet.Cli.ShellShim;
using Microsoft.DotNet.Cli.ToolPackage;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Cli.Utils.Extensions;
using Microsoft.Extensions.EnvironmentAbstractions;
using NuGet.Common;
using NuGet.Frameworks;
using NuGet.Versioning;
using Microsoft.DotNet.Cli.Utils.Extensions;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.ShellShim;
using Microsoft.DotNet.Cli.Commands.Tool.Update;
using Microsoft.DotNet.Cli.Commands.Tool.Uninstall;
using Microsoft.DotNet.Cli.Commands.Tool.List;

namespace Microsoft.DotNet.Cli.Commands.Tool.Install;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override int Execute()
}
else
{
return ExecuteInstallCommand((PackageId) _packageId);
return ExecuteInstallCommand((PackageId)_packageId);
}
}

Expand Down
Loading
Loading