Is there a way with Roslyn to bundle all dependencies with the generated app

Viewed 110

I've recently started working with Roslyn for building apps at runtime.

After a few hours, I've finally managed to compile a working executable of a console application which only does:

Console.WriteLine("Hello World, Roslyn");

The main issue I've faced was how to add the reference to the System namespace. Finally I've used the following line, chained with the creation of the CSharpCompilation object:

.AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location))

It works perfectly but when I try and debug this, I found that:

typeof(object).Assembly.Location

returns:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll"

I am worried that this path may vary depending on the machine. Thus, I was wondering if there was a way to bundle all the dependencies next to the generated .exe? (like if you were to build a self-contained .Net Core app).

0 Answers
Related