I have been trying to use Roslyn to parse a solution file and programmatically add a custom assembly reference to each project in the solution.
I tried using the following code snippet to do the same:
//The name of the DLL is customLib.dll
var reference = MetadataReference.CreateAssemblyReference("customLib");
project = project.AddMetadataReference(reference);
However, it encounters a FileNotFoundException while creating the MetadataReference.
So, my question is : How do I specify the path at which Roslyn needs to check for the specified dll?
Thanks.
MetadataReference.CreateAssemblyReference
is used to get references to assemblies in the GAC. Try this:
project = project.AddMetadataReference(new MetadataFileReference("<path>"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With