Closed OoLunar closed 2 years ago
If you add the following to a .cs file, what version does the compiler report in the error message?
#error version
#error: 'version' [Tomoe] csharp(CS1029)
Compiler version: '4.2.0-1.22074.8 (979fa475)'. Language version: 10.0.
As a general comment, it may be useful for dotnet format
to print out its own version.
My apologies, I didn't realize dotnet format
had it's own repo. I'll remember next time.
Might be related to https://github.com/dotnet/format/issues/1519 and/or https://github.com/dotnet/format/issues/1433
You might also want to try the workaround proposed in https://github.com/dotnet/format/issues/1433#issuecomment-1055920818
Issue not fixed with https://github.com/dotnet/format/issues/1433#issuecomment-1055920818. Change .NET SDK to 6.0.100 fixed issue for GitHub Actions environment.
I'm also getting the ReflectionTypeLoadException - Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp' when running dotnet format
.
❯ dotnet format
Unhandled exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
...
❯ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.200
Commit: 4c30de7899
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.200\
Host (useful for support):
Version: 6.0.2
Commit: 839cdfb0ec
.NET SDKs installed:
2.2.401 [C:\Program Files\dotnet\sdk]
3.1.404 [C:\Program Files\dotnet\sdk]
5.0.101 [C:\Program Files\dotnet\sdk]
6.0.200 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
@OoLunar Can you use the Report a Problem feature of Visual Studio to submit a new issue here? In the Additional Attachments section, the item I'm looking for is a binlog, which you can collect by executing a command line build and passing the /bl
flag. This will produce an msbuild.binlog file.
Unfortunately I cannot do this as I'm on Linux and use Visual Studio Code. Are there any alternatives I can do?
Edit: I failed to read. Will attach the binlog in a moment
@OoLunar There is a fix coming in the next .NET 6 SDK release. In the meantime you can install dotnet format as a global tool to work around this issue (See https://github.com/dotnet/format/issues/1519#issuecomment-1055922333). Closing this issue as duplicate of https://github.com/dotnet/format/issues/1519
I am getting this issue but for 4.5.0.0 in .NET 7.0.202.
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
I got the same issue but (temporarily) resolved it by removing <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
from my .csproj
.
@jerohero that fixed it for me, thank you.
I got the same issue but (temporarily) resolved it by removing
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
from my.csproj
.
This also fixed the problem for me, though I'm not sure why. I don't understand why this would be a problem.
Just encountered the same issue with the .NET 7 SDK while running dotnet-format
in a GitHub Action workflow. Any comment from official side here?
Same situation here. Does not work in .NET 7.0:
`dotnet --info
.NET SDK: Version: 7.0.203 Commit: 5b005c19f5
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.203\
Host: Version: 7.0.5 Architecture: x64 Commit: 8042d61b17
.NET SDKs installed: 6.0.402 [C:\Program Files\dotnet\sdk] 6.0.408 [C:\Program Files\dotnet\sdk] 7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk] 7.0.203 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables: Not set
global.json file: C:\Users\manchax\source\repos\matrix\global.json
Learn more: https://aka.ms/dotnet/info
Download .NET: https://aka.ms/dotnet/download`
Same situation here. Does not work in .NET 7.0:
`dotnet --info
Version: 7.0.5 Architecture: x64 Commit: 8042d61b17
.NET SDKs installed: 7.0.203 [C:\Program Files\dotnet\sdk] 7.0.302 [C:\Program Files\dotnet\sdk]
@JoeRobich we have similar problem (just version is 4.6.0.0 instead of 4.1.0.0) on github actions with 7.0.302 version. Should this issue be reopened?
The fix for the current SDKs will be in the next servicing release of the SDKs. Sorry the infrastructure that updated the Roslyn version fell behind.
Same for me with .NET 7 SDK
We have the same issue in github actions.
The same commit yesterday had passed dotnet format --verify-no-changes
, but today it failed with
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.6.0.0, Culture=neutral, PublicKeyToken=31bf3[8](https://github.com/eToro/EtoroOps.Flows/actions/runs/5154865172/jobs/9284376141#step:6:9)56ad364e35'. The system cannot find the file specified.
+1 for the error @konstantinkos-tr is receiving. Same version(s)
Same problem as @konstantinkos-tr
Same here, with the same version.
Same problem as @konstantinkos-tr with same version
running into the same issue as @konstantinkos-tr with same version
For those running into this problem. The following worked for me. Use the dotnet-format
standalone tool instead of the one bundled into dotnet.
dotnet tool install -g dotnet-format --version "7.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json
Invoke with
dotnet-format
For other versions of dotnet (6, 8, etc). Change the version and source: ex:
dotnet tool install -g dotnet-format --version "6.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json
This was sufficient for me, you may need to look for a specific version of the tool if this doesn't work for you.
I switched to Rust and everything worked perfect since then.
On the topic: just wait or use LTS versions of .NET.
This seems to be broken again in v6.0.423.
This seems to be broken again in v6.0.423.
We start facing the same issue today after installing this NuGet Microsoft.Extensions.Telemetry.Abstractions" Version="8.0.0". We are using same version of the SDK v6.0.423.
This seems to be broken again in v6.0.423.
We start facing the same issue today after installing this NuGet Microsoft.Extensions.Telemetry.Abstractions" Version="8.0.0". We are using same version of the SDK v6.0.423.
We encounter the same issue after installing System.Diagnostics.DiagnosticSource
version 8.0.1
. The version of dotnet format is 5.1.250801
. We are running GitLab pipelines using the following base image: mcr.microsoft.com/dotnet/sdk:6.0
. The command executed is: dotnet format --verify-no-changes $DOTNET_WORKSPACE
.
Version Used: 6.0.2
Steps to Reproduce: Clone https://github.com/OoLunar/Tomoe/commit/f37434a797fa3c8906302989539b9400b1a3b851 on branch rewrite/DSP_3.0 (Apologies for the non-minimal repro, unsure on how to reproduce)
Expected Behavior: Successfully formatted
<x>
files.Actual Behavior:
Notes: Apologies for the non-minimal repro, as I'm not sure what's causing this in the first place. Additional apologies if this belongs in roslyn-analyzers instead of this repo. I didn't see anything related to
CAxxxx
, so I'm assuming this belongs here.