Skip to content
Draft
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 @@ -19,7 +19,12 @@ public static Command GetCommand()

private static Command ConstructCommand()
{
Command command = new("package", CliCommandStrings.PackageListAppFullName);
Command command = new("package", CliCommandStrings.PackageListAppFullName)
{
// Allow unmatched tokens to support binlog arguments (e.g., --bl, -bl:output.binlog)
// that are forwarded to the MSBuild restore phase
TreatUnmatchedTokensAsErrors = false
};

command.Options.Add(PackageListCommandParser.VerbosityOption);
command.Options.Add(PackageListCommandParser.OutdatedOption);
Expand Down
9 changes: 9 additions & 0 deletions src/Cli/dotnet/Commands/Package/List/PackageListCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ private int RunRestore(string projectOrSolution, ReportOutputFormat formatOption

args.Add($"-interactive:{interactive.ToString().ToLower()}");

// Forward any binlog arguments from the command line to the restore phase
foreach (var token in _parseResult.UnmatchedTokens)
{
if (LoggerUtility.IsBinLogArgument(token))
{
args.Add(token);
}
}

MSBuildForwardingApp restoringCommand = new MSBuildForwardingApp(rawMSBuildArgs: args);

int exitCode = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ public static Command GetCommand()

private static Command ConstructCommand()
{
Command command = new("list", CliCommandStrings.PackageListAppFullName);
Command command = new("list", CliCommandStrings.PackageListAppFullName)
{
// Allow unmatched tokens to support binlog arguments (e.g., --bl, -bl:output.binlog)
// that are forwarded to the MSBuild restore phase
TreatUnmatchedTokensAsErrors = false
};

command.Options.Add(VerbosityOption);
command.Options.Add(OutdatedOption);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,33 @@ public void ItRecognizesRelativePathsForASolutionFromSubFolder()
.Should()
.Pass();
}

[Fact]
public void ItAcceptsBinlogArgument()
{
var testAssetName = "TestAppSimple";
var testAsset = _testAssetsManager
.CopyTestAsset(testAssetName)
.WithSource();

var projectDirectory = testAsset.Path;
var binlogPath = Path.Combine(projectDirectory, "restore.binlog");

// Ensure no binlog exists initially
if (File.Exists(binlogPath))
{
File.Delete(binlogPath);
}

// Run list package with binlog argument (restore will run and create binlog)
new ListPackageCommand(Log)
.WithWorkingDirectory(projectDirectory)
.Execute("-bl:" + binlogPath)
.Should()
.Pass();

// Verify binlog was created
File.Exists(binlogPath).Should().BeTrue("binlog file should be created during restore");
}
}
}