Udostępnij za pośrednictwem


/target (C# Compiler Options)

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

Unless you specify /target:module, /target causes a .NET Framework assembly manifest to be placed in an output file. For more information, see Assemblies in the Common Language Runtime and Common 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. No matter what the first output file is (/target:exe, /target:winexe, /target:library or /target:module), 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 CLSCompliantAttribute attribute.

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

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

For more information about setting this compiler option programmatically, see OutputType.

See Also

Other Resources

C# Compiler Options

Project Properties (Visual Studio)