1

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.

dman
  • 10,406
  • 18
  • 102
  • 201
  • 1
    The path to `System.Text.Json.SourceGeneration.dll` you've posted in your `lr` command is different to the one posted in the error. In the error, the path is /roslyn3.11/, in the `lr` command it's `/roslyn4.0/`. – madmonk46 Nov 14 '22 at 08:50
  • Thank you for catching that, I cut and pasted the wrong output. I updated the post with the corrected output where it shows roslyn3.11 that lives and exists on my system. So, the issue is still here if you know what could be wrong, please. – dman Nov 14 '22 at 14:18
  • 2
    The assembly "Microsoft.CodeAnalysis" is the thing missing; the analyzer `System.Text.Json.SourceGeneration.JsonSourceGenerator` requires that assembly and can't find it. Looks a lot like [Why can't Microsoft analyzers find Microsoft.CodeAnalysis?](https://stackoverflow.com/q/54370683/215552) – Heretic Monkey Nov 14 '22 at 14:23
  • Thank you for that link. It seems to target windows.... how could I trouble a missing "Microsoft.CodeAnalysis" in Ubuntu? – dman Nov 14 '22 at 15:12
  • You should be able to install/uninstall packages and that's not platform-specific, does [the accepted answer to that question](https://stackoverflow.com/a/54408041/9796331) not work for you in vscode? – madmonk46 Nov 14 '22 at 15:44
  • No, it did not work for me. I used 'nuget: add package' in VS code to install 'Microsoft.CodeAnalaysis' version 3.11.0. I have no way to verify, but I assume it installed successfully. I still get the errors mentioned above in the original post. – dman Nov 14 '22 at 16:13

0 Answers0