Condividi tramite


Framework di destinazione

NuGet usa riferimenti al framework di destinazione in un'ampia gamma di posizioni per identificare e isolare in modo specifico i componenti dipendenti dal 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 pacchetti distinti da includere in un progetto a seconda del framework di destinazione del progetto.
  • Nome cartella .nupkg: le cartelle all'interno della cartella di lib un pacchetto possono essere denominate in base al framework di destinazione, ognuna delle quali contiene le DLL e altro contenuto appropriato per tale framework.
  • packages.config: l'attributo targetframework di una dipendenza specifica la variante di un pacchetto da installare.

Per l'elenco canonico di tutti i framework di destinazione supportati e la relativa sintassi TFM, vedere Framework di destinazione nei progetti in stile SDK.

I valori targetFramework sono alias

La TargetFramework proprietà in un file di progetto è un nome descrittivo, un alias, che viene convertito in un'identità del framework canonica. .NET SDK esegue questa conversione impostando ( TargetFrameworkMoniker TFM) e, se applicabile, le TargetPlatformMoniker proprietà.

Ad esempio, quando si scrive <TargetFramework>net10.0-windows</TargetFramework>, .NET SDK lo converte in:

  • TargetFrameworkMoniker = .NETCoreApp,Version=v10.0
  • TargetPlatformMoniker = Windows,Version=7.0

NuGet usa queste proprietà del moniker, non la stringa, per i controlli di TargetFramework compatibilità dei pacchetti. Ciò significa che il TargetFramework valore stesso può essere qualsiasi stringa, purché le proprietà del moniker siano impostate correttamente. Ad esempio, il progetto seguente è valido:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>banana</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(TargetFramework)' == 'banana' ">
    <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
    <TargetFrameworkMoniker>.NETCoreApp,Version=v10.0</TargetFrameworkMoniker>
  </PropertyGroup>
</Project>

Questo progetto ripristina e compila per .NET 10.0, anche se il TargetFramework valore è banana. .NET SDK si basa già su questo meccanismo di aliasing per tfm specifici del sistema operativo come net8.0-ios e net8.0-android, dove il tfm breve viene convertito nel moniker completo con informazioni sulla piattaforma.

Multitargeting con framework duplicati

A partire da NuGet 7.6 / .NET SDK 10.0.300, più TargetFrameworks alias possono essere risolti nello stesso framework efficace. Ciò consente scenari come compilazioni multi-RID e destinazione dell'estensione a più versioni. Per informazioni dettagliate su come funziona con il ripristino, il pacchetto, i file di blocco e i riferimenti al progetto, vedere Targeting di più framework.

Framework supportati

Un framework viene in genere fatto riferimento da un moniker del framework di destinazione breve o TFM. In .NET Standard viene generalizzato anche in TxM per consentire un singolo riferimento a più framework.

Annotazioni

Il codice sorgente del client NuGet che calcola le tabelle seguenti è disponibile nelle posizioni seguenti:

I client NuGet supportano i framework nella tabella seguente. Gli equivalenti vengono visualizzati tra parentesi quadre []. Si noti che alcuni strumenti, ad esempio dotnet, potrebbero usare varianti di TFM canoniche in alcuni file. Ad esempio, dotnet pack usa .NETCoreApp2.0 in un .nuspec file anziché netcoreapp2.0. I vari strumenti client NuGet gestiscono correttamente queste varianti, ma è consigliabile usare sempre tfm canonici durante la modifica diretta dei file.

Nome Abbreviazione TFMs/TxMs
.NET Framework rete 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
MicroFramework .NET netmf netmf
Windows vincere / vittoria 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
rete net5.0
net6.0
net7.0
net8.0
net9.0
net10.0
Tizen tizen tizen3
tizen4
Native nativo nativo

Framework deprecati

I framework seguenti sono deprecati. I pacchetti destinati a questi framework devono eseguire la migrazione alle sostituzioni indicate.

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

Precedenza

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

Struttura Può utilizzare
uap (piattaforma UAP )UAP (Universal Windows Platform) Windows 8.1
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 ciò che NuGet usa per selezionare un framework da molti asset framework disponibili in un pacchetto basato sul framework del progetto.

La serie di moniker deve essere usata in NuGet 3.3 e versioni precedenti. La dotnetnetstandard sintassi del moniker deve essere usata nella versione 3.4 e successive.

Librerie di classi portabili

Avvertimento

Le licenze CAL non sono consigliate. Anche se le licenze CAL sono supportate, gli autori di pacchetti devono invece 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 figlio-target,la portable parola chiave usata per anteporre l'elenco di framework a cui si fa riferimento. Evitare l'inclusione artificiale di framework aggiuntivi non compilati direttamente rispetto a perché può causare effetti collaterali imprevisti in tali framework.

Altri framework definiti da terze parti garantiscono la compatibilità con altri ambienti accessibili in questo modo. Inoltre, sono disponibili numeri di profilo abbreviati per fare riferimento a queste combinazioni di framework correlati come Profile#, ma questa non è una procedura consigliata per usare questi numeri perché riduce la leggibilità delle cartelle e .nuspec.

Profilo # Frameworks 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 Xamarin definiti aggiuntivi:

Nome Descrizione .NET Standard
monoandroide Supporto mono per il sistema operativo Android netstandard1.4
monotouch Supporto mono per iOS netstandard1.4
monomac Supporto mono per OSX netstandard1.4
xamarinios Supporto per Xamarin per iOS netstandard1.4
xamarinmac Supporto per Xamarin per Mac netstandard1.4
xamarinpsthree Supporto per Xamarin in Playstation 3 netstandard1.4
xamarinpsfour Supporto per Xamarin in Playstation 4 netstandard1.4
xamarinpsvita Supporto per Xamarin in PS Vita netstandard1.4
xamarinwatchos Sistema operativo Xamarin for Watch netstandard1.4
xamarintvos Xamarin per il sistema operativo TV netstandard1.4
xamarinxboxthreesixty Xamarin per XBox 360 netstandard1.4
xamarinxboxone Xamarin per XBox One netstandard1.4

Annotazioni

Stephen Cleary ha creato uno strumento che elenca i PCL supportati, che è possibile trovare nel suo post, Profili framework in .NET.