diff --git a/docs/consume-packages/Package-References-in-Project-Files.md b/docs/consume-packages/Package-References-in-Project-Files.md index c7a6d1eca..7d00090d7 100644 --- a/docs/consume-packages/Package-References-in-Project-Files.md +++ b/docs/consume-packages/Package-References-in-Project-Files.md @@ -261,6 +261,19 @@ namespace PackageReferenceAliasesExample ``` +## IsImplicitlyDefined metadata + +MSBuild project SDKs sometimes inject `` items on the consumer's behalf — for example, the .NET SDK injects framework packs such as `Microsoft.NETCore.App`. SDKs mark these references with `IsImplicitlyDefined="true"` so NuGet knows they're owned by the SDK rather than authored by the project: + +```xml + +``` + +End users don't set this metadata on references in their own project files. + +- **SDK authors**: Set `IsImplicitlyDefined="true"` on every `` your SDK injects, and pair it with a documented MSBuild property (for example, `$(ContosoSdkVersion)`) so end users have a supported way to influence the resolved version. This follows the same contract the .NET SDK uses for framework packs such as `Microsoft.NETCore.App`. +- **End users**: Implicitly defined packages appear in the Visual Studio Package Manager UI's **Installed** tab but can't be updated or uninstalled there, and adding a duplicate `` for the same package id produces [NU1504](../reference/errors-and-warnings/NU1504.md) during restore (from `dotnet`, `msbuild`, or Visual Studio). To change the version, set the property documented by the SDK (for example, `` for `MSTest.Sdk`) or upgrade the SDK. + ## NuGet warnings and errors *This feature is available with NuGet **4.3** or above and with Visual Studio 2017 **15.3** or above.* diff --git a/docs/reference/errors-and-warnings/NU1504.md b/docs/reference/errors-and-warnings/NU1504.md index 0b1cb88ae..15bddb640 100644 --- a/docs/reference/errors-and-warnings/NU1504.md +++ b/docs/reference/errors-and-warnings/NU1504.md @@ -40,3 +40,5 @@ Consult the recommendations in the warning message and do one of the following: - Remove the duplicate items - Use item `Update` instead of item `Include` +- If you're using an MSBuild project SDK (for example, `MSTest.Sdk`), the SDK's `` should be marked with `IsImplicitlyDefined="true"` and should not be duplicated by a user-authored reference. +To change its version, set the version property documented by the SDK or upgrade the SDK itself. See [IsImplicitlyDefined metadata](../../consume-packages/package-references-in-project-files.md#isimplicitlydefined-metadata) for more information.