Condividi tramite


Errore NuGet NU1008

Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: PackageId.

Problema

Quando si usa la gestione centrale dei pacchetti, le versioni devono essere definite nell'elemento PackageVersion.

Nel file di progetto è possibile che venga visualizzato quanto illustrato di seguito:

<!-- In the project file. -->
<PackageReference Include="PackageId" Version="5.1.0" />

Soluzione

  • Rimuovere la versione da PackageId PackageReference.
  • Potrebbe essere necessario aggiungere o aggiornare l'elemento PackageVersion per PackageId in Directory.Packages.props

Esempio:

<!-- In the project file. -->
<PackageReference Include="PackageId" />
<!-- In the Directory.Packages.props -->
<PackageVersion Include="PackageId" Version="5.1.0" />

Nota

Si noti che i metadati, ad esempio IncludeAssets, PrivateAssets e così via , devono rimanere sull'elemento PackageReference.