Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling Portable Class Library at run-time

In the example below... instead of compiling for .Net "v4.0", what should be provided to compile a PCL library?

var compiler = new CSharpCodeProvider(new Dictionary<string, string>
{
   {"CompilerVersion", "v4.0"}
});
like image 412
user1413403 Avatar asked Nov 21 '13 23:11

user1413403


1 Answers

From this perspective a Portable Class Library is simply a library that is compiled against a set of portable reference assemblies, instead of the implementation or reference assemblies for a specific framework.

You can see the path to the PCL reference assemblies if you create a PCL in Visual Studio, select the ".NET Portable Subset" reference in solution explorer, and look at the Path property in the properties window. (The path will be different depending on what set of platforms you target in the PCL).

Set the references that the compiler will use to all the DLLs in the PCL reference path, and the result should be a portable library. If there are references that are included by default (ie mscorlib), then you will also need to disable them.

like image 97
Daniel Plaisted Avatar answered Oct 22 '22 12:10

Daniel Plaisted