Skip to content

Commit 3ba5762

Browse files
committed
Merged main into live
2 parents 69f21c3 + 5802fbd commit 3ba5762

File tree

7 files changed

+75
-58
lines changed

7 files changed

+75
-58
lines changed

docs/code-quality/migrate-from-legacy-analysis-to-net-analyzers.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Migrate from FxCop to source analysis (.NET)
33
description: Analyze code for the first time or migrate your process from binary analysis (FxCop code analysis) to .NET analyzers for source analysis.
4-
ms.date: 09/17/2021
4+
ms.date: 04/30/2025
55
ms.topic: conceptual
66
f1_keywords:
77
- "vs.projectpropertypages.codeanalysis"
@@ -50,6 +50,8 @@ To learn more about how to configure the .NET analyzers:
5050

5151
- To find out about configuring analyzers using predefined rules with EditorConfig or a rule set file, see [Enable a category of rules](/dotnet/fundamentals/code-analysis/code-quality-rule-options).
5252

53+
- To migrate from rule set files to EditorConfig, see [Convert an existing rule set file to an EditorConfig file](../code-quality/use-roslyn-analyzers.md#convert-an-existing-rule-set-file-to-an-editorconfig-file).
54+
5355
## Related content
5456

5557
- [Migrate from FxCop analyzers to .NET analyzers](migrate-from-fxcop-analyzers-to-net-analyzers.md)

docs/code-quality/use-roslyn-analyzers.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ helpviewer_keywords:
1010
- code analysis, managed code
1111
- analyzers
1212
- Roslyn analyzers
13-
ms.date: 04/04/2024
13+
ms.date: 04/30/2025
1414
---
1515

1616
# Customize Roslyn analyzer rules
@@ -265,7 +265,7 @@ When you convert your existing rule set file to an EditorConfig file, save it at
265265
You can convert an existing rule set file to an EditorConfig file by using either the rule set editor or the command line.
266266

267267
> [!NOTE]
268-
> .NET Core and .NET Standard projects don't support the menu commands for rule sets in Solution Explorer, for example, **Open Active Rule Set**. To specify a non-default rule set for a .NET Core or .NET Standard project, manually [add the **CodeAnalysisRuleSet** property](using-rule-sets-to-group-code-analysis-rules.md#specify-a-rule-set-for-a-project) to the project file. You can still configure the rules within the rule set in the rule set editor.
268+
> .NET Core and .NET 5+ projects don't support the menu commands for rule sets in Solution Explorer, for example, **Open Active Rule Set**. To specify a non-default rule set for a .NET Core or a .NET 5+ project, manually [add the **CodeAnalysisRuleSet** property](using-rule-sets-to-group-code-analysis-rules.md#specify-a-rule-set-for-a-project) to the project file. You can still configure the rules within the rule set in the rule set editor.
269269
270270
To use the rule set editor, follow these steps. If your project already uses a specific rule set file for its `CodeAnalysisRuleSet` property value, you can convert it to an equivalent EditorConfig file from the rule set editor:
271271

@@ -281,6 +281,11 @@ To use the rule set editor, follow these steps. If your project already uses a s
281281

282282
The generated EditorConfig opens in the editor. Additionally, the MSBuild property `CodeAnalysisRuleSet` is updated in the project file so that it no longer references the original rule set file.
283283

284+
The original rule set file can be removed from the project.
285+
286+
> [!NOTE]
287+
> In a .NET Framework project, the default rule set file can't be migrated or removed from the project.
288+
284289
To use the command line, follow these steps:
285290

286291
1. Install the NuGet package [Microsoft.CodeAnalysis.RulesetToEditorconfigConverter](https://www.nuget.org/packages/Microsoft.CodeAnalysis.RulesetToEditorconfigConverter).
Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Customize the solution build
3-
description: Customize the solution build prepared by MSBuild for command-line builds of solutions with settings that don't affect project builds.
4-
ms.date: 02/28/2023
2+
title: Customize solution builds
3+
description: Customize the solution build MSBuild prepares for command-line builds with settings that don't affect project builds.
4+
ms.date: 04/29/2025
55
ms.topic: how-to
66
helpviewer_keywords:
77
- MSBuild, transforms
@@ -10,13 +10,18 @@ author: ghogen
1010
ms.author: ghogen
1111
manager: mijacobs
1212
ms.subservice: msbuild
13+
14+
#customer intent: As a builder, I want to know how to customize MSBuild solution builds, so I can extend solution builds with files and settings that affect different subsets of files.
15+
1316
---
1417

15-
# Customize the solution build
18+
# Customize solution builds
19+
20+
When MSBuild builds a solution file, it first translates the file internally into a project file, and then builds that project file. The generated project file can import a *before.\<solutionname>.sln.targets* file before it defines any targets, and import *after.\<solutionname>.sln.targets* after it imports the targets.
1621

17-
When MSBuild builds a solution file, it first translates it internally into a project file and then builds that. The generated project file imports `before.{solutionname}.sln.targets` before defining any targets and `after.{solutionname}.sln.targets` after importing targets, including targets installed to the `$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\SolutionFile\ImportBefore` and `$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\SolutionFile\ImportAfter` directories.
22+
The *before* and *after* targets files are installed to the `$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\SolutionFile\ImportBefore` and `$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\SolutionFile\ImportAfter` directories.
1823

19-
For example, you could define a new target to write a custom log message after building *MyCustomizedSolution.sln* by creating a file in the same directory named *after.MyCustomizedSolution.sln.targets* that contains
24+
So, for example, you could define a new target to write a custom log message after *MyCustomizedSolution.sln* builds, by creating the following file named *after.MyCustomizedSolution.sln.targets* in the same directory.
2025

2126
```xml
2227
<Project>
@@ -26,18 +31,20 @@ For example, you could define a new target to write a custom log message after b
2631
</Project>
2732
```
2833

29-
The solution build is separate from the project builds, so settings here do not affect project builds.
34+
The solution build is separate from the project builds, so these settings don't affect the project builds.
3035

3136
> [!IMPORTANT]
32-
> Customizing the solution build in this way applies only to command-line builds with `MSBuild.exe` or `dotnet build`. It **does not** apply to builds inside Visual Studio. For this reason, it is not recommended to put customization at the solution level. A better alternative for customizing all projects in a solution is to use *Directory.Build.props* and *Directory.build.targets* files in the solution folder, as discussed elsewhere in this article.
37+
> Customizing the solution builds this way applies only to command-line builds using `MSBuild.exe` or `dotnet build`, and doesn't apply to builds inside Visual Studio. Therefore, it's best not to put customization at the solution level. A better alternative for customizing all projects in a solution is to use *Directory.Build.props* and *Directory.Build.targets* files in the solution folder.
3338
34-
When you have many solution files that you want to extend in the same way, but you don't want to write to the `$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\SolutionFile\` folder (which usually requires elevated permissions), you can create the files *Directory.Solution.props* and *Directory.Solution.targets* and place them in the root path above the solution files you want to extend. *Directory.Solution.props* is imported at the beginning of the solution build, and *Directory.Solution.targets* is imported at the end of the solution build. When you build a solution file, *Directory.Build.props* and *Directory.Build.targets* are not imported, so you must use *Directory.Solution.props* and *Directory.Solution.targets* instead. They do not implicitly import each other.
39+
Writing to the `$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\SolutionFile` folder usually requires elevated permissions. If you have many solution files to extend the same way, but you don't want to write to the *SolutionFile* folder, you can create the *Directory.Solution.props* and *Directory.Solution.targets* files and place them in the root path above the solution files you want to extend. *Directory.Solution.props* is imported at the beginning of the solution build, and *Directory.Solution.targets* is imported at the end of the solution build.
3540

36-
When you have *Directory.Solution.props* or *Directory.Solution.targets* in a root folder, but you have a solution under that folder that you don't want to import them, you can use the solution-specific files mentioned previously `before.{solutionname}.sln.targets` and `after.{solutionname}.sln.targets` to set the properties `$(ImportDirectorySolutionProps)` and `$(ImportDirectorySolutionTargets)` to false. Or, you can use the properties `$(DirectorySolutionPropsPath)` and `$(DirectorySolutionTargetsPath)` to specify a different location for those files. This could be helpful if you have various subsets of your solutions that require certain property values or targets common to the subsets.
41+
When you build a solution file, *Directory.Build.props* and *Directory.Build.targets* aren't imported, so you must use *Directory.Solution.props* and *Directory.Solution.targets* instead. The two types of files don't implicitly import each other.
3742

38-
> [!NOTE]
39-
> The solution build is supported with the `.slnx` solution file format in MSBuild 17.12 and later. Both `before.{solutionname}.slnx.targets` and `before.{solutionname}.sln.targets` work (and likewise for the `after` forms) with MSBuild 17.14 and later.
43+
When you have *Directory.Solution.props* or *Directory.Solution.targets* files in a root folder, but you don't want a solution under that folder to import those files, you can use the solution's *before.\<solutionname>.sln.targets* file to set the properties `ImportDirectorySolutionProps` and `ImportDirectorySolutionTargets` to `false`.
44+
45+
Or, you can use the `$(DirectorySolutionPropsPath)` and `$(DirectorySolutionTargetsPath)` properties to specify a different location for those files. This approach can be helpful if subsets of your solutions require certain property values or targets in common.
4046

41-
## Related content
47+
> [!NOTE]
48+
> The solution build is supported with the `.slnx` solution file format in MSBuild 17.12 and later. Both *before.\<solutionname>.slnx.targets* and *before.\<solutionname>.sln.targets*, and the corresponding *after* files, work with MSBuild 17.14 and later.
4249
43-
- [Customize your build](customize-your-build.md).
50+
For more information about build customization options, see [Customize your build](customize-your-build.md).
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Customize your local build
3-
description: Customize the build process just for your own local build without affecting files that you share with a source code repository.
4-
ms.date: 02/28/2023
2+
title: Customize local builds
3+
description: Customize the build process for local builds without affecting shared files in source code repositories.
4+
ms.date: 04/29/2025
55
ms.topic: how-to
66
helpviewer_keywords:
77
- MSBuild, transforms
@@ -10,42 +10,41 @@ author: ghogen
1010
ms.author: ghogen
1111
manager: mijacobs
1212
ms.subservice: msbuild
13+
14+
#customer intent: As a builder, I want to customize local builds, so that I can reproduce bugs or test configurations without affecting shared source code files.
15+
1316
---
1417

1518
# Customize your local build
1619

17-
When you work in a team that used a code repository like GitHub, source control, or any shared codebase, but you want to customize your builds on your local machine, perhaps temporarily to reproduce a bug or test a different configuration, it can be convenient to keep those customizations separate from the shared project files that are shared with the shared code repository. This article describes some build extensions available in MSBuild that let you make user-specific or local-only custom configurations.
20+
When you work with shared code in a code repository like GitHub, in source control, or with any shared codebase, you can use MSBuild to temporarily customize builds on your local machine. You might want to temporarily reproduce a bug or test a different configuration, and keep those customizations separate from the files in the shared code repository. This article describes some build extensions available in MSBuild that let you make user-specific or local-only custom build configurations.
1821

19-
## .user file
22+
## Prerequisites
2023

21-
Using `$(MSBuildProjectFullPath).user`, also referred as `.user` file in this context, is also an option. This file is intended to keep extensions, options, or variables that are specific to your local machine. It is not intended to be uploaded to source control, and it is automatically checked on `.gitignore`. For more extensive changes prefer changing the project itself, so that future maintainers do not have to know about this extension mechanism.
24+
- A Visual Studio project that builds with MSBuild.
2225

23-
On supported multitargeted projects the `.user` file is automatically imported in inner builds and outer builds, so you can just create the file within the solution. If you are working on another type of build, you can still use the `.user` file. You can create it within your solution and then import it in your project file.
24-
```xml
25-
<Import Project="$(MSBuildProjectFullPath).user" Condition="Exists('$(MSBuildProjectFullPath).user')"/>
26-
```
26+
## Use the user file
2727

28-
## MSBuildExtensionsPath and MSBuildUserExtensionsPath
28+
You can use `$(MSBuildProjectFullPath).user`, also called the *user* file in this context, to store extensions, options, or variables that are specific to your local machine. The user file isn't intended to be uploaded to source control, and is automatically checked on `.gitignore`. For more extensive changes, change the project itself, so future maintainers don't have to know about this extension mechanism.
2929

30-
By convention, many core build logic files import
30+
On supported multitargeted projects, the user file is automatically imported in inner builds and outer builds, so you can create this file within the solution. If you're working on another type of build, you can use the user file by creating it within your solution and then importing it in your project file, as follows:
3131

3232
```xml
33-
$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\{TargetFileName}\ImportBefore\*.targets
33+
<Import Project="$(MSBuildProjectFullPath).user" Condition="Exists('$(MSBuildProjectFullPath).user')"/>
3434
```
3535

36-
before their contents, and
36+
<a name="msbuildextensionspath-and-msbuilduserextensionspath"></a>
37+
## Use MSBuildExtensionsPath and MSBuildUserExtensionsPath
3738

38-
```xml
39-
$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\{TargetFileName}\ImportAfter\*.targets
40-
```
39+
By convention, many core build logic files import the `$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\TargetFileName\ImportBefore\*.targets` file before their contents, and the `$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\TargetFileName\ImportAfter\*.targets` file afterwards. This convention allows installed SDKs to augment the build logic of common project types.
4140

42-
afterward. This convention allows installed SDKs to augment the build logic of common project types.
41+
The same directory structure is searched in `$(MSBuildUserExtensionsPath)`, which is the per-user folder *%LOCALAPPDATA%\\Microsoft\\MSBuild*. Files placed in that folder are imported for all builds of the corresponding project type run under that user's credentials.
4342

44-
The same directory structure is searched in `$(MSBuildUserExtensionsPath)`, which is the per-user folder *%LOCALAPPDATA%\Microsoft\MSBuild*. Files placed in that folder will be imported for all builds of the corresponding project type run under that user's credentials. You can disable the user extensions by setting properties named after the importing file in the pattern `ImportUserLocationsByWildcardBefore{ImportingFileNameWithNoDots}`. For example, setting `ImportUserLocationsByWildcardBeforeMicrosoftCommonProps` to `false` would prevent importing `$(MSBuildUserExtensionsPath)\$(MSBuildToolsVersion)\Imports\Microsoft.Common.props\ImportBefore\*`.
43+
You can disable the user extensions by setting properties named after the importing file, in the pattern `ImportUserLocationsByWildcardBefore\<ImportingFileNameWithNoDots>`. For example, setting `ImportUserLocationsByWildcardBeforeMicrosoftCommonProps` to `false` prevents importing `$(MSBuildUserExtensionsPath\$(MSBuildToolsVersion)\Imports\Microsoft.Common.props\ImportBefore\*`.
4544

46-
## Custom configuration based on project language
45+
## Create custom conditions based on project language
4746

48-
If you need different behaviors depending on the .NET language (C#, Visual Basic, or F#), you can add property groups with conditions that depend on the project file extension in `$(MSBuildProjectExtension)` to define language-specific properties and their values.
47+
If you need different behaviors depending on the .NET language: C#, Visual Basic, or F#, you can add property groups with conditions that depend on the project file extension in `<MSBuildProjectExtension>` to define language-specific properties and their values.
4948

5049
```xml
5150
<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.vbproj'">
@@ -61,4 +60,5 @@ If you need different behaviors depending on the .NET language (C#, Visual Basic
6160

6261
## Related content
6362

64-
- [Customize your build](customize-your-build.md).
63+
- [Customize your build](customize-your-build.md)
64+
- [Customize solution builds](customize-solution-build.md)

docs/windows/index.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ additionalContent:
157157
url: /dotnet/maui/
158158
- text: Windows development with C++
159159
url: /cpp/windows/desktop-applications-visual-cpp
160+
- text: Mobile development with C++
161+
url: /cpp/cross-platform/
162+
- text: Linux development with C++
163+
url: /cpp/linux
160164
- title: Game development
161165
links:
162166
- text: Unity

0 commit comments

Comments
 (0)