-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET Core SDK 6.0.200: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0' #23972
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
I updated the bug description with steps to reproduce. |
We're also seeing this trying to build a .NET 6 Blazor app on a hosted agent using image 'windows-2022' (with image version '20220207.1'), and also using .NET SDK 6.0.200. It started happening as soon as the .NET SDK version moved to 6.0.200 (didn't happen on SDK 6.0.102). |
Same issue here. It happend on the build server, but not locally. For those also affected: The workaround from pmalmsten works: global.json: .yaml for the build pipelines: HIH |
I had the same problem with CS8032 warnings when building in Visual Studio 2022 17.0.6 using SDK 6.0.200. After upgrading to Visual Studio 2022 17.1.0, the CS8032 warnings disappeared. |
same here, omnisharp in vscode is broken on 6.0.200 with this exception. |
Same here, I'd blown away all my
repeated in the logs, since the docs say the package is unnecessary for SDK-style projects targeting .NET 5 and above. Seems like it's actually an OmniSharp issue as its release is lagging behind the SDK's release: dotnet/vscode-csharp#5061 (comment) |
This same issue is breaking dotnet-format: dotnet/format#1519 |
This definitely seems to be the issue with It would be great if there's another workaround other than downgrading the SDK version. I discovered this as my enterprise client's self-hosted CI has just supported .NET 6, specifically .NET 6.0.200. |
Same issue with SDK 6.0.101 (the one installed on AppVeyor...) |
I'm having the same issue with builds directly on build agents in Azure DevOps, but building locally using VS 17.1.0 works fine. I suspect when they update VS Build Task and binaries on the build image it'll go away, but that probably doesn't help those using VS Code or other build environments. |
Same problem on ubuntu-latest, after banging my head against the wall as I didn't understand why my pipelines were suddenly failing I found this post. |
This issue was fixed in OmniSharp v1.38.1 (2022-02-18) , but in VSCode Extension Marketplace latest available release is 1.24.0. Potentially latest omnisharp version can be installed manually from github build, but I hope, that latest release will be available for download in Marketplace soon. |
have fixed it in VS Code by adding below settings
|
VS2022 v17.0.5 was having this issue and upgrading to v17.1.0 fixed it. Thank you @El-Gor-do |
The upgrade from 17.0.0 to 17.1.0 also fixed it for me. I think this issue can be closed. |
I have 17.1.0 and am still hitting the issue. So I don't agree that it should be closed. |
This error can crop up on the CLI as well, it's not restricted to Visual Studio environments. So I agree with the above. Issue is not yet resolved. |
I use When I use |
A workaround is to add this to your csproj: <ItemGroup>
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers;</IncludeAssets>
</PackageReference>
</ItemGroup> |
I also experience this problem with the VS 2022 and SDK 6.0.201, updating to the latest version helped me though. |
upgrade from 17.0.0 to 17.1.4 also fixed it for me. |
I confirmed that the |
Closing as this seem to be fixed already. Thanks for confirmation, @andschwa |
I am experiencing this issue locally but with it not being able to load cc: @mkArtakMSFT |
This is definitely not fixed. Upgrading to 6.0.20+ just changes the error. |
For me, what worked was using the daily builds of the .NET 7 SDK and then manually switching it's analyzers to the latest stable releases of all of it's analyzers (except the source generators) and it ended up working fine after that. This is because the daily .NET 7 builds uses roslyn 4.3.0 preview builds. |
I hit this as well. When running from VS 17.2.1 with sdk 6.0.3, some of the NuGet packages do not get copied, when running dotnet build with global.json with 6.0.101 works. |
Cant another workaround for the compiler libraries in the IDE is to install an local build of them into the IDE (and then keep it up to date with their branch main)? It might possibly be risky but I think it could be another option as well. |
For those that are coming here and looking for answers: I could fix it by upgrading visual studio to 17.3.5 from 17.2.5 |
The exact upgrade that's needed is for the .NET SDK to be 6.0.202 or higher. |
Hitting same issue with .NET SDK 6.0.400 and 6.0.408. |
I have the same issue with Visual Studio 2022 Version 17.6.2 just for my project with target framework net6.0 : I have both dotnet 6.0.408, and 7.0.302 on my machine. |
Don't know if this helps any future readers at all, but a long time ago we installed the "Microsoft.CodeAnalysis.Compilers" and "Microsoft.Net.Compilers.Toolset" NuGet packages, as per the advice given in https://stackoverflow.com/a/71208208. Then it broke again, with the same symptom of the web log showing that views couldn't be found (they were not embedded any more).
Building the project in Azure DevOps then yielded a bus load of build warnings like this:
We were using the 4.6.0 version of those two NuGet packages. We then followed the advice of the updated answer of the aforementioned SO issue, that suggested to now remove those two NuGet packages again, as well as adding the following: After removing the two NuGet packages, our runtime problems disappeared, so something has been fixed somewhere, not requiring these packages to be referenced any more (which could only be a good thing, judging by the rather scary description of the "Microsoft.Net.Compilers.Toolset" NuGet package - go and look it up for fun...). We did NOT follow the advice of adding the framework reference, though, as that yields a build warning of its own:
That reference was nonetheless already visible in Visual Studio 2022's solution explorer, under "Dependencies | Frameworks" for the web project in question. |
An update to my previous findings related to removing the two "Microsoft.CodeAnalysis.Compilers" and "Microsoft.Net.Compilers.Toolset" NuGet packages; That led me to look at which tools were actually used to build in those two cases. The one that didn't work, on the other hand, was using the "Visual Studio build" task available to Azure DevOps pipelines. So, to conclude, the MSbuild tool actually seems to be the problem here, and you will need to use a new enough version of it. |
Even better, build msbuild and all the tools you need yourself for the absolute latest version. |
We experienced the same problems, for us, it started happening once the runner-images on the Azure pipeline agents were updated in August. We had several problems as we had NET 6 and NET 7 versions running side by side in different environments. As pointed out by @mgroetan the main problem is the combination of which version of MSBuild is used, the csproj configuration and the SDK. For NET 6 (using the SDK 6.0.410-413) For NET 7 (using the SDK 7.0.305)
Now Things are looking good again. |
I had the same issue when upgrading from SDK version 7.0.307 to SDK version 7.0.402. After upgrading, all views are missing in the DLL by building the project.
|
Describe the bug
Build fails with error:
##[error]CSC(0,0): Error CS8032: An instance of analyzer Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator cannot be created from C:\hostedtoolcache\windows\dotnet\sdk\6.0.200\Sdks\Microsoft.NET.Sdk.Razor\source-generators\Microsoft.NET.Sdk.Razor.SourceGenerators.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..
when using .NET Core SDK 6.0.200 with Visual Studio 2022 on Azure DevOps Microsoft-Hosted Agent.
Error goes away after reverting to .NET Core SDK 6.0.102.
I was unable to reproduce this on my personal Windows 11 machine using Visual Studio 2022 (with latest updates) and running a build command very similar to what Azure DevOps does:
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" "C:\Users\paulmalmsten\source\repos\Terrapin\PackageRebuilder.sln" /nologo /nr:false -m /p:configuration="debug" /p:VisualStudioVersion="17.0" /p:_MSDeployUserAgent="VSTS_011b8bdf-6d56-4f87-be0d-0092136884d9_build_11835_0"
Azure DevOps image version where this was observed: https://github.com/actions/virtual-environments/releases/tag/win22%2F20220207.1
To Reproduce
I was able to reproduce this issue on a template Web App project created by Visual Studio 2022 without modification.
Steps:
WebApplication1
directory below the git repository root), push to a branch in Azure Dev Ops.windows-2022
having the following steps:Expected Result: Compiles successfully.
Actual result: Error message seen above.
Exceptions (if any)
Not applicable.
Further technical details
dotnet --info
Not applicable. Error happens on Azure DevOps hosted agent.
The text was updated successfully, but these errors were encountered: