ターゲット フレームワーク

NuGet では、さまざまな場所でターゲット フレームワーク参照を使用して、パッケージのフレームワークに依存するコンポーネントを具体的に識別して分離します。

  • プロジェクト ファイル: SDK スタイルのプロジェクトの場合、 .csproj にはターゲット フレームワーク参照が含まれています。
  • .nuspec マニフェスト: パッケージは、プロジェクトのターゲット フレームワークに応じて、プロジェクトに含める個別のパッケージを示すことができます。
  • .nupkg フォルダー名: パッケージの lib フォルダー内のフォルダーには、ターゲット フレームワークに従って名前を付けることができます。各フォルダーには、そのフレームワークに適した DLL とその他のコンテンツが含まれています。
  • packages.config: 依存関係の targetframework 属性は、インストールするパッケージのバリアントを指定します。

サポートされているすべてのターゲット フレームワークとその TFM 構文の正規リストについては、 SDK スタイルのプロジェクトのターゲット フレームワークに関するページを参照してください。

TargetFramework 値はエイリアスです

プロジェクト ファイル内の TargetFramework プロパティは、正規フレームワーク ID に変換されるフレンドリ名 (別名) です。 .NET SDK は、 TargetFrameworkMoniker (TFM) を設定し、該当する場合は TargetPlatformMoniker プロパティを設定することで、この変換を実行します。

たとえば、 <TargetFramework>net10.0-windows</TargetFramework>を記述すると、.NET SDK によって次のように変換されます。

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

NuGet は、パッケージの互換性チェックのために、 TargetFramework 文字列ではなく、これらのモニカー プロパティを使用します。 つまり、モニカーのプロパティが正しく設定されている限り、 TargetFramework 値自体は任意の文字列にすることができます。 たとえば、次のプロジェクトは有効です。

<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>

このプロジェクトは、 TargetFramework 値が bananaされている場合でも、.NET 10.0 用に復元およびビルドされます。 .NET SDK は、 net8.0-iosnet8.0-androidなどの OS 固有の TFM に対して、このエイリアシング メカニズムに既に依存しています。短い TFM はプラットフォーム情報を使用して完全なモニカーに変換されます。

重複するフレームワークを使用したマルチターゲット

NuGet 7.6 / .NET SDK 10.0.300 以降では、複数のTargetFrameworksエイリアスを同じ効果的なフレームワークに解決できます。 これにより、マルチ RID ビルドやマルチバージョン拡張機能のターゲット設定などのシナリオが可能になります。 復元、パック、ロック ファイル、およびプロジェクト参照での動作の詳細については、「 複数のフレームワークのターゲット設定」を参照してください。

サポートされているフレームワーク

フレームワークは通常、短いターゲット フレームワーク モニカーまたは TFM によって参照されます。 .NET Standard では、これは TxM に一般化され、複数のフレームワークへの 1 つの参照が可能になります。

以下の表を計算する NuGet クライアントのソース コードは、次の場所にあります。

NuGet クライアントは、次の表のフレームワークをサポートしています。 同等の値は角かっこ [] 内に表示されます。 dotnetなどの一部のツールでは、一部のファイルで正規の TFM のバリエーションが使用される場合があることに注意してください。 たとえば、dotnet packでは、netcoreapp2.0ではなく、.nuspec ファイル内の.NETCoreApp2.0が使用されます。 さまざまな NuGet クライアント ツールはこれらのバリエーションを適切に処理しますが、ファイルを直接編集するときは常に正規の TFM を使用する必要があります。

名前 略称 TFM/TxMs
.NET Framework net net11
ネット20
net35
ネット40
ネット403
net45
net451
net452
net46
net461
net462
net47
net471
net472
net48 (ネット48)
Microsoft Store (Windows ストア) netcore netcore [netcore45]
netcore45 [win, win8]
netcore451 [win81]
netcore50
.NET MicroFramework .NET Micro Framework(ネットマイクロフレームワーク) .NET Micro Framework(ネットマイクロフレームワーク)
ウィンドウズ 勝利 win [win8, netcore45]
win8 [netcore45, win]
win81 [netcore451]
win10 (Windows 10 プラットフォームではサポートされていません)
Silverlight sl sl4
sl5
Windows Phone (SL) Wp wp [wp7]
wp7
wp75
wp8
wp81
Windows Phone (UWP) wpa81
ユニバーサル Windows プラットフォーム Uap uap [uap10.0]
uap10.0
uap10.0.xxxxx (10.0.xxxxx は、使用しているアプリのターゲット プラットフォーム最小バージョンです)
.NET Standard netstandard netstandard1.0
netstandard1.1
netstandard1.2
netstandard1.3
netstandard1.4
netstandard1.5
netstandard1.6
netstandard2.0
netstandard2.1
.NET 5+ (および .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
net9.0
net10.0
タイゼン Tizen tizen3
tizen4
Native ネイティブ ネイティブ

非推奨のフレームワーク

次のフレームワークは非推奨です。 これらのフレームワークを対象とするパッケージは、指定された置換に移行する必要があります。

非推奨のフレームワーク Replacement
aspnet50 netcoreapp
aspnetcore50
dnxcore50
dnx
dnx45
dnx451
dnx452
dotnet netstandard
dotnet50
dotnet51
dotnet52
dotnet53
dotnet54
dotnet55
dotnet56
winrt 勝利

優先順位

多くのフレームワークは相互に関連し、互換性がありますが、必ずしも同等であるとは限りません。

フレームワーク 使用可能
uap (ユニバーサル Windows プラットフォーム) Windows 8.1
wpa81
netcore50
win (Microsoft Store) winrt

NET Standard

.NET Standard では、バイナリ互換フレームワーク間の参照が簡略化され、1 つのターゲット フレームワークが他のフレームワークの組み合わせを参照できるようになります。 (背景については、 .NET 入門を参照してください)。

NuGet Get Nearest Framework ツールは、NuGet がプロジェクトのフレームワークに基づいてパッケージ内の多数の利用可能なフレームワーク資産から 1 つのフレームワークを選択するために使用するものをシミュレートします。

nuGet 3.3 以前では、 dotnet 一連のモニカーを使用する必要があります。 netstandard モニカー構文は v3.4 以降で使用する必要があります。

ポータブル クラス ライブラリ

Warnung

PCL は推奨されません。 PCL はサポートされていますが、パッケージ作成者は代わりに netstandard をサポートする必要があります。 .NET Platform Standard は PCL の進化であり、 ポータブル a+b+c モニカーのような静的ライブラリに関連付けられていない単一モニカーを使用して、プラットフォーム間のバイナリ 移植性を表します。

複数の子ターゲット フレームワークを参照するターゲット フレームワークを定義するには、 portable キーワードを使用して、参照されるフレームワークの一覧の前に付けます。 これらのフレームワークでは意図しない副作用が発生する可能性があるため、直接コンパイルされない追加のフレームワークを人為的に含めないでください。

サード パーティによって定義された追加のフレームワークは、この方法でアクセスできる他の環境との互換性を提供します。 さらに、関連するフレームワークのこれらの組み合わせを Profile#として参照できる短縮形のプロファイル番号がありますが、フォルダーと .nuspecの読みやすさが低下するため、これらの数値を使用することは推奨されません。

プロファイル# フレームワーク 氏名 .NET Standard
プロファイル2 .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)

さらに、Xamarin を対象とする NuGet パッケージでは、追加の Xamarin 定義フレームワークを使用できます。

名前 説明 .NET Standard
monoandroid Android OS の Mono サポート netstandard1.4
monotouch iOS の Mono サポート netstandard1.4
monomac OSX の Mono サポート netstandard1.4
xamarinios Xamarin for iOS のサポート netstandard1.4
xamarinmac Xamarin for Mac のサポート netstandard1.4
xamarinpsthree Playstation 3 での Xamarin のサポート netstandard1.4
xamarinpsfour Playstation 4 での Xamarin のサポート netstandard1.4
xamarinpsvita PSVit での Xamarin のサポート netstandard1.4
xamarinwatchos Xamarin for Watch OS netstandard1.4
xamarintvos Xamarin for TV OS netstandard1.4
xamarinxboxthreesixty XBox 360 用 Xamarin netstandard1.4
xamarinxboxone Xamarin for XBox One netstandard1.4

Stephen Cleary は、サポートされている PCL を一覧表示するツールを作成しました。このツールは、 .NET の投稿の Framework プロファイルで確認できます。