Home > Net >  Missing "Microsoft.CodeAnalysis" in .net 3.1 install on Ubuntu
Missing "Microsoft.CodeAnalysis" in .net 3.1 install on Ubuntu

Time:11-17

I have a .net project that runs in windows with VS code with no issues.

I am trying to run the same project in Ubuntu 20.04.2 with VS code. Run trying to run it with F5, I get the errors:

CSC : error CS8032: An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from /home/one/.nuget/packages/system.text.json/6.0.6/analyzers/dotnet/roslyn3.11/cs/System.Text.Json.SourceGeneration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.11.0.0, Culture=neutral, PublicKeyToken=****'. The system cannot find the file specified.. [/home/one/github/fhir/Foo.Service/Foo.Service/Foo.Service.csproj]
CSC : error CS8032: An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from /home/one/.nuget/packages/system.text.json/6.0.6/analyzers/dotnet/roslyn4.0/cs/System.Text.Json.SourceGeneration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.11.0.0, Culture=neutral, PublicKeyToken=******'. The system cannot find the file specified.. [/home/one/github/fhir/Foo.Service/Foo.Service/Foo.Service.csproj]

I verified the files are on my system: roslyn3.11

% lr /home/one/.nuget/packages/system.text.json/6.0.6/analyzers/dotnet/roslyn3.11/cs/System.Text.Json.SourceGeneration.dll
-rwxrw-r-- 1 one one 148K Aug 19 19:48 /home/one/.nuget/packages/system.text.json/6.0.6/analyzers/dotnet/roslyn3.11/cs/System.Text.Json.SourceGeneration.dll

roslyn4.0

one@work ~
% lr /home/one/.nuget/packages/system.text.json/6.0.6/analyzers/dotnet/roslyn4.0/cs/System.Text.Json.SourceGeneration.dll
-rwxrw-r-- 1 one one 164K Aug 19 19:48 /home/one/.nuget/packages/system.text.json/6.0.6/analyzers/dotnet/roslyn4.0/cs/System.Text.Json.SourceGeneration.dll

csproj

one@work ~
% lr /home/one/github/fhir/Foo.Service/Foo.Service/Foo.Service.csproj
-rw-rw-r-- 1 one one 1.8K Nov 10 16:59 /home/one/github/fhir/Foo.Service/Foo.Service/Foo.Service.csproj

It looks like "Microsoft.CodeAnalysis" was missing. So, I installed it with nuget in VS code. I added 'nuget: add package' in VS code to install 'Microsoft.CodeAnalaysis' version 3.11.0. I have verified it successfully lives on my system:

one@work ...packages/microsoft.codeanalysis/3.11.0
% pwd
/home/one/.nuget/packages/microsoft.codeanalysis/3.11.0
one@work ...packages/microsoft.codeanalysis/3.11.0
% lr
total 80K
drwxrwxr-x 2 one one 4.0K Nov 14 10:08 .
drwxrwxr-x 4 one one 4.0K Nov 14 10:08 ..
-rw-rw-r-- 1 one one  178 Nov 14 10:08 .nupkg.metadata
-rwxrw-r-- 1 one one  19K Aug 10  2021 .signature.p7s
-rwxrw-r-- 1 one one 6.9K Apr 30  2021 Icon.png
-rwxrw-r-- 1 one one 2.2K Aug  3  2021 ThirdPartyNotices.rtf
-rw-rw-r-- 1 one one  28K Nov 14 10:08 microsoft.codeanalysis.3.11.0.nupkg
-rw-rw-r-- 1 one one   88 Nov 14 10:08 microsoft.codeanalysis.3.11.0.nupkg.sha512
-rwxrw-r-- 1 one one 2.4K Aug  3  2021 microsoft.codeanalysis.nuspec

I still get the errors mentioned above.

CodePudding user response:

Install the latest NuGet packages of:

Microsoft.CodeAnalysis.Compilers
Microsoft.Net.Compilers

This will fix the issue.

  • Related