ASP.NET Core 2.0 的 Microsoft.AspNetCore.All 中繼套件Microsoft.AspNetCore.All metapackage for ASP.NET Core 2.0

注意

建議以 ASP.NET Core 2.1 及更新版本為目標的應用程式使用 Microsoft.AspNetCore.App 中繼套件,而非此套件。We recommend applications targeting ASP.NET Core 2.1 and later use the Microsoft.AspNetCore.App metapackage rather than this package. 請參閱本文章中的從 Microsoft.AspNetCore.All 移轉到 Microsoft.AspNetCore.AppSee Migrating from Microsoft.AspNetCore.All to Microsoft.AspNetCore.App in this article.

這項功能需要以 .NET Core 2.x 為目標的 ASP.NET Core 2.x。This feature requires ASP.NET Core 2.x targeting .NET Core 2.x.

Microsoft.AspNetCore.All (英文) 是參考共用架構的中繼套件。Microsoft.AspNetCore.All is a metapackage that refers to a shared framework. 「共用的架構」是一組不在應用程式資料夾內的組件 (.dll 檔案)。A shared framework is a set of assemblies (.dll files) that are not in the app's folders. 共用的架構必須安裝於要執行應用程式的機器上。The shared framework must be installed on the machine to run the app. 如需詳細資訊,請參閱共用的架構 (英文)。For more information, see The shared framework.

Microsoft.AspNetCore.All 所參考的共用架構包含:The shared framework that Microsoft.AspNetCore.All refers to includes:

  • 所有由 ASP.NET Core 小組支援的套件。All supported packages by the ASP.NET Core team.
  • 所有由 Entity Framework Core 支援的套件。All supported packages by the Entity Framework Core.
  • ASP.NET Core 與 Entity Framework Core 所使用的內部與第三人相依性。Internal and 3rd-party dependencies used by ASP.NET Core and Entity Framework Core.

Microsoft.AspNetCore.All 套件包含 ASP.NET Core 2.x 和 Entity Framework Core 2.x 的所有功能。All the features of ASP.NET Core 2.x and Entity Framework Core 2.x are included in the Microsoft.AspNetCore.All package. 以 ASP.NET Core 2.0 為目標的預設專案範本會使用此套件。The default project templates targeting ASP.NET Core 2.0 use this package.

Microsoft.AspNetCore.All 中繼套件的版本號碼代表最低的 ASP.NET Core 版本和 Entity Framework Core 版本。The version number of the Microsoft.AspNetCore.All metapackage represents the minimum ASP.NET Core version and Entity Framework Core version.

下列 .csproj 檔案參考 ASP.NET Core 的 Microsoft.AspNetCore.All 中繼套件:The following .csproj file references the Microsoft.AspNetCore.All metapackage for ASP.NET Core:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
  </ItemGroup>

</Project>

隱含的版本設定Implicit versioning

在 ASP.NET Core 2.1 或更新版本中,您可指定不含版本的 Microsoft.AspNetCore.All 套件參考。In ASP.NET Core 2.1 or later, you can specify the Microsoft.AspNetCore.All package reference without a version. 當未指定版本時,SDK (Microsoft.NET.Sdk.Web) 會指定隱含的版本。When the version isn't specified, an implicit version is specified by the SDK (Microsoft.NET.Sdk.Web). 建議依賴 SDK 指定的隱含版本,而不要明確設定套件參考的版本號碼。We recommend relying on the implicit version specified by the SDK and not explicitly setting the version number on the package reference. 如果您對此方法有疑問,請在 Discussion for the Microsoft.AspNetCore.App implicit version (Microsoft.AspNetCore.App 隱含版本討論區) 留下 GitHub 意見。If you have questions about this approach, leave a GitHub comment at the Discussion for the Microsoft.AspNetCore.App implicit version.

可攜式應用程式的隱含版本會設定為 major.minor.0The implicit version is set to major.minor.0 for portable apps. 共用架構向前復原機制會在已安裝共用架構中的最新相容版本上,執行應用程式。The shared framework roll-forward mechanism runs the app on the latest compatible version among the installed shared frameworks. 為了保證開發、測試和生產均使用相同版本,請務必在所有環境中安裝相同版本的共用架構。To guarantee the same version is used in development, test, and production, ensure the same version of the shared framework is installed in all environments. 針對獨立應用程式,隱含版本號碼會設定為已安裝 SDK 隨附共用架構的 major.minor.patchFor self-contained apps, the implicit version number is set to the major.minor.patch of the shared framework bundled in the installed SDK.

Microsoft.AspNetCore.All 套件參考上指定版本號碼保證會選擇該版本的共用架構。Specifying a version number on the Microsoft.AspNetCore.All package reference does not guarantee that version of the shared framework is chosen. 例如,假設指定版本 "2.1.1",但安裝 "2.1.3"。For example, suppose version "2.1.1" is specified, but "2.1.3" is installed. 在此情況下,應用程式會使用 "2.1.3"。In that case, the app will use "2.1.3". 您可以停用向前復原 (修補及/或次要),但不建議這樣做。Although not recommended, you can disable roll forward (patch and/or minor). 如需 dotnet 主機向前復原及如何設定其行為的詳細資訊,請參閱 dotnet 主機向前復原For more information regarding dotnet host roll-forward and how to configure its behavior, see dotnet host roll forward.

在專案檔中,專案的 SDK 必須設定為 Microsoft.NET.Sdk.Web,才能使用 Microsoft.AspNetCore.All 的隱含版本。The project's SDK must be set to Microsoft.NET.Sdk.Web in the project file to use the implicit version of Microsoft.AspNetCore.All. 當指定 Microsoft.NET.Sdk SDK 時 (專案檔頂端的 <Project Sdk="Microsoft.NET.Sdk">),就會產生以下警告:When the Microsoft.NET.Sdk SDK is specified (<Project Sdk="Microsoft.NET.Sdk"> at the top of the project file), the following warning is generated:

警告 NU1604:專案相依性 Microsoft.AspNetCore.All 不包含界限下限 (含)。請在相依性版本包含下限,以確保還原結果一致。Warning NU1604: Project dependency Microsoft.AspNetCore.All does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.

這是.NET Core 2.1 SDK 的已知的問題,並將於 .NET Core 2.2 SDK 中修正。This is a known issue with the .NET Core 2.1 SDK and will be fixed in the .NET Core 2.2 SDK.

從 Microsoft.AspNetCore.All 移轉到 Microsoft.AspNetCore.AppMigrating from Microsoft.AspNetCore.All to Microsoft.AspNetCore.App

下列套件隨附於 Microsoft.AspNetCore.All,而不是 Microsoft.AspNetCore.App 套件。The following packages are included in Microsoft.AspNetCore.All but not the Microsoft.AspNetCore.App package.

  • Microsoft.AspNetCore.ApplicationInsights.HostingStartup
  • Microsoft.AspNetCore.AzureAppServices.HostingStartup
  • Microsoft.AspNetCore.AzureAppServicesIntegration
  • Microsoft.AspNetCore.DataProtection.AzureKeyVault
  • Microsoft.AspNetCore.DataProtection.AzureStorage
  • Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv
  • Microsoft.AspNetCore.SignalR.Redis
  • Microsoft.Data.Sqlite
  • Microsoft.Data.Sqlite.Core
  • Microsoft.EntityFrameworkCore.Sqlite
  • Microsoft.EntityFrameworkCore.Sqlite.Core
  • Microsoft.Extensions.Caching.Redis
  • Microsoft.Extensions.Configuration.AzureKeyVault
  • Microsoft.Extensions.Logging.AzureAppServices
  • Microsoft.VisualStudio.Web.BrowserLink

若要從 Microsoft.AspNetCore.All 移到 Microsoft.AspNetCore.App,如果您的應用程式使用來自上述套件的任何 API,或這些套件中隨附的套件,請將參考新增到專案中的這些套件。To move from Microsoft.AspNetCore.All to Microsoft.AspNetCore.App, if your app uses any APIs from the above packages, or packages brought in by those packages, add references to those packages in your project.

若前述套件的任何相依性不是 Microsoft.AspNetCore.App 的相依性,即不包含在內。Any dependencies of the preceding packages that otherwise aren't dependencies of Microsoft.AspNetCore.App are not included implicitly. 例如:For example:

  • StackExchange.RedisMicrosoft.Extensions.Caching.Redis 的相依性StackExchange.Redis as a dependency of Microsoft.Extensions.Caching.Redis
  • Microsoft.ApplicationInsightsMicrosoft.AspNetCore.ApplicationInsights.HostingStartup 的相依性Microsoft.ApplicationInsights as a dependency of Microsoft.AspNetCore.ApplicationInsights.HostingStartup

更新 ASP.NET Core 2.1Update ASP.NET Core 2.1

建議您移轉到 Microsoft.AspNetCore.App 中繼套件 2.1 與更新版本。We recommend migrating to the Microsoft.AspNetCore.App metapackage for 2.1 and later. 若要繼續使用 Microsoft.AspNetCore.All 中繼套件並確保已部署最新的更新程式版本:To keep using the Microsoft.AspNetCore.All metapackage and ensure the latest patch version is deployed:

  • 在開發電腦和組建伺服器上:安裝最新的 .NET Core SDKOn development machines and build servers: Install the latest .NET Core SDK.
  • 在部署伺服器上:安裝最新的 .NET Core 執行階段On deployment servers: Install the latest .NET Core runtime. 您的應用程式會在應用程式重新開機時,向前復原到已安裝的最新版本。Your app will roll forward to the latest installed version on an application restart.