Closed mortenbock closed 6 months ago
Although you can install dotnet-format as a global tool, I would recommend using the dotnet-format shipped with the SDK. It is not necessary to try and match dotnet-format version to the TargetFramework version, especially as the older versions are not getting updated with newer compiler dependencies. In this case, the older 6.x package is not shipping with a version of Roslyn new enough to run the analyzers in your project.
So the recommended approach is to use the v7/8 sdk to compile/format/build a v6 project?
Yes, newer SDKs retain their ability to build projects which target earlier frameworks. They ship with newer versions of the compiler and will provide you with the broadest project support and latest language features.
I have a similar problem as soon as I update Roslynator.Analyzers package from 4.6.2 to 4.6.3 or 4.7.0. Error message for me is
File name: 'Microsoft.CodeAnalysis.Workspaces, Version=4.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.CodeAnalysis.Workspaces, Version=4.6.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)
I am using Fedora 39 and dotnet info output is
$ dotnet --info
.NET SDK:
Version: 7.0.113
Commit: e24ee34c8e
Runtime Environment:
OS Name: fedora
OS Version: 39
OS Platform: Linux
RID: fedora.39-x64
Base Path: /usr/lib64/dotnet/sdk/7.0.113/
Host:
Version: 7.0.13
Architecture: x64
Commit: 3f73a2f186
.NET SDKs installed:
6.0.100 [/usr/lib64/dotnet/sdk]
6.0.124 [/usr/lib64/dotnet/sdk]
7.0.113 [/usr/lib64/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.24 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.13 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.0 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.24 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.13 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
DOTNET_ROOT [/usr/lib64/dotnet]
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
@Kampfmoehre The 7.0.1xx SDK ships with Roslyn 4.4.0. You will need to install a newer version of the SDK to get an updated dotnet-format that is compatible with those versions of Roslynator.
Fixed by #1885
My project file has:
I've installed the dotnet-format tool for v6 using this command:
When executing the command I first build the project, and then run
This works well, until I install this package:
Then I get this exception:
According to nuget, the package should be compatible with .net6
Why would this be happening?