简体   繁体   English

仅在 Windows 上:net5.0-windows(或 net6.0-windows)是否允许我在 .Net 5(或 .Net 6)中重新编译 .Net 框架?

[英]On Windows only: does net5.0-windows (or net6.0-windows) allow me to recompile .Net framework in .Net 5 ( or .Net 6)?

I have .Net framework apps, that are intended to run only on Windows, now and forever.我有 .Net 框架应用程序,旨在仅在 Windows 上运行,现在和永远。

I am thinking about upgrading them to .Net 5 or .Net 6, and target them to net5.0-windows (or net6.0-windows ).我正在考虑将它们升级到 .Net 5 或 .Net 6,并将它们定位到net5.0-windows (或net6.0-windows )。 From MS website it says thatMS 网站它说

net5.0-windows will be used to expose Windows-specific functionality, including Windows Forms, WPF and WinRT APIs. net5.0-windows 将用于公开特定于 Windows 的功能,包括 Windows 窗体、WPF 和 WinRT API。

Does that mean that my .Net framework apps can be recompiled in .Net 6, as long as I specify the net-windows target and the csproject upgrade and compilation is successful, the program will just work ?这是否意味着我的.Net框架应用程序可以在.Net 6中重新编译,只要我指定net-windows目标并且csproject升级和编译成功,程序就可以运行 I just intend them to run on Windows, now and always .我只是想让它们现在和始终在 Windows 上运行

My apps also consume a lot of .Net framework 2.0/3.5/4.6 dlls ( mostly they are involved with OpenGL and other graphic things), which I can only assume to have no general port to .Net 5 or .Net 6, and which the source code is no longer available even to me ( they are from close-source third party providers).我的应用程序还使用了大量 .Net 框架 2.0/3.5/4.6 dll(主要涉及 OpenGL 和其他图形内容),我只能假设它们没有通向 .Net 5 或 .Net 6 的通用端口,并且即使对我来说,源代码也不再可用(它们来自封闭源代码的第三方供应商)。

Does that mean that my .Net framework apps can be recompiled in .Net 6,这是否意味着我的 .Net 框架应用程序可以在 .Net 6 中重新编译,

Yes是的

the program will just work?该程序将正常工作?

Most likely it will, but one should do a full regression test to verify.很可能会,但应该做一个完整的回归测试来验证。

My apps also consume a lot of .Net framework 2.0/3.5/4.6 dlls我的应用程序也消耗了很多 .Net framework 2.0/3.5/4.6 dll

If you can't migrate to .Net 4.8, then chances are slim that one can be able to migrate into .Net core.如果您无法迁移到 .Net 4.8,那么您能够迁移到 .Net 核心的可能性就很小。

( mostly they are involved with OpenGL and other graphic things), which I can only assume to have no general port to .Net 5 or .Net 6 (他们大多与 OpenGL 和其他图形相关),我只能假设没有到 .Net 5 或 .Net 6 的通用端口

Each one has to be taken on as a case by case basis;每一个都必须根据具体情况进行处理; you may have just actually answered your own question.您可能刚刚真正回答了您自己的问题。 Say Goodnight Gracey...说晚安格蕾丝...


What may better serve you is to create a docker container which will serve up the older versions of these app(s) which has the target version of the frameworks which currently work.更好地为您服务的是创建一个 docker 容器,它将为这些应用程序的旧版本提供服务,这些应用程序具有当前可用的框架的目标版本。

Unfortunately there is no definitive answer to your question, as it will depend (no pun intended) entirely on what your dependencies are.不幸的是,您的问题没有明确的答案,因为它完全取决于(不是双关语)您的依赖项是什么。

.NET 5 was intended to be the unification of classic .NET Framework and .NET Core and in many cases it will just work . .NET 5 旨在成为经典 .NET Framework 和 .NET Core 的统一,并且在许多情况下它会正常工作

Speaking from experience, in many cases it is easier to create a clean project in the new framework, copy all the existing files from the old project then re-add NuGet and project references.从经验上讲,在很多情况下,在新框架中创建一个干净的项目更容易,从旧项目中复制所有现有文件,然后重新添加 NuGet 和项目引用。 I have done this successfully for Console Apps, Test Projects and even a WinForms app 15-20 project dependencies to .NET 4.8 projects and it has worked out of the box - albeit with a compiler warning about the .NET 4.8 dependencies.我已经成功地为控制台应用程序、测试项目,甚至是 WinForms 应用程序 15-20 项目依赖项到 .NET 4.8 项目,它已经开箱即用 - 尽管有关于 .NET 4.8 依赖项的编译器警告。

However I have also come across at least one missing / changed API between 4.8 and 5.0 - BeginInvoke .但是,我也遇到了 4.8 和 5.0 之间至少有一个缺失/更改的 API - BeginInvoke A blog post here describes it in more detail. 此处的博客文章更详细地描述了它。 Sometimes there are also issues with NuGet versions.有时,NuGet 版本也存在问题。

The closest thing to a definitive list online is the MS Doc "Changes that affect compatibility" and in particular the Breaking changes for migration from .NET Framework to .NET Core section.最接近在线最终列表的是MS Doc“影响兼容性的更改” ,特别是从 .NET Framework 迁移到 .NET Core 的重大更改部分。 I'm not sure the is a better "answer from a reputable source" out there.我不确定这是一个更好的“来自信誉良好的来源的答案”。

As for your .NET 2.0 / 3.5 / 4.6 dlls I don't think there is anyway of knowing without trying.至于您的 .NET 2.0 / 3.5 / 4.6 dll,我认为不尝试就不会知道。 There are simply too many unknowns, especially as they are 3rd party dlls.有太多的未知数,尤其是因为它们是 3rd 方 dll。 If I had to guess it would be that at least one won't work, whether you can find an updated version or how much work an alternative library will be to incorporate will be impossible to tell如果我不得不猜测至少有一个不起作用,那么您是否可以找到更新版本或替代库将包含多少工作将无法确定

As for net5.0-windows , it's basically a fudge.至于net5.0-windows ,它基本上是一个软糖。 While the goal of everything .NET 5.0 onwards was unification and cross-platform everything, they couldn't get all the work done in time.虽然 .NET 5.0 以后的所有目标都是统一和跨平台的,但他们无法及时完成所有工作。 I read a blob post about it, which I can't find right now, but basically WinForms in particular is very closely tied to some underlying Windows only APIs.我读了一篇关于它的 blob 帖子,我现在找不到,但基本上 WinForms 尤其与一些底层的 Windows API 密切相关。 Maybe .NET 7.0?也许.NET 7.0?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM