Dotnet format fails with EnforceCodeStyleInBuild enabled in 7.0.200
See original GitHub issueDescribe the bug
When running dotnet format
with .NET SDK 7.0.200 and EnforceCodeStyleInBuild, I get an error of Microsoft.CodeAnalysis 4.5.0.0 not being found. This works however on .NET SDK 7.0.103. It looks like the version of the Microsoft.CodeAnalysis within dotnet-format is incorrect (shipped with 4.4.0 while the SDK is expected 4.5.0), and additionally 4.5.0 is yet to be released on nuget.
To Reproduce
A new project with the csproj modified to have the property <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
. Here is a sample:
Exceptions (if any)
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
at Microsoft.CodeAnalysis.DefaultAnalyzerAssemblyLoader.DirectoryLoadContext.Load(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
Further technical details
.NET SDK: Version: 7.0.200 Commit: 534117727b
Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.200\
Host: Version: 7.0.3 Architecture: x64 Commit: 0a2bda10e8
.NET SDKs installed: 7.0.101 [C:\Program Files\dotnet\sdk] 7.0.102 [C:\Program Files\dotnet\sdk] 7.0.103 [C:\Program Files\dotnet\sdk] 7.0.200 [C:\Program Files\dotnet\sdk]
Issue Analytics
- State:
- Created 7 months ago
- Reactions:25
- Comments:7 (1 by maintainers)
Top GitHub Comments
I’m also stuck at 7.0.103 at the moment. Installing Microsoft.CodeAnalysis.CSharp v4.5.0.0 in every project is not a valid solution. At 7.0.103 dotnet format works without that.
See: