Skip to content

allow targetting a specific sdk version when running dotnet format command #2233

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

Closed
lahsrah opened this issue Mar 5, 2025 · 0 comments
Closed

Comments

@lahsrah
Copy link

lahsrah commented Mar 5, 2025

dotnet format command is broken in 9.0.200 that was installed by Visual Studio and no update is available as of now. dotnet/sdk#46780

I want to be able to run dotnet format command that is part of 8.x.x but it doesn't seem possible. I tried using a global.json file to pin .net 8 to my project but format command still uses 9.0.200 on my machine.

global.json to pin dotnet 8 to my project

{
  "sdk": {
    "version": "8.0.406",
    "rollForward": "latestFeature"
  }
}

SDKs installed on my machine:

> dotnet --list-sdks
8.0.406 [C:\Program Files\dotnet\sdk]
9.0.200 [C:\Program Files\dotnet\sdk]

SDK dotnet command uses after pinning via global.json

> dotnet --version
8.0.406 [C:\Program Files\dotnet\sdk]

dotnet build respects pinned version

> dotnet build -v d
Build started 5/03/2025 5:35:58 PM.
     0>Process = "C:\Program Files\dotnet\dotnet.exe"
     MSBuild executable path = "C:\Program Files\dotnet\sdk\8.0.406\MSBuild.dll"
     ...

dotnet format does not respect pinned version

> dotnet format -v d
  The dotnet runtime version is '9.0.2'.
  Formatting code files in workspace 'C:\Data\Code\demo-project\demo-project.csproj'.
@lahsrah lahsrah closed this as completed Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant