Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/consume-packages/Package-References-in-Project-Files.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@ namespace PackageReferenceAliasesExample

```

## IsImplicitlyDefined metadata

MSBuild project SDKs sometimes inject `<PackageReference>` 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
<PackageReference Include="Contoso.SdkPackage" Version="$(ContosoSdkVersion)" IsImplicitlyDefined="true" />
```

End users don't set this metadata on references in their own project files.

- **SDK authors**: Set `IsImplicitlyDefined="true"` on every `<PackageReference>` 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 `<PackageReference>` 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, `<MSTestVersion>` 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.*
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/errors-and-warnings/NU1504.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<PackageReference>` 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.