Skip to content

Nuget Exception while running Unit Testing example for Source Generator Testing #61432

@papafe

Description

@papafe

I was trying to setup my system to test source generators following the recommended approach (Solution A) in the roslyn cookbook . I have practically copy pasted the code, but I get the following exception when running the test:

NuGet.Protocol.Core.Types.FatalProtocolException : Unable to load the service index for source https://api.nuget.org/v3/index.json.
  ----> System.IO.FileLoadException : Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I am a little confused by this exception, as the source generator project has no reference to external packages, while the test project uses NewtonSoft.Json version 13.0.1. I also don't have issues with Nuget otherwise.

I have tried also the non-recommended approach (Solution B), and that works fine.

I'm using:
Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.NUnit (1.1.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions