Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions docs/csharp/language-reference/compiler-options/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ helpviewer_keywords:
- "ChecksumAlgorithm compiler option [C#]"
- "CodePage compiler option [C#]"
- "Utf8Output compiler option [C#]"
- "MainEntryPoint compiler option [C#]"
- "StartupObject compiler option [C#]"
- "GenerateFullPaths compiler option [C#]"
- "FileAlignment compiler option [C#]"
- "PathMap compiler option [C#]"
Expand All @@ -27,7 +27,7 @@ helpviewer_keywords:

The following options support advanced scenarios. The new MSBuild syntax is shown in **Bold**. The older `csc.exe` syntax is shown in `code style`.

- **MainEntryPoint**, **StartupObject** / `-main`: Specify the type that contains the entry point.
- **StartupObject** / `-main`: Specify the type that contains the entry point.
- **PdbFile** / `-pdb`: Specify debug information file name.
- **PathMap** / `-pathmap`: Specify a mapping for source path names output by the compiler.
- **ApplicationConfiguration** / `-appconfig`: Specify an application configuration file containing assembly binding settings.
Expand All @@ -54,21 +54,15 @@ You add any of these options in a `<PropertyGroup>` element in your `*.csproj` f
</PropertyGroup>
``````

## MainEntryPoint or StartupObject
## StartupObject

This option specifies the class that contains the entry point to the program, if more than one class contains a `Main` method.

```xml
<StartupObject>MyNamespace.Program</StartupObject>
```

or

```xml
<MainEntryPoint>MyNamespace.Program</MainEntryPoint>
```

Where `Program` is the type that contains the `Main` method. The provided class name must be fully qualified; it must include the full namespace containing the class, followed by the class name. For example, when the `Main` method is located inside the `Program` class in the `MyApplication.Core` namespace, the compiler option has to be `-main:MyApplication.Core.Program`. If your compilation includes more than one type with a [`Main`](../../fundamentals/program-structure/main-command-line.md) method, you can specify which type contains the `Main` method.
Where `Program` is the type that contains the `Main` method. The class name can be either fully qualified (including the namespace) or just the class name if it's unambiguous. For example, when the `Main` method is located inside the `Program` class in the `MyApplication.Core` namespace, you can specify either `-main:MyApplication.Core.Program` or just `-main:Program` if there's no ambiguity. If your compilation includes more than one type with a [`Main`](../../fundamentals/program-structure/main-command-line.md) method, you can specify which type contains the `Main` method.

> [!NOTE]
> This option can't be used for a project that includes [top-level statements](../../fundamentals/program-structure/top-level-statements.md), even if that project contains one or more `Main` methods.
Expand Down Expand Up @@ -245,7 +239,7 @@ Use this option if you want to define or create your own System namespace and ob
Specifies the minimum version of the subsystem on which the executable file runs. Most commonly, this option ensures that the executable file can use security features that aren’t available with older versions of Windows.

> [!NOTE]
> To specify the subsystem itself, use the [**TargetType**](./output.md#targettype) compiler option.
> To specify the subsystem itself, use the [**OutputType**](./output.md#outputtype) compiler option.

```xml
<SubsystemVersion>major.minor</SubsystemVersion>
Expand All @@ -266,9 +260,9 @@ The following table lists common subsystem versions of Windows.
The default value of the **SubsystemVersion** compiler option depends on the conditions in the following list:

- The default value is 6.02 if any compiler option in the following list is set:
- [-target:appcontainerexe](output.md)
- [-target:winmdobj](output.md)
- [-platform:arm](output.md)
- [-target:appcontainerexe](output.md#outputtype)
- [-target:winmdobj](output.md#outputtype)
- [-platform:arm](output.md#platformtarget)
- The default value is 6.00 if you're using MSBuild, you're targeting .NET Framework 4.5, and you haven't set any of the compiler options that were specified earlier in this list.
- The default value is 4.00 if none of the previous conditions are true.

Expand All @@ -286,7 +280,7 @@ Specifies the name of an assembly whose nonpublic types a *.netmodule* can acces
- You know the name of the assembly into which the .netmodule will be built.
- The existing assembly has granted friend assembly access to the assembly into which the .*netmodule* will be built.

For more information on building a .netmodule, see [**TargetType**](output.md#targettype) option of **module**. For more information on friend assemblies, see [Friend Assemblies](../../../standard/assembly/friend.md).
For more information on building a .netmodule, see [**OutputType**](output.md#outputtype) option of **module**. For more information on friend assemblies, see [Friend Assemblies](../../../standard/assembly/friend.md).

## ReportIVTs

Expand Down
6 changes: 3 additions & 3 deletions docs/csharp/language-reference/compiler-options/inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ In the previous example, `LS` is the valid C# identifier that represents a root

## AddModules

This option adds a module that was created with the `<TargetType>module</TargetType>` switch to the current compilation:
This option adds a module that was created with the `<OutputType>module</OutputType>` switch to the current compilation:

```xml
<AddModule Include=file1 />
<AddModule Include=file2 />
```

Where `file`, `file2` are output files that contain metadata. The file can't contain an assembly manifest. To import more than one file, separate file names with either a comma or a semicolon. All modules added with **AddModules** must be in the same directory as the output file at run time. That is, you can specify a module in any directory at compile time but the module must be in the application directory at run time. If the module isn't in the application directory at run time, you'll get a <xref:System.TypeLoadException>. `file` can't contain an assembly. For example, if the output file was created with [**TargetType**](output.md#targettype) option of **module**, its metadata can be imported with **AddModules**.
Where `file`, `file2` are output files that contain metadata. The file can't contain an assembly manifest. To import more than one file, separate file names with either a comma or a semicolon. All modules added with **AddModules** must be in the same directory as the output file at run time. That is, you can specify a module in any directory at compile time but the module must be in the application directory at run time. If the module isn't in the application directory at run time, you'll get a <xref:System.TypeLoadException>. `file` can't contain an assembly. For example, if the output file was created with [**OutputType**](output.md#outputtype) option of **module**, its metadata can be imported with **AddModules**.

If the output file was created with a [**TargetType**](output.md#targettype) option other than **module**, its metadata cannot be imported with **AddModules** but can be imported with the [**References**](#references) option.
If the output file was created with a [**OutputType**](output.md#outputtype) option other than **module**, its metadata cannot be imported with **AddModules** but can be imported with the [**References**](#references) option.

## EmbedInteropTypes

Expand Down
19 changes: 10 additions & 9 deletions docs/csharp/language-reference/compiler-options/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ helpviewer_keywords:
- "OutputAssembly compiler option [C#]"
- "PlatformTarget compiler option [C#]"
- "ProduceReferenceAssembly compiler option [C#]"
- "TargetType compiler option [C#]"
- "OutputType compiler option [C#]"
---
# C# Compiler Options that control compiler output

Expand All @@ -21,7 +21,7 @@ The following options control compiler output generation.
| **OutputAssembly** | `-out:` | Specify the output assembly file. |
| **PlatformTarget** | `-platform:` | Specify the target platform CPU. |
| **ProduceReferenceAssembly** | `-refout:` | Generate a reference assembly. |
| **TargetType** | `-target:` | Specify the type of the output assembly. |
| **OutputType** | `-target:` | Specify the type of the output assembly. |

> [!NOTE]
> Refer to [Compiler options](index.md#how-to-set-options) for more information on configuring these options for your project.
Expand All @@ -34,7 +34,7 @@ The **DocumentationFile** option allows you to place documentation comments in a
<DocumentationFile>path/to/file.xml</DocumentationFile>
```

The source code file that contains Main or top-level statements is output first into the XML. You'll often want to use the generated .xml file with [IntelliSense](/visualstudio/ide/using-intellisense). The *.xml* filename must be the same as the assembly name. The *.xml* file must be in the same directory as the assembly. When the assembly is referenced in a Visual Studio project, the *.xml* file is found as well. For more information about generating code comments, see [Supplying Code Comments](/visualstudio/ide/reference/generate-xml-documentation-comments). Unless you compile with [`<TargetType:Module>`](#targettype), `file` will contain `<assembly>` and `</assembly>` tags specifying the name of the file containing the assembly manifest for the output file. For examples, see [How to use the XML documentation features](../xmldoc/index.md).
The source code file that contains Main or top-level statements is output first into the XML. You'll often want to use the generated .xml file with [IntelliSense](/visualstudio/ide/using-intellisense). The *.xml* filename must be the same as the assembly name. The *.xml* file must be in the same directory as the assembly. When the assembly is referenced in a Visual Studio project, the *.xml* file is found as well. For more information about generating code comments, see [Supplying Code Comments](/visualstudio/ide/reference/generate-xml-documentation-comments). Unless you compile with [`<OutputType:module>`](#outputtype), `file` will contain `<assembly>` and `</assembly>` tags specifying the name of the file containing the assembly manifest for the output file. For examples, see [How to use the XML documentation features](../xmldoc/index.md).

> [!NOTE]
> The **DocumentationFile** option applies to all files in the project. To disable warnings related to documentation comments for a specific file or section of code, use [#pragma warning](../preprocessor-directives.md#pragma-warning).
Expand All @@ -43,13 +43,14 @@ This option can be used in any .NET SDK-style project. For more information, see

## OutputAssembly

The **OutputAssembly** option specifies the name of the output file. The output path specifies the folder where compiler output is placed.
The **OutputAssembly** option specifies the name of the output file. This option corresponds to the combination of the `OutputPath` and `AssemblyName` MSBuild properties that control where the compiled assembly is placed and what it's named.

```xml
<OutputAssembly>folder</OutputAssembly>
<OutputPath>bin\Debug\</OutputPath>
<AssemblyName>MyApplication</AssemblyName>
```

Specify the full name and extension of the file you want to create. If you don't specify the name of the output file, MSBuild uses the name of the project to specify the name of the output assembly. Old style projects use the following rules:
Specify the name and extension of the file you want to create. The path can be relative or absolute. If you don't specify the name of the output file, MSBuild uses the project name to specify the name of the output assembly. Old style projects use the following rules:

- An .exe will take its name from the source code file that contains the `Main` method or top-level statements.
- A .dll or .netmodule will take its name from the first source code file.
Expand Down Expand Up @@ -103,9 +104,9 @@ You generally don't need to work directly with reference assembly files. By defa

.NET SDK 6.0.200 made a [change](../../../core/compatibility/sdk/6.0/write-reference-assemblies-to-obj.md) that moved reference assemblies from the output directory to the intermediate directory by default.

## TargetType
## OutputType

The **TargetType** compiler option can be specified in one of the following forms:
The **OutputType** compiler option can be specified in one of the following forms:

- **library**: to create a code library. **library** is the default value.
- **exe**: to create an .exe file.
Expand All @@ -118,7 +119,7 @@ The **TargetType** compiler option can be specified in one of the following form
> For .NET Framework targets, unless you specify **module**, this option causes a .NET Framework assembly manifest to be placed in an output file. For more information, see [Assemblies in .NET](../../../standard/assembly/index.md) and [Common Attributes](../attributes/global.md).

```xml
<TargetType>library</TargetType>
<OutputType>library</OutputType>
```

The compiler creates only one assembly manifest per compilation. Information about all files in a compilation is placed in the 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.
Expand Down
4 changes: 2 additions & 2 deletions docs/csharp/language-reference/compiler-options/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Specifies the filename containing the cryptographic key.
<KeyFile>filename</KeyFile>
```

`file` is the name of the file containing the strong name key. When this option is used, the compiler inserts the public key from the specified file into the assembly manifest and then signs the final assembly with the private key. To generate a key file, type `sn -k file` at the command line. If you compile with [**-target:module**](output.md#targettype), the name of the key file is held in the module and incorporated into the assembly created when you compile an assembly with [**AddModules**](inputs.md#addmodules). You can also pass your encryption information to the compiler with [**KeyContainer**](#keycontainer). Use [**DelaySign**](#delaysign) if you want a partially signed assembly. In case both **KeyFile** and **KeyContainer** are specified in the same compilation, the compiler will first try the key container. If that succeeds, then the assembly is signed with the information in the key container. If the compiler doesn't find the key container, it will try the file specified with [**KeyFile**](#keyfile). If that succeeds, the assembly is signed with the information in the key file and the key information will be installed in the key container. On the next compilation, the key container will be valid. A key file might contain only the public key. For more information, see [Creating and Using Strong-Named Assemblies](../../../standard/assembly/create-use-strong-named.md) and [Delay Signing an Assembly](../../../standard/assembly/delay-sign.md).
`file` is the name of the file containing the strong name key. When this option is used, the compiler inserts the public key from the specified file into the assembly manifest and then signs the final assembly with the private key. To generate a key file, type `sn -k file` at the command line. If you compile with [**-target:module**](output.md#outputtype), the name of the key file is held in the module and incorporated into the assembly created when you compile an assembly with [**AddModules**](inputs.md#addmodules). You can also pass your encryption information to the compiler with [**KeyContainer**](#keycontainer). Use [**DelaySign**](#delaysign) if you want a partially signed assembly. In case both **KeyFile** and **KeyContainer** are specified in the same compilation, the compiler will first try the key container. If that succeeds, then the assembly is signed with the information in the key container. If the compiler doesn't find the key container, it will try the file specified with [**KeyFile**](#keyfile). If that succeeds, the assembly is signed with the information in the key file and the key information will be installed in the key container. On the next compilation, the key container will be valid. A key file might contain only the public key. For more information, see [Creating and Using Strong-Named Assemblies](../../../standard/assembly/create-use-strong-named.md) and [Delay Signing an Assembly](../../../standard/assembly/delay-sign.md).

## KeyContainer

Expand All @@ -64,7 +64,7 @@ Specifies the name of the cryptographic key container.
<KeyContainer>container</KeyContainer>
```

`container` is the name of the strong name key container. When the **KeyContainer** option is used, the compiler creates a sharable component. The compiler inserts a public key from the specified container into the assembly manifest and signs the final assembly with the private key. To generate a key file, type `sn -k file` at the command line. `sn -i` installs the key pair into a container. This option isn't supported when the compiler runs on CoreCLR. To sign an assembly when building on CoreCLR, use the [**KeyFile**](#keyfile) option. If you compile with [**TargetType**](output.md#targettype), the name of the key file is held in the module and incorporated into the assembly when you compile this module into an assembly with [**AddModules**](inputs.md#addmodules). You can also specify this option as a custom attribute (<xref:System.Reflection.AssemblyKeyNameAttribute?displayProperty=nameWithType>) in the source code for any common intermediate language (CIL) module. You can also pass your encryption information to the compiler with [**KeyFile**](#keyfile). Use [**DelaySign**](#delaysign) to add the public key to the assembly manifest but signing the assembly until it has been tested. For more information, see [Creating and Using Strong-Named Assemblies](../../../standard/assembly/create-use-strong-named.md) and [Delay Signing an Assembly](../../../standard/assembly/delay-sign.md).
`container` is the name of the strong name key container. When the **KeyContainer** option is used, the compiler creates a sharable component. The compiler inserts a public key from the specified container into the assembly manifest and signs the final assembly with the private key. To generate a key file, type `sn -k file` at the command line. `sn -i` installs the key pair into a container. This option isn't supported when the compiler runs on CoreCLR. To sign an assembly when building on CoreCLR, use the [**KeyFile**](#keyfile) option. If you compile with [**OutputType**](output.md#outputtype), the name of the key file is held in the module and incorporated into the assembly when you compile this module into an assembly with [**AddModules**](inputs.md#addmodules). You can also specify this option as a custom attribute (<xref:System.Reflection.AssemblyKeyNameAttribute?displayProperty=nameWithType>) in the source code for any common intermediate language (CIL) module. You can also pass your encryption information to the compiler with [**KeyFile**](#keyfile). Use [**DelaySign**](#delaysign) to add the public key to the assembly manifest but signing the assembly until it has been tested. For more information, see [Creating and Using Strong-Named Assemblies](../../../standard/assembly/create-use-strong-named.md) and [Delay Signing an Assembly](../../../standard/assembly/delay-sign.md).

## HighEntropyVA

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/misc/cs0734.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The /moduleassemblyname option may only be specified when building a target type

The compiler option **ModuleAssemblyName** should only be used when building a .netmodule. See [**ModuleAssemblyName** (C# Compiler Option)](../language-reference/compiler-options/advanced.md#moduleassemblyname) for more information.

For more information on building a .netmodule, see the **module** element for the [**TargetType** (C# Compiler Options)](../language-reference/compiler-options/output.md#targettype).
For more information on building a .netmodule, see the **module** element for the [**OutputType** (C# Compiler Options)](../language-reference/compiler-options/output.md#outputtype).

## Example

Expand Down
Loading
Loading