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 issuestep 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:
- Created 7 months ago
- Reactions:36
- Comments:28 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
This seems to be an issue on 7.0.202 and 7.0.203 as well.