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 is broken on sdk 7.0.200 if `EnforceCodeStyleInBuild` is set to `true` – Could not load file or assembly 'Microsoft.CodeAnalysis'

See original GitHub issue

step to reproduce

  • create new project
dotnet new console
  • add <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> to .csproj

  • add global.json

dotnet new globaljson
  • change sdk version in global.json to “7.0.103”
  • run
dotnet format

everything is ok here.

  • change sdk version in global.json to “7.0.200”
  • run
dotnet format

and now there are a lot of

Unhandled exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

in output

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Reactions:36
  • Comments:28 (7 by maintainers)

github_iconTop GitHub Comments

26reactions
MrcnPnkrskcommented, Apr 6, 2023

Is there any Road Map for fixing this issue?

.NET 7.0.4 is installed automatically with Visual Studio 2022 and for the past 4 months bundled dotnet-format is unusable. #1782 Seems to be forgotten.

17reactions
avideniccommented, Apr 14, 2023

This seems to be an issue on 7.0.202 and 7.0.203 as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not load file or assembly 'Microsoft.CodeAnalysis ...
Our build machine has the same VS/C# versions and its Ctrl+'.' still works fine. We never had DotNetCompilerPlatform in any of our projects' ......
Read more >
dotnet format command - .NET CLI
dotnet format is a code formatter that applies style preferences to a project or solution. Preferences will be read from an .editorconfig ...
Read more >
Code analysis in .NET
In this article ... .NET compiler platform (Roslyn) analyzers inspect your C# or Visual Basic code for code quality and style issues. Starting...
Read more >
Microsoft.Extensions.Logging.Generators.dll: Could not ...
0\analyzers\dotnet\roslyn4.0\cs\Microsoft.Extensions.Logging.Generators.dll: Could not load file or assembly 'Microsoft.CodeAnalysis, Version= ...
Read more >
Modern StyleCop alternative? Advice appreciated. : r/dotnet
We are needing to enforce some very basic style rules in a set of DotNet 6 projects. This is not something we have...
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