Roslyn version 1.2. * has a function called MetadataReference.CreateAssemblyReference()
, which takes the display name of the assembly and returns the corresponding MetadataReference
object. For example, I was able to add a link to various assemblies as follows:
Compilation compilation = Compilation.Create("HelloWorld") .AddReferences(MetadataReference.CreateAssemblyReference("mscorlib"), MetadataReference.CreateAssemblyReference("System.Linq"), MetadataReference.CreateAssemblyReference("System.Data.Linq"), MetadataReference.CreateAssemblyReference("System.Data"), MetadataReference.CreateAssemblyReference("System.Data.DataSetExtensions"), MetadataReference.CreateAssemblyReference("System.Xml"), MetadataReference.CreateAssemblyReference("System.Xml.Linq"), MetadataReference.CreateAssemblyReference("System"), MetadataReference.CreateAssemblyReference("System.Core") //MetadataReference.CreateAssemblyReference("System.Core"), /*MetadataReference.CreateAssemblyReference("System")*/) .AddSyntaxTrees(tree);
This, however, is not possible with the Microsoft.CodeAnalysis package (this is the last package that can be installed from Nuget). This package has several functions inside the MetadataReference
- but they require either assembly or a file path.
Does the simpler function described above exist in new compiler packages?
source share