Skip to content

[dotnet-format] Include the .NET Framework buildhost executable in the SDK. #45290

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

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

JoeRobich
Copy link
Member

@JoeRobich JoeRobich commented Dec 3, 2024

This is necessary for dotnet-format to load .NET Framework projects.

Fixes #43017

This is necessary for dotnet-format to loading .NET Framework projects.
@Kielek
Copy link

Kielek commented Dec 4, 2024

Could you please ensure that the fix will be included also in next hotfix for .NET9 release?

@JoeRobich
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@JoeRobich JoeRobich merged commit 27c7378 into main Dec 4, 2024
119 checks passed
@JoeRobich JoeRobich deleted the dev/jorobich/fix-format-layout branch December 4, 2024 20:50
@JoeRobich
Copy link
Member Author

/backport to release/9.0.2xx

Copy link
Contributor

github-actions bot commented Dec 5, 2024

Started backporting to release/9.0.2xx: https://github.com/dotnet/sdk/actions/runs/12175899687

@epenet
Copy link

epenet commented May 14, 2025

Hi
I am targetting 8.0.x, and it looks like the release of 8.0.16 today has broken dotnet format.
It was working fine in 8.0.15

dotnet format whitespace  --verify-no-changes --verbosity diagnostic
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\0a0b64ad-06be-4bf5-a936-16ee200968a8.cmd""
  The dotnet runtime version is '8.0.16'.
  The dotnet CLI version is '8.0.409'.
  Using MSBuild.exe located in 'C:\hostedtoolcache\windows/dotnet\sdk\8.0.409\'.
  Formatting code files in workspace 'D:\a\1\s\xxx.sln'.
  Loading workspace.
Unhandled exception: System.Exception: The build host could not be found at 'C:\hostedtoolcache\windows\dotnet\sdk\8.0.409\DotnetTools\dotnet-format\BuildHost-net472\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.exe'
   at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.AssertBuildHostExists(String buildHostPath)
   at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetDotNetFrameworkBuildHostPath()
   at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.CreateDotNetFrameworkBuildHostStartInfo()
   at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostAsync(BuildHostProcessKind buildHostKind, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostWithFallbackAsync(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadProjectFileInfosAsync(String projectPath, DiagnosticReportingOptions reportingOptions, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadProjectInfosFromPathAsync(String projectPath, DiagnosticReportingOptions reportingOptions, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadAsync(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadSolutionInfoAsync(String solutionFilePath, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadSolutionInfoAsync(String solutionFilePath, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.OpenSolutionAsync(String solutionFilePath, ILogger msbuildLogger, IProgress`1 progress, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Tools.Workspaces.MSBuildWorkspaceLoader.LoadAsync(String solutionOrProjectPath, WorkspaceType workspaceType, String binaryLogPath, Boolean logWorkspaceWarnings, ILogger logger, CancellationToken cancellationToken)
   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.FormatWhitespaceCommand.FormatWhitespaceHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
   at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

@JoeRobich
Copy link
Member Author

/backport to release/8.0.4xx

Copy link
Contributor

Started backporting to release/8.0.4xx: https://github.com/dotnet/sdk/actions/runs/15032948879

Copy link
Contributor

@JoeRobich backporting to "release/8.0.4xx" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Include the .NET Framework buildhost executable in the SDK.
Using index info to reconstruct a base tree...
M	src/Layout/redist/targets/GenerateLayout.targets
Falling back to patching base and 3-way merge...
Auto-merging src/Layout/redist/targets/GenerateLayout.targets
CONFLICT (content): Merge conflict in src/Layout/redist/targets/GenerateLayout.targets
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Include the .NET Framework buildhost executable in the SDK.
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

JoeRobich added a commit that referenced this pull request May 14, 2025
This is necessary for dotnet-format to load .NET Framework projects.

Fixes #43017

Backport of #45290 to release/8.0.4xx
JoeRobich added a commit that referenced this pull request May 14, 2025
This is necessary for dotnet-format to load .NET Framework projects.

Fixes #43017

Backport of #45290 to release/8.0.4xx
@JoeRobich
Copy link
Member Author

@epenet I opened a backport at #48969. Will see if it meets the servicing bar.

@arunchndr
Copy link
Member

@marcpopMSFT fyi. We would like to bring this for approval in next tactics.

@marcpopMSFT
Copy link
Member

@arunchndr please fill out the template in 48969 and send mail to the tactics alias tomorrow. They want to start building for June before the next tactics meeting. There might be rebuilds next week but they start early to get testing going early.

BTW, we support the /backport command in this repo so ya'll can use that next time you backport if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Format untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotnet format style fails when requiring .NET Framework Build Host exe
5 participants