Export (0) Print
Expand All

/target (Specify Output File Format)

The /target compiler option can be specified in one of four forms:

/target:exe
Create an .exe file.
/target:library
Create a code library.
/target:module
Create a module.
/target:winexe
Create a Windows program.

Unless you specify /target:module, /target causes a .NET Framework assembly manifest to be placed in an output file. See Global Attributes for information on how to specify assembly attributes.

The assembly manifest is placed in the first .exe output file in the compilation or in the first .dll, if there is no .exe output file. For example, in the following command line, the manifest will be placed in 1.exe:

csc /out:1.exe t1.cs /out:2.netmodule t2.cs

The compiler creates only one assembly manifest per compilation. Information about all files in a compilation is placed in the assembly manifest. All output files except those created with /target:module can contain an assembly manifest. When producing multiple output files at the command line, only one assembly manifest can be created and it must go into the first output file specified on the command line. If the first output file is an exe (/target:exe or /target:winexe) or code library (/target:library), then any other output files produced in the same compilation must be modules (/target:module).

If you create an assembly, you can indicate that all or part of your code is CLS compliant with the CLSCompliant attribute.

// target_clscompliant.cs
[assembly:System.CLSCompliant(true)]   // specify assembly compliance

[System.CLSCompliant(false)]   // specify compliance for an element
class TestClass
{   
   public static void Main()
   {
   }
}

To set this compiler option programmatically

See OutputType Property.

See Also

C# Compiler Options

Show:
© 2014 Microsoft