question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dotnet format cannot find MSBuild on SDK 7.0.101

See original GitHub issue

It fails with the error message Unable to locate MSBuild. Ensure the .NET SDK was installed with the official installer..

Steps to reproduce:

> docker run --rm -it mcr.microsoft.com/dotnet/sdk:7.0.101-alpine3.17 sh
/ # mkdir /tmp/test
/ # cd /tmp/test
/tmp/test # dotnet new console
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring /tmp/test/test.csproj:
  Determining projects to restore...
  Restored /tmp/test/test.csproj (in 83 ms).
Restore succeeded.


/tmp/test # dotnet format
Unable to locate MSBuild. Ensure the .NET SDK was installed with the official installer.

Output of dotnet format --version: 7.0.352902+f7beff0efdb20b8f22516d310279204a3fa9ef50

Issue Analytics

  • State:open
  • Created 9 months ago
  • Reactions:8
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
badsyntaxcommented, Feb 16, 2023

@craigktreasure i’ve tried with 7.0.103 and it results in the same problem 😦 it would be great to get some feedback from the dotnet devs, do we know they’re even aware of this issue?

2reactions
jnoordsijcommented, Feb 22, 2023

Still an issue on the 8.0-preview image as well:

> docker run --rm -it mcr.microsoft.com/dotnet/sdk:8.0-preview-alpine3.17 sh -c "mkdir /tmp/test && cd /tmp/test && dotnet new console && dotnet format"
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring /tmp/test/test.csproj:
  Determining projects to restore...
  Restored /tmp/test/test.csproj (in 62 ms).
Restore succeeded.


Unable to locate MSBuild. Ensure the .NET SDK was installed with the official installer.

Note that 7.0.200 has no Docker image published yet (see https://github.com/dotnet/dotnet-docker/discussions/4434), so can’t test behavior for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet format fails to locate msbuild · Issue #27332
Running dotnet format on a recent build from main fails with Unable to locate MSBuild. Ensure the .NET SDK was installed with the...
Read more >
NETSDK1045: The current .NET SDK does not support ...
This error occurs when the build tools can't find the version of the .NET SDK that's needed to build a project. This is...
Read more >
The SDK 'Microsoft.NET.Sdk' specified could not be found - ...
The compiler can not find the SDK. You need it installed togeher with the Compiler to make a build. Ideally you picked the...
Read more >
Net Core/MSBuild Tooling not finding right version
Error : Version 3.1.401 of the .NET Core SDK requires at least version 16.7.0 of MSBuild. The current available version of MSBuild is...
Read more >
Support for .NET SDK 7
I was able to resolve the issue "The current .NET SDK does not support targeting .NET 7.0". I don't know if this is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found