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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Apply dotnet format - Thu Dec 11 22:23:23 UTC 2025
a02f341
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, BuildCommandParser.NoLogoOption);
var msbuildArgs = MSBuildArgs.AnalyzeMSBuildArguments([.. args], CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, BuildCommandParser.TargetOption, BuildCommandParser.VerbosityOption, BuildCommandParser.NoLogoOption);
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 @@ -13,7 +13,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
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#nullable disable

using System.CommandLine;
using Microsoft.DotNet.Cli.Commands.BuildServer.Shutdown;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.BuildServer.Shutdown;
using Microsoft.DotNet.Cli.Extensions;

namespace Microsoft.DotNet.Cli.Commands.BuildServer;
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, CleanCommandParser.NoLogoOption],
[CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, CleanCommandParser.TargetOption, CleanCommandParser.VerbosityOption, CleanCommandParser.NoLogoOption],
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
3 changes: 2 additions & 1 deletion src/Cli/dotnet/Commands/Fsi/FsiCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public static Command GetCommand()

private static Command ConstructCommand()
{
Command command = new("fsi") {
Command command = new("fsi")
{
Arguments = { Arguments },
DocsLink = DocsLink,
};
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Hidden/Add/AddCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.CommandLine;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.Hidden.Add.Package;
using Microsoft.DotNet.Cli.Commands.Hidden.Add.Reference;
using Microsoft.DotNet.Cli.Commands.Package;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Extensions;

namespace Microsoft.DotNet.Cli.Commands.Hidden.Add;
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
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Hidden/List/ListCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#nullable disable

using System.CommandLine;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.Hidden.List.Package;
using Microsoft.DotNet.Cli.Commands.Hidden.List.Reference;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.CommandLine;

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

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

using System.CommandLine;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.Hidden.Remove.Package;
using Microsoft.DotNet.Cli.Commands.Hidden.Remove.Reference;
using Microsoft.DotNet.Cli.Commands.Package;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Extensions;

namespace Microsoft.DotNet.Cli.Commands.Hidden.Remove;
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/MSBuild/MSBuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MSBuildCommand(
{
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
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/MSBuild/MSBuildLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Globalization;
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Pack/PackCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Package/Add/PackageAddCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.MSBuild;
using Microsoft.DotNet.Cli.Commands.NuGet;
using Microsoft.DotNet.Cli.Commands.Run;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.FileBasedPrograms;
Expand Down
6 changes: 3 additions & 3 deletions src/Cli/dotnet/Commands/Package/List/PackageListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#nullable disable

using System.CommandLine;
using System.Globalization;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.Hidden.List;
using Microsoft.DotNet.Cli.Commands.MSBuild;
using Microsoft.DotNet.Cli.Commands.NuGet;
using Microsoft.DotNet.Cli.CommandLine;
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
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Package/PackageCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.CommandLine;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.Package.Add;
using Microsoft.DotNet.Cli.Commands.Package.List;
using Microsoft.DotNet.Cli.Commands.Package.Remove;
using Microsoft.DotNet.Cli.Commands.Package.Search;
using Microsoft.DotNet.Cli.Commands.Run;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.Utils;
using Command = System.CommandLine.Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

using System.CommandLine;
using System.Diagnostics;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.NuGet;
using Microsoft.DotNet.Cli.Commands.Run;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.FileBasedPrograms;

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

#nullable disable

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

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 @@ -22,7 +22,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
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#nullable disable

using System.CommandLine;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.Reference.Add;
using Microsoft.DotNet.Cli.Commands.Reference.List;
using Microsoft.DotNet.Cli.Commands.Reference.Remove;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Extensions;

namespace Microsoft.DotNet.Cli.Commands.Reference;
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 @@ -118,13 +118,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 @@ -171,7 +171,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
16 changes: 8 additions & 8 deletions src/Cli/dotnet/Commands/Run/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public int Execute()

// Create a single logger for all MSBuild operations (device selection + build/run)
// File-based runs (.cs files) don't support device selection and should use the existing logger behavior
FacadeLogger? logger = ProjectFileFullPath is not null
FacadeLogger? logger = ProjectFileFullPath is not null
? LoggerUtility.DetermineBinlogger([.. MSBuildArgs.OtherMSBuildArgs], "dotnet-run")
: null;
try
Expand Down Expand Up @@ -241,7 +241,7 @@ private bool TrySelectTargetFrameworkAndDeviceIfNeeded(FacadeLogger? logger)
Debug.Assert(ProjectFileFullPath is not null);

var globalProperties = CommonRunHelpers.GetGlobalPropertiesFromArgs(MSBuildArgs);

// If user specified --device on command line, add it to global properties and MSBuildArgs
if (!string.IsNullOrWhiteSpace(Device))
{
Expand All @@ -255,7 +255,7 @@ private bool TrySelectTargetFrameworkAndDeviceIfNeeded(FacadeLogger? logger)
// we can skip both framework selection and device selection entirely
bool hasFramework = globalProperties.TryGetValue("TargetFramework", out var existingFramework) && !string.IsNullOrWhiteSpace(existingFramework);
bool hasDevice = globalProperties.TryGetValue("Device", out var preSpecifiedDevice) && !string.IsNullOrWhiteSpace(preSpecifiedDevice);

if (!ListDevices && hasFramework && hasDevice)
{
// Both framework and device are pre-specified, no need to create selector or logger
Expand All @@ -264,7 +264,7 @@ private bool TrySelectTargetFrameworkAndDeviceIfNeeded(FacadeLogger? logger)

// Create a single selector for both framework and device selection
using var selector = new RunCommandSelector(ProjectFileFullPath, globalProperties, Interactive, MSBuildArgs, logger);

// Step 1: Select target framework if needed
if (!selector.TrySelectTargetFramework(out string? selectedFramework))
{
Expand All @@ -274,7 +274,7 @@ private bool TrySelectTargetFrameworkAndDeviceIfNeeded(FacadeLogger? logger)
if (selectedFramework is not null)
{
ApplySelectedFramework(selectedFramework);

// Re-evaluate project with the selected framework so device selection sees the right devices
var properties = CommonRunHelpers.GetGlobalPropertiesFromArgs(MSBuildArgs);
selector.InvalidateGlobalProperties(properties);
Expand Down Expand Up @@ -331,7 +331,7 @@ private bool TrySelectTargetFrameworkForFileBasedProject()
Debug.Assert(EntryPointFileFullPath is not null);

var globalProperties = CommonRunHelpers.GetGlobalPropertiesFromArgs(MSBuildArgs);

// If a framework is already specified via --framework, no need to check
if (globalProperties.TryGetValue("TargetFramework", out var existingFramework) && !string.IsNullOrWhiteSpace(existingFramework))
{
Expand Down Expand Up @@ -363,10 +363,10 @@ private bool TrySelectTargetFrameworkForFileBasedProject()
{
var sourceFile = SourceFile.Load(sourceFilePath);
var directives = FileLevelDirectiveHelpers.FindDirectives(sourceFile, reportAllErrors: false, DiagnosticBag.Ignore());

var targetFrameworksDirective = directives.OfType<CSharpDirective.Property>()
.FirstOrDefault(p => string.Equals(p.Name, "TargetFrameworks", StringComparison.OrdinalIgnoreCase));

if (targetFrameworksDirective is null)
{
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/dotnet/Commands/Run/RunCommandSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal sealed class RunCommandSelector : IDisposable
private readonly FacadeLogger? _binaryLogger;
private readonly bool _isInteractive;
private readonly MSBuildArgs _msbuildArgs;

private ProjectCollection? _collection;
private Microsoft.Build.Evaluation.Project? _project;
private ProjectInstance? _projectInstance;
Expand Down Expand Up @@ -316,7 +316,7 @@ public bool TrySelectDevice(

// Try to get available devices from the project
bool targetExists = TryComputeAvailableDevices(noRestore, out var devices, out restoreWasPerformed);

// If the target doesn't exist, continue without device selection
if (!targetExists)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/dotnet/Commands/Sdk/SdkCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#nullable disable

using System.CommandLine;
using Microsoft.DotNet.Cli.Commands.Sdk.Check;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Commands.Sdk.Check;
using Microsoft.DotNet.Cli.Extensions;

namespace Microsoft.DotNet.Cli.Commands.Sdk;
Expand Down
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
Loading