Skip to content

dotnet format --binarylog format.binlog doesn't work on 10.0.100-preview.6.25358.103, 9.0.303/4 or 8.0.412/3 but works on 8.0.119 #50059

@Frulfump

Description

@Frulfump

Describe the bug

Trying to investigate #49910 and figured I would look at a binlog to see if that would give me any insights.
But the command fails to give me a binlog. EDIT: It works on 8.0.119 see #50059 (comment)
Seems it worked here at least #39124 (comment)

Also tried dotnet format --binarylog and dotnet format --binarylog . and the result is the same.

From dotnet format --help

--binarylog <binary-log-path> Log all project or solution load information to a binary log file.

Thought a similar approach to dotnet build -bl or dotnet build /bl would work but that just gives me this for either one

➜ dotnet format -bl
Unhandled exception: System.IO.FileNotFoundException: The file '-bl' does not appear to be a valid project or solution file.
at Microsoft.CodeAnalysis.Tools.Workspaces.MSBuildWorkspaceFinder.FindFile(String workspacePath)
at Microsoft.CodeAnalysis.Tools.Workspaces.MSBuildWorkspaceFinder.FindWorkspace(String searchDirectory, String workspacePath)
at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.ParseWorkspaceOptions(ParseResult parseResult, FormatOptions formatOptions)
at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

So tried dotnet format <project> -bl

➜ dotnet format .\FormatBinlogMissing.csproj -bl
'-bl' was not matched. Did you mean one of the following?
-h
-v

Unrecognized command or argument '-bl'.

➜ dotnet format .\FormatBinlogMissing.csproj /bl
'/bl' was not matched. Did you mean one of the following?
/h

Unrecognized command or argument '/bl'.

➜ dotnet new global.json --sdk-version 9.0.303
The template "global.json file" was created successfully.

➜ dotnet format --binarylog format.binlog
Unhandled exception: System.Exception: Restore operation failed.
at Microsoft.CodeAnalysis.Tools.CodeFormatter.OpenMSBuildWorkspaceAsync(String solutionOrProjectPath, WorkspaceType workspaceType, Boolean noRestore, Boolean requiresSemantics, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.CodeFormatter.FormatWorkspaceAsync(FormatOptions formatOptions, ILogger logger, CancellationToken cancellationToken, String binaryLogPath)
at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.FormatAsync(FormatOptions formatOptions, ILogger`1 logger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

(This should fail but for the reason of the TFM can't be net10.0 when using the .NET 9 SDK i.e NETSDK1045)
Edit the csproj, run format again no binlog produced.

➜ dotnet new global.json --sdk-version 8.0.412 --force
<Change TFM to net8.0>

➜ dotnet format --binarylog format.binlog

no binlog produced, which makes me think it's some system issue since it worked for Jared in February of 2024, not sure which SDK but guessing from the date could have been preview 1 of .NET 9 SDK or the latest .NET 8 at the time or a nightly I guess.

Also tried the case where a binlog had already been created with dotnet build /bl but it didn't update the existing binlog (compared last write time).

To Reproduce

In a new folder
dotnet new console
dotnet format --binarylog format.binlog
ls
<Check output of ls to see there's no binlog>
(I also used rg --files -g *.binlog in case I misunderstood where it would place the file, which uses ripgrep to search for files https://github.com/BurntSushi/ripgrep)

Exceptions (if any)

N/A

Further technical details

details of dotnet --info

.NET SDK: Version: 10.0.100-preview.6.25358.103 Commit: 75972a5ba7 Workload version: 10.0.100-manifests.6616851e MSBuild version: 17.15.0-preview-25358-103+75972a5ba

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100-preview.6.25358.103\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
Workloads are configured to install and update using workload versions, but none were found. Run "dotnet workload restore" to install a workload version.

Host:
Version: 10.0.0-preview.6.25358.103
Architecture: x64
Commit: 75972a5ba7

.NET SDKs installed:
8.0.412 [C:\Program Files\dotnet\sdk]
9.0.303 [C:\Program Files\dotnet\sdk]
10.0.100-preview.6.25358.103 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0-preview.6.25358.103 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0-preview.6.25358.103 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.0-preview.6.25358.103 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version

N/A

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions