Skip to content

Commit bbd10cf

Browse files
authored
Update NU5127 docs (#3425)
1 parent c4d84f2 commit bbd10cf

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docs/reference/errors-and-warnings/NU5127.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
title: NuGet Warning NU5127
33
description: NU5127 Warning code
44
author: zivkan
5-
ms.date: 09/20/2019
5+
ms.date: 05/05/2025
66
ms.topic: reference
7-
ms.reviewer: karann
87
f1_keywords:
98
- NU5127
109
---
@@ -17,8 +16,17 @@ f1_keywords:
1716
1817
### Issue
1918

20-
Projects using packages with `PackageReference` only use `lib/` and `ref/` assemblies to determine package compatibility. Therefore, a package without any `lib/` or `ref/` files will be considered compatible with all projects. However, if that package contains build files specific to one or more [Target Framework Monikers (TFMs)](../target-frameworks.md), a package consumer may expect the package to fail if none of the build files are used.
19+
Projects using packages with `PackageReference` only use `lib/` and `ref/` assemblies to determine package compatibility.
20+
Therefore, a package without any `lib/` or `ref/` files will be considered compatible with all projects.
21+
However, packages containing MSBuild props or targets that are specific to one or more target frameworks show intent in only being compatible with those target frameworks.
22+
23+
For example, consider a package `PackageA` contains a single file, `build/net8.0/PackageA.targets`.
24+
If this package is referenced by a project targeting `net48` (.NET Framework, Version 4.8), NuGet will not emit any warnings or errors, but also will not select any assets from the package.
25+
Therefore, the package consumer will not be notified that the package does not work correctly with their project.
2126

2227
### Solution
2328

24-
As the warning message suggests, create an empty file named `_._` in the lib folder for the TFMs listed. This will allow NuGet to fail the restore for `PackageReference` projects when the project is incompatible with the package.
29+
As the warning message suggests, create an empty file named `_._` in the lib folder for the TFMs listed.
30+
This will allow NuGet to fail the restore for `PackageReference` projects when the project is incompatible with the package.
31+
32+
If your package is intended to be compatible with all target frameworks, but only take effect for certain target frameworks, create a file `build/{PackageId}.props` whose contents are `<Project />`.

0 commit comments

Comments
 (0)