[英]Targeting Multiple Runtimes When Publishing a .NET Core App
I want to create a self contained web application using .NET Core. 我想使用.NET Core创建一个自包含的 Web应用程序。 I want to target any version of Windows and have this in my project.json
: 我想定位到任何版本的Windows,并将其放在我的project.json
:
"runtimes": {
"win10-x64": { },
"win8-x64": { },
"win7-x64": { }
}
When I run dotnet publish --runtime win10-x64
I can only specify a single runtime to publish at a time. 当我运行dotnet publish --runtime win10-x64
我只能指定一次要发布的单个运行时。 I then have to maintain three copies of my binaries. 然后,我必须维护我的二进制文件的三个副本。
Is it possible to publish my app for all three runtimes and copy that folder around as a completely self contained application? 是否可以为所有三个运行时发布我的应用程序,并将该文件夹复制为一个完全自包含的应用程序?
When you create a self-contained application, it contains all dependencies it needs to run. 创建自包含应用程序时,它包含运行所需的所有依赖项。 As far as I can tell, the only different between publishing to the various versions of Windows is that for older versions, some dependencies that are built-in in the newer versions have to be bundled in. 据我所知,发布到Windows的各个版本之间的唯一区别是,对于较旧的版本,必须捆绑一些较新版本中内置的依赖项。
This means that if you want to have one version of your self-contained application that runs on all supported versions of Windows, you can: just use the oldest version of Windows ( win7-x64
). 这意味着,如果您希望拥有一个可以在所有受支持的Windows版本上运行的自包含应用程序的版本,则可以:仅使用Windows的最旧版本( win7-x64
)。
The same approach probably won't work on Linux, since Linux generally does not maintain binary compatibility between versions. 由于Linux通常不维护版本之间的二进制兼容性,因此相同的方法可能不适用于Linux。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.