Search code examples
c#codedomcompiler-options

C# CodeDom Multiple CompilerOptions


I would like to add multiple CompilerOptions with CodeDom, but I cannot figure out how to do so.

What I am currently trying:

CompilerParameters cp = new CompilerParameters(referencedAssemblies, "executable file path", false);

cp.CompilerOptions = "/unsafe";
cp.CompilerOptions = "/t:winexe";

The issue is that only the latter of the two parameters is being incorporated into the output executable file. Is there some way to add CompilerOptions parameters as an array?

Thank you for any help,

Evan


Solution

  • Based on the usage I'm guessing you can do something like

    cp.CompilerOptions = "/unsafe /t:winexe";
    

    If you wanted to build that string up in an array you would just need to loop over the array that holds the compiler options and append them to a string. Then assign that string to cp.CompilerOptions

    MSDN http://msdn.microsoft.com/en-us/library/system.codedom.compiler.compilerparameters.compileroptions.aspx