Skip to content

Commit 9235893

Browse files
authored
Update NU1008.md (#3331)
Explain how to override package version
1 parent a590d43 commit 9235893

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

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

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,33 @@ In your project file, you may see:
2929
- Remove the version from the PackageId PackageReference.
3030
- You may need to add or update the PackageVersion item for PackageId in Directory.Packages.props
3131

32-
Example:
32+
Example:
3333

34-
```xml
35-
<!-- In the project file. -->
36-
<PackageReference Include="PackageId" />
37-
```
34+
```xml
35+
<!-- In the project file. -->
36+
<PackageReference Include="PackageId" />
37+
```
38+
39+
```xml
40+
<!-- In the Directory.Packages.props -->
41+
<PackageVersion Include="PackageId" Version="5.1.0" />
42+
```
43+
44+
- Alternatively, you may override an individual package version by using the `VersionOverride` property on a `<PackageReference />` item.
45+
This overrides any `<PackageVersion />` defined centrally.
46+
47+
Example:
48+
49+
```xml
50+
<!-- In the project file. -->
51+
<PackageReference Include="PackageId" VersionOverride="3.0.0" />
52+
```
53+
54+
```xml
55+
<!-- In the Directory.Packages.props -->
56+
<PackageVersion Include="PackageId" Version="5.1.0" />
57+
```
3858

39-
```xml
40-
<!-- In the Directory.Packages.props -->
41-
<PackageVersion Include="PackageId" Version="5.1.0" />
42-
```
4359

4460
> [!NOTE]
4561
> Note that metadata such as [IncludeAssets, PrivateAssets etc.](../../consume-packages/Package-References-in-Project-Files.md#controlling-dependency-assets) should remain on the PackageReference item.

0 commit comments

Comments
 (0)