You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Reference for the MSBuild properties and items that are understood by the .NET SDK.
4
-
ms.date: 11/09/2023
4
+
ms.date: 12/01/2023
5
5
ms.topic: reference
6
6
ms.custom: updateeachrelease
7
7
---
@@ -12,6 +12,52 @@ This page is a reference for the MSBuild properties and items that you can use t
12
12
> [!NOTE]
13
13
> This page is a work in progress and does not list all of the useful MSBuild properties for the .NET SDK. For a list of common MSBuild properties, see [Common MSBuild properties](/visualstudio/msbuild/common-msbuild-project-properties).
14
14
15
+
## Assembly validation properties
16
+
17
+
These properties and items are passed to the `ValidateAssemblies` task. For more information about assembly validation, see [Assembly validation](../../fundamentals/apicompat/assembly-validation.md).
18
+
19
+
The following MSBuild properties are documented in this section:
> These properties aren't part of the .NET SDK (yet). To use them, you must also add a `PackageReference` to [Microsoft.DotNet.ApiCompat.Task](https://www.nuget.org/packages/Microsoft.DotNet.ApiCompat.Task).
26
+
27
+
In addition, the following properties that are documented in the [Package validation properties](#package-validation-properties) also apply to assembly validation:
When set to `true`, the `ApiCompatStrictMode` property specifies that API compatibility checks should be performed in [strict mode](../../fundamentals/apicompat/overview.md#strict-mode).
44
+
45
+
```xml
46
+
<PropertyGroup>
47
+
<ApiCompatStrictMode>true</ApiCompatStrictMode>
48
+
</PropertyGroup>
49
+
```
50
+
51
+
### ApiCompatValidateAssemblies
52
+
53
+
The `ApiCompatValidateAssemblies` property enables a series of validations on the specified assemblies. For more information, see [Assembly validation](../../fundamentals/apicompat/assembly-validation.md).
The following MSBuild properties are documented in this section:
@@ -159,14 +205,194 @@ The `PackRelease` property is similar to the [PublishRelease](#publishrelease) p
159
205
> - Starting in the .NET 8 SDK, `PackRelease` defaults to `true`. For more information, see ['dotnet pack' uses Release configuration](../compatibility/sdk/8.0/dotnet-pack-config.md).
160
206
> - .NET 7 SDK only: To use `PackRelease` in a project that's part of a Visual Studio solution, you must set the environment variable `DOTNET_CLI_ENABLE_PACK_RELEASE_FOR_SOLUTIONS` to `true` (or any other value). For solutions that have many projects, setting this variable increases the time required to pack.
161
207
208
+
## Package validation properties
209
+
210
+
These properties and items are passed to the `ValidatePackage` task. For more information about package validation, see [Package validation overview](../../fundamentals/apicompat/package-validation/overview.md).
211
+
212
+
For properties for the `ValidateAssemblies` task, see [Assembly validation properties](#assembly-validation-properties).
213
+
214
+
The following MSBuild properties and items are documented in this section:
When set to `true`, the `ApiCompatEnableRuleAttributesMustMatch` property enables the validation rule that checks if attributes match. The default is `false`.
When set to `true`, the `ApiCompatEnableRuleCannotChangeParameterName` property enables the validation rule that checks whether parameter names have changed in public methods. The default is `false`.
The `ApiCompatExcludeAttributesFile` item specifies the path to a file that contains attributes to exclude in [DocId](../../csharp/language-reference/xmldoc/index.md#id-strings) format.
The `ApiCompatPreserveUnnecessarySuppressions` property specifies whether to preserve unnecessary suppressions when regenerating the suppression file. When an existing suppression file is regenerated, its content is read, deserialized into a set of suppressions, and then stored in a list. Some of the suppressions might no longer be necessary if the incompatibility has been fixed. When the suppressions are serialized back to disk, you can choose to keep *all* the existing (deserialized) expressions by setting this property to `true`.
The `ApiCompatSuppressionFile` item specifies the path to one or more suppression files to read from. If unspecified, the suppression file *\<project-directory>/CompatibilitySuppressions.xml* is read (if it exists).
The `ApiCompatSuppressionOutputFile` property specifies the path to a suppression file to write to when `<ApiCompatGenerateSuppressionFile>` is `true`. If unspecified, the first `ApiCompatSuppressionFile` item is used.
324
+
325
+
### EnablePackageValidation
326
+
327
+
The `EnablePackageValidation` property enables a series of validations on the package after the `Pack` task. For more information, see [package validation](../../fundamentals/apicompat/package-validation/overview.md).
When set to `true`, the `EnableStrictModeForBaselineValidation` property enables [strict mode](../../fundamentals/apicompat/overview.md#strict-mode) for package baseline checks. The default is `false`.
When set to `true`, the `EnableStrictModeForCompatibleFrameworksInPackage` property enables [strict mode](../../fundamentals/apicompat/overview.md#strict-mode) for assemblies that are compatible based on their target framework. The default is `false`.
342
+
343
+
### EnableStrictModeForCompatibleTfms
344
+
345
+
When set to `true`, the `EnableStrictModeForCompatibleTfms` property enables [strict mode](../../fundamentals/apicompat/overview.md#strict-mode) for contract and implementation assemblies for all compatible target frameworks. The default is `true`.
346
+
347
+
### NoWarn
348
+
349
+
The `NoWarn` property specifies the diagnostic IDs to suppress.
350
+
351
+
```xml
352
+
<PropertyGroup>
353
+
<NoWarn>$(NoWarn);PKV0001</NoWarn>
354
+
</PropertyGroup>
355
+
```
356
+
357
+
### PackageValidationBaselineFrameworkToIgnore
358
+
359
+
The `PackageValidationBaselineFrameworkToIgnore` item specifies a target framework to ignore from the baseline package. The framework string must exactly match the folder name in the baseline package.
The `PackageValidationBaselineName` property specifies the name of the baseline package to validate the current package against. If unspecified, the `PackageId` value is used.
370
+
371
+
### PackageValidationBaselineVersion
372
+
373
+
The `PackageValidationBaselineVersion` property specifies the version of the baseline package to validate the current package against.
374
+
375
+
### PackageValidationReferencePath
376
+
377
+
The `PackageValidationReferencePath` item specifies the directory path where the reference assembly can be found per TFM.
The `RoslynAssembliesPath` property specifies the path to the directory that contains the Microsoft.CodeAnalysis assemblies you want to use. You only need to set this property if you want to test with a newer compiler than what's in the SDK.
388
+
162
389
## Publish-related properties
163
390
164
391
The following MSBuild properties are documented in this section:
@@ -237,18 +463,6 @@ The `ErrorOnDuplicatePublishOutputFiles` property relates to whether the SDK gen
237
463
238
464
This property was introduced in .NET 6.
239
465
240
-
### EnablePackageValidation
241
-
242
-
The `EnablePackageValidation` property enables a series of validations on the package after the `pack` task. For more information, see [package validation](../../fundamentals/apicompat/package-validation/overview.md).
Starting with the .NET 6 SDK, the *\[Appname].runtimesettings.dev.json* file is [no longer generated by default](../compatibility/sdk/6.0/runtimeconfigdev-file.md) at compile time. If you still want this file to be generated, set the `GenerateRuntimeConfigDevFile` property to `true`.
description: Learn how assembly validation can be used to develop consistent and well-formed multi-targeting assemblies.
4
+
ms.date: 12/01/2023
5
+
ms.topic: overview
6
+
---
7
+
8
+
# Assembly validation
9
+
10
+
Similar to [package validation](/dotnet/fundamentals/apicompat/package-validation/overview), assembly validation tooling allows you, as a library developer, to validate that your assemblies are consistent and well formed. It provides the following checks:
11
+
12
+
- Validates that there are no breaking changes across versions.
13
+
- Validates that the assembly has the same set of public APIs for all the different runtime-specific implementations.
14
+
- Catches any applicability holes.
15
+
16
+
You can run assembly validation either as an [MSBuild task](#enable-msbuild-task) or using the [Microsoft.DotNet.ApiCompat.Tool global tool](global-tool.md).
17
+
18
+
## Enable MSBuild task
19
+
20
+
You enable assembly validation in your .NET project by setting the [`ApiCompatValidateAssemblies`](../../core/project-sdk/msbuild-props.md#apicompatvalidateassemblies) property to `true`. You must also add a package reference to [Microsoft.DotNet.ApiCompat.Task](https://www.nuget.org/packages/Microsoft.DotNet.ApiCompat.Task). (The `targets` files in that package aren't part of the .NET SDK.)
Assembly validation runs either in the outer build for multi-targeting projects (after the `DispatchToInnerBuilds` target) or in the inner build for a single-targeting project (as part of the `PrepareForRun` target). It's also fully incremental, meaning the comparison is only triggered if the inputs or outputs have changed.
38
+
39
+
## Suppress compatibility warnings
40
+
41
+
For information about suppressing compatibility warnings, see [How to suppress](diagnostic-ids.md#how-to-suppress).
0 commit comments