From ede1780aa3aef3537cd9f69e804b61fe3ab89b37 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Mon, 14 Apr 2025 12:11:56 +0200 Subject: [PATCH 1/3] Document RoslynCompilerType --- docs/core/project-sdk/msbuild-props.md | 27 +++++++++----------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/docs/core/project-sdk/msbuild-props.md b/docs/core/project-sdk/msbuild-props.md index 25c9633fa9ac0..cadf8478c482e 100644 --- a/docs/core/project-sdk/msbuild-props.md +++ b/docs/core/project-sdk/msbuild-props.md @@ -679,8 +679,7 @@ The following MSBuild properties are documented in this section: - [OptimizeImplicitlyTriggeredBuild](#optimizeimplicitlytriggeredbuild) - [DisableRuntimeMarshalling](#disableruntimemarshalling) - [BuildWithNetFrameworkHostedCompiler](#buildwithnetframeworkhostedcompiler) -- [RoslynUseSdkCompiler](#roslynusesdkcompiler) -- [RoslynUseMSBuildCompiler](#roslynusemsbuildcompiler) +- [RoslynCompilerType](#roslyncompilertype) C# compiler options, such as `LangVersion` and `Nullable`, can also be specified as MSBuild properties in your project file. For more information, see [C# compiler options](../../csharp/language-reference/compiler-options/index.md). @@ -847,24 +846,16 @@ The `DisableRuntimeMarshalling` property enables you to specify that you would l ### BuildWithNetFrameworkHostedCompiler -When using .NET Framework MSBuild, `BuildWithNetFrameworkHostedCompiler=true` ensures that -a C#/VB compiler corresponding to the current SDK version is used -instead of the default version that ships with MSBuild. -When this property is set to `true`, the .NET Framework version of the compiler is used, unlike `RoslynUseSdkCompiler`. -In some cases, this behavior happens automatically when it is detected that MSBuild and SDK versions are different, -and then you can set `BuildWithNetFrameworkHostedCompiler=false` to opt out of the behavior. +Specifying `BuildWithNetFrameworkHostedCompiler=true` is the equivalent of specifying `RoslynCompilerType=FrameworkPackage`, see below. +Specifying `BuildWithNetFrameworkHostedCompiler=false` ensures the automatic opt in to `RoslynCompilerType=FrameworkPackage` does not happen. +If `RoslynCompilerType` is specified explicitly, `BuildWithNetFrameworkHostedCompiler` has no effect. -### RoslynUseSdkCompiler +### RoslynCompilerType -When using .NET Framework MSBuild, `RoslynUseSdkCompiler=true` ensures that -a C#/VB compiler corresponding to the current SDK version is used -instead of the default version that ships with MSBuild. -When this property is set to `true`, the .NET Core version of the compiler is used, unlike `BuildWithNetFrameworkHostedCompiler`. -In most cases, `RoslynUseSdkCompiler=true` is the default setting. - -### RoslynUseMSBuildCompiler - -`RoslynUseMSBuildCompiler=true` can be used to opt out of an implicit `RoslynUseSdkCompiler=true`. +The `RoslynCompilerType` property controls version of C#/VB compiler. These values are recognized: +- `Core`: Use the compiler that comes with the .NET SDK. This is the default since .NET 10, even when using .NET Framework MSBuild. +- `Framework`: Use the compiler that comes with .NET Framework MSBuild. +- `FrameworkPackage`: When using .NET Framework MSBuild, download and use a package with .NET Framework compiler corresponding to the .NET SDK version. ## Default item inclusion properties From 0705367a95e15007360e03dbb33e479cab3649c6 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Mon, 14 Apr 2025 12:18:12 +0200 Subject: [PATCH 2/3] Fix lint error --- docs/core/project-sdk/msbuild-props.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/core/project-sdk/msbuild-props.md b/docs/core/project-sdk/msbuild-props.md index cadf8478c482e..0f341bf18b7b2 100644 --- a/docs/core/project-sdk/msbuild-props.md +++ b/docs/core/project-sdk/msbuild-props.md @@ -853,6 +853,7 @@ If `RoslynCompilerType` is specified explicitly, `BuildWithNetFrameworkHostedCom ### RoslynCompilerType The `RoslynCompilerType` property controls version of C#/VB compiler. These values are recognized: + - `Core`: Use the compiler that comes with the .NET SDK. This is the default since .NET 10, even when using .NET Framework MSBuild. - `Framework`: Use the compiler that comes with .NET Framework MSBuild. - `FrameworkPackage`: When using .NET Framework MSBuild, download and use a package with .NET Framework compiler corresponding to the .NET SDK version. From 77ee59021ccad2d7aaf8ce88647ec3704a5b4aae Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Mon, 21 Apr 2025 15:20:23 +0200 Subject: [PATCH 3/3] Improve wording Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/project-sdk/msbuild-props.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/core/project-sdk/msbuild-props.md b/docs/core/project-sdk/msbuild-props.md index 0f341bf18b7b2..729c8ff0e4457 100644 --- a/docs/core/project-sdk/msbuild-props.md +++ b/docs/core/project-sdk/msbuild-props.md @@ -846,17 +846,17 @@ The `DisableRuntimeMarshalling` property enables you to specify that you would l ### BuildWithNetFrameworkHostedCompiler -Specifying `BuildWithNetFrameworkHostedCompiler=true` is the equivalent of specifying `RoslynCompilerType=FrameworkPackage`, see below. +Specifying `BuildWithNetFrameworkHostedCompiler=true` is the equivalent of specifying `RoslynCompilerType=FrameworkPackage`. For more information, see [RoslynCompilerType](#roslyncompilertype). Specifying `BuildWithNetFrameworkHostedCompiler=false` ensures the automatic opt in to `RoslynCompilerType=FrameworkPackage` does not happen. If `RoslynCompilerType` is specified explicitly, `BuildWithNetFrameworkHostedCompiler` has no effect. ### RoslynCompilerType -The `RoslynCompilerType` property controls version of C#/VB compiler. These values are recognized: +The `RoslynCompilerType` property controls the version of the C# or Visual Basic compiler. The following values are recognized: - `Core`: Use the compiler that comes with the .NET SDK. This is the default since .NET 10, even when using .NET Framework MSBuild. - `Framework`: Use the compiler that comes with .NET Framework MSBuild. -- `FrameworkPackage`: When using .NET Framework MSBuild, download and use a package with .NET Framework compiler corresponding to the .NET SDK version. +- `FrameworkPackage`: When using .NET Framework MSBuild, download and use a package with the .NET Framework compiler that corresponds to the .NET SDK version. ## Default item inclusion properties