.NET Core 是否有任何 GAC 等效项?

Is there any GAC equivalent for .NET Core?

正如我目前在完整的 .NET Framework 中所了解的那样,当我们将框架安装到计算机时,它将整个 BCL 部署到计算机的 GAC。这样,当我们使用 .NET 开发软件并部署到该计算机时,它将使用 BCL 程序集,这些程序集在安装 .NET Framework 本身时在 GAC 中可用。

现在,据我所知,CoreFX 相当于新 .NET Core 的 BCL。然而,主要区别在于我们可以在 project.json 中准确指定我们需要哪些 CoreFX。

我的问题是:当我们部署 .NET Core 应用程序时,生产环境中是否有任何 GAC 等效项?那么,当我们部署要执行的应用程序时,应用程序会在计算机中查看整个 CoreFX 是否可用的中央位置吗?

不,不是,不是您对 GAC 的看法。核心应用程序应该相互隔离,因此您可以修补其中一个而不用担心影响其他应用程序。您可以使用该应用运送您需要的所有包裹。

有一个服务目录可用于发布核心组件的更新,但它会将它们完全换出,不启用并排版本控制,并且仅适用于通过 Microsoft Update 发布的更新。

编辑 2017-09-01

有点类似于 GAC,.NET Core 2.0 引入了“Runtime package store”:

Starting with .NET Core 2.0, it's possible to package and deploy apps against a known set of packages that exist in the target environment. The benefits are faster deployments, lower disk space use, and improved startup performance in some cases.

This feature is implemented as a runtime package store, which is a directory on disk where packages are stored (typically at /usr/local/share/dotnet/store on macOS/Linux and C:/Program Files/dotnet/store on Windows).


您正在寻找 "Framework-dependent deployment"。来自 the docs:

You can create two types of deployments for .NET Core applications:

  • Framework-dependent deployment. As the name implies, framework-dependent deployment (FDD) relies on a shared system-wide version of .NET Core to be present on the target system. Because .NET Core is already present, your app is also portable between installations of .NET Core. Your app contains only its own code and any third-party dependencies that are outside of the .NET Core libraries. FDDs contain .dll files that can be launched by using the dotnet utility from the command line. For example, dotnet app.dll runs an application named app.

  • Self-contained deployment. Unlike FDD, a self-contained deployment (SCD) does not rely on any shared components to be present on the target system. All components, including both .NET Core libraries and the .NET Core runtime, are included with the application and are isolated from other .NET Core applications. SCDs include an executable (such as app.exe on Windows platforms for an application named app), which is a renamed version of the platform-specific .NET Core host, and a .dll file (such as app.dll), which is the actual application.