Framework di destinazione

NuGet usa I riferimenti ai framework di destinazione in svariate posizioni per identificare e isolare i componenti dipendenti dai framework di un pacchetto:

  • file di progetto: per i progetti in stile SDK, il file con estensione csproj contiene i riferimenti al framework di destinazione.
  • Manifesto .nuspec: un pacchetto può indicare i pacchetti distinti da includere in un progetto a seconda del framework di destinazione del progetto.
  • Nome delle cartella .nupkg: le cartelle all'interno della cartella lib di un pacchetto possono essere denominate in base al framework di destinazione e ognuna contiene le DLL e altro contenuto appropriati per tale framework.
  • packages.config: l'attributo targetframework di una dipendenza specifica la variante di un pacchetto da installare.

Nota

NuGet supporta tutti i framework di destinazione .NET moderni:

Framework supportati

In genere si fa riferimento a un framework tramite un breve moniker del framework di destinazione o TFM (Target Framework Moniker). In .NET Standard viene generalizzato anche in TxM per consentire un singolo riferimento a più framework.

Nota

Il codice sorgente del client NuGet che consente di calcolare le tabelle riportate di seguito è disponibile nelle posizioni seguenti:

I client NuGet supportano i framework nella tabella seguente. Gli equivalenti sono visualizzati tra parentesi quadre []. Si noti che alcuni strumenti, ad esempio dotnet, potrebbero usare varianti dei moniker TFM canonici in alcuni file. Ad esempio, dotnet pack usa .NETCoreApp2.0 in un .nuspec file anziché netcoreapp2.0. I vari strumenti client NuGet gestiscono queste variazioni correttamente, ma è consigliabile usare sempre i TFM canonici quando si modificano direttamente i file.

Nome Abbreviazione TFM/TxM
.NET Framework net net11
net20
net35
net40
net403
net45
net451
net452
net46
net461
net462
net47
net471
net472
net48
Microsoft Store (Windows Store) netcore netcore [netcore45]
netcore45 [win, win8]
netcore451 [win81]
netcore50
.NET MicroFramework netmf netmf
Windows win win [win8, netcore45]
win8 [netcore45, win]
win81 [netcore451]
win10 (non supportato dalla piattaforma Windows 10)
Silverlight sl sl4
sl5
Windows Phone (SL) wp wp [wp7]
wp7
wp75
wp8
wp81
Windows Phone (UWP) wpa81
Piattaforma UWP (Universal Windows Platform) uap uap [uap10.0]
uap10.0
uap10.0.xxxxx (dove 10.0.xxxxx è la versione minima della piattaforma di destinazione dell'app che usa)
.NET Standard netstandard netstandard1.0
netstandard1.1
netstandard1.2
netstandard1.3
netstandard1.4
netstandard1.5
netstandard1.6
netstandard2.0
netstandard2.1
.NET 5+ (e .NET Core) netcoreapp netcoreapp1.0
netcoreapp1.1
netcoreapp2.0
netcoreapp2.1
netcoreapp2.2
netcoreapp3.0
netcoreapp3.1
net net5.0
net6.0
net7.0
net8.0
Tizen tizen tizen3
tizen4
Nativo nativi nativi

Framework deprecati

I framework seguenti sono deprecati. I pacchetti che hanno come destinazione questi framework devono essere migrati alle sostituzioni indicate.

Framework deprecato Sostituzione
aspnet50 netcoreapp
aspnetcore50
dnxcore50
dnx
dnx45
dnx451
dnx452
dotnet netstandard
dotnet50
dotnet51
dotnet52
dotnet53
dotnet54
dotnet55
dotnet56
winrt win

Precedenza

Alcuni framework sono correlati e compatibili tra loro, ma non necessariamente equivalenti:

Framework Possono usare
uap (piattaforma UWP) win81
wpa81
netcore50
win (Microsoft Store) winrt

NET Standard

.NET Standard semplifica i riferimenti tra framework compatibili con binari, consentendo a un singolo framework di destinazione di fare riferimento a una combinazione di altre. (Per informazioni generali, vedere Nozioni di base su .NET.)

Lo strumento NuGet Get Nearest Framework simula la logica usata da NuGet per la selezione di un framework da molte risorse di framework disponibili in un pacchetto sulla base del framework di progetto.

La serie dotnet di moniker deve essere usata in NuGet 3.3 e versioni precedenti, mentre la sintassi per i moniker netstandard deve essere usata nella versione 3.4 e versioni successive.

Librerie di classi portabili

Avviso

Le librerie di classi portabili (PCL) non sono consigliate. Anche se sono supportate, gli autori di pacchetti devono supportare netstandard. .NET Platform Standard è un'evoluzione delle librerie di classi portabili e rappresenta la portabilità binaria tra piattaforme usando un singolo moniker che non è associato a una libreria statica come moniker portable-a+b+c .

Per definire un framework di destinazione che fa riferimento a più framework di destinazione figlio, la parola chiave portable viene usata come prefisso per l'elenco dei framework a cui si fa riferimento. Evitare di includere artificialmente framework aggiuntivi non usati direttamente per la compilazione, perché ciò può portare a effetti collaterali imprevisti in tali framework.

I framework aggiuntivi definiti da terze parti garantiscono la compatibilità con altri ambienti accessibili in questo modo. Esistono, inoltre, numeri di profilo abbreviati per fare riferimento a queste combinazioni di framework correlati come Profile#, ma non è consigliabile usare questi numeri, in quanto risulta ridotta la leggibilità delle cartelle e di .nuspec.

N. di profilo Framework Nome completo .NET Standard
Profile2 .NETFramework 4.0 portable-net40+win8+sl4+wp7
Windows 8.0
Silverlight 4.0
WindowsPhone 7.0
Profile3 .NETFramework 4.0 portable-net40+sl4
Silverlight 4.0
Profile4 .NETFramework 4.5 portable-net45+sl4+win8+wp7
Silverlight 4.0
Windows 8.0
WindowsPhone 7.0
Profile5 .NETFramework 4.0 portable-net40+win8
Windows 8.0
Profile6 .NETFramework 4.0.3 portable-net403+win8
Windows 8.0
Profile7 .NETFramework 4.5 portable-net45+win8 netstandard1.1
Windows 8.0
Profile14 .NETFramework 4.0 portable-net40+sl5
Silverlight 5.0
Profile18 .NETFramework 4.0.3 portable-net403+sl4
Silverlight 4.0
Profile19 .NETFramework 4.0.3 portable-net403+sl5
Silverlight 5.0
Profile23 .NETFramework 4.5 portable-net45+sl4
Silverlight 4.0
Profile24 .NETFramework 4.5 portable-net45+sl5
Silverlight 5.0
Profile31 Windows 8.1 portable-win81+wp81 netstandard1.0
WindowsPhone 8.1 (SL)
Profile32 Windows 8.1 portable-win81+wpa81 netstandard1.2
WindowsPhone 8.1 (UWP)
Profile36 .NETFramework 4.0 portable-net40+sl4+win8+wp8
Silverlight 4.0
Windows 8.0
WindowsPhone 8.0 (SL)
Profile37 .NETFramework 4.0 portable-net40+sl5+win8
Silverlight 5.0
Windows 8.0
Profile41 .NETFramework 4.0.3 portable-net403+sl4+win8
Silverlight 4.0
Windows 8.0
Profile42 .NETFramework 4.0.3 portable-net403+sl5+win8
Silverlight 5.0
Windows 8.0
Profile44 .NETFramework 4.5.1 portable-net451+win81 netstandard1.2
Windows 8.1
Profile46 .NETFramework 4.5 portable-net45+sl4+win8
Silverlight 4.0
Windows 8.0
Profile47 .NETFramework 4.5 portable-net45+sl5+win8
Silverlight 5.0
Windows 8.0
Profile49 .NETFramework 4.5 portable-net45+wp8 netstandard1.0
WindowsPhone 8.0 (SL)
Profile78 .NETFramework 4.5 portable-net45+win8+wp8 netstandard1.0
Windows 8.0
WindowsPhone 8.0 (SL)
Profile84 WindowsPhone 8.1 portable-wp81+wpa81 netstandard1.0
WindowsPhone 8.1 (UWP)
Profile88 .NETFramework 4.0 portable-net40+sl4+win8+wp75
Silverlight 4.0
Windows 8.0
WindowsPhone 7.5
Profile92 .NETFramework 4.0 portable-net40+win8+wpa81
Windows 8.0
WindowsPhone 8.1 (UWP)
Profile95 .NETFramework 4.0.3 portable-net403+sl4+win8+wp7
Silverlight 4.0
Windows 8.0
WindowsPhone 7.0
Profile96 .NETFramework 4.0.3 portable-net403+sl4+win8+wp75
Silverlight 4.0
Windows 8.0
WindowsPhone 7.5
Profile102 .NETFramework 4.0.3 portable-net403+win8+wpa81
Windows 8.0
WindowsPhone 8.1 (UWP)
Profile104 .NETFramework 4.5 portable-net45+sl4+win8+wp75
Silverlight 4.0
Windows 8.0
WindowsPhone 7.5
Profile111 .NETFramework 4.5 portable-net45+win8+wpa81 netstandard1.1
Windows 8.0
WindowsPhone 8.1 (UWP)
Profile136 .NETFramework 4.0 portable-net40+sl5+win8+wp8
Silverlight 5.0
Windows 8.0
WindowsPhone 8.0 (SL)
Profile143 .NETFramework 4.0.3 portable-net403+sl4+win8+wp8
Silverlight 4.0
Windows 8.0
WindowsPhone 8.0 (SL)
Profile147 .NETFramework 4.0.3 portable-net403+sl5+win8+wp8
Silverlight 5.0
Windows 8.0
WindowsPhone 8.0 (SL)
Profile151 NETFramework 4.5.1 portable-net451+win81+wpa81 netstandard1.2
Windows 8.1
WindowsPhone 8.1 (UWP)
Profile154 .NETFramework 4.5 portable-net45+sl4+win8+wp8
Silverlight 4.0
Windows 8.0
WindowsPhone 8.0 (SL)
Profile157 Windows 8.1 portable-win81+wp81+wpa81 netstandard1.0
WindowsPhone 8.1 (SL)
WindowsPhone 8.1 (UWP)
Profile158 .NETFramework 4.5 portable-net45+sl5+win8+wp8
Silverlight 5.0
Windows 8.0
WindowsPhone 8.0 (SL)
Profile225 .NETFramework 4.0 portable-net40+sl5+win8+wpa81
Silverlight 5.0
Windows 8.0
WindowsPhone 8.1 (UWP)
Profile240 .NETFramework 4.0.3 portable-net403+sl5+win8+wpa8
Silverlight 5.0
Windows 8.0
WindowsPhone 8.1 (UWP)
Profile255 .NETFramework 4.5 portable-net45+sl5+win8+wpa81
Silverlight 5.0
Windows 8.0
WindowsPhone 8.1 (UWP)
Profile259 .NETFramework 4.5 portable-net45+win8+wpa81+wp8 netstandard1.0
Windows 8.0
WindowsPhone 8.1 (UWP)
WindowsPhone 8.0 (SL)
Profile328 .NETFramework 4.0 portable-net40+sl5+win8+wpa81+wp8
Silverlight 5.0
Windows 8.0
WindowsPhone 8.1 (UWP)
WindowsPhone 8.0 (SL)
Profile336 .NETFramework 4.0.3 portable-net403+sl5+win8+wpa81+wp8
Silverlight 5.0
Windows 8.0
WindowsPhone 8.1 (UWP)
WindowsPhone 8.0 (SL)
Profile344 .NETFramework 4.5 portable-net45+sl5+win8+wpa81+wp8
Silverlight 5.0
Windows 8.0
WindowsPhone 8.1 (UWP)
WindowsPhone 8.0 (SL)

Inoltre, i pacchetti NuGet destinati a Xamarin possono usare framework aggiuntivi definiti da Xamarin. Vedere Manually Creating NuGet Packages for Xamarin (Creazione manuale di pacchetti NuGet per Xamarin).

Nome Descrizione .NET Standard
monoandroid Supporto di Mono per sistema operativo Android netstandard1.4
monotouch Supporto di Mono per iOS netstandard1.4
monomac Supporto di Mono per OSX netstandard1.4
xamarinios Supporto di Xamarin per iOS netstandard1.4
xamarinmac Supporto di Xamarin per Mac netstandard1.4
xamarinpsthree Supporto di Xamarin su Playstation 3 netstandard1.4
xamarinpsfour Supporto di Xamarin su Playstation 4 netstandard1.4
xamarinpsvita Supporto di Xamarin su PS Vita netstandard1.4
xamarinwatchos Xamarin per Watch OS netstandard1.4
xamarintvos Xamarin per tvOS netstandard1.4
xamarinxboxthreesixty Xamarin per XBox 360 netstandard1.4
xamarinxboxone Xamarin per XBox One netstandard1.4

Nota

Stephen Cleary ha creato uno strumento che elenca le librerie di classi portabili supportate, disponibile nel suo post Framework profiles in .NET (Profili di framework in .NET).