景安网站备案表格,如何使用wordpress模板,网页版梦幻西游36天罡攻略,廊坊做网站的企业哪家好迁移 WinForm 应用从 dotnet framework 到 dotnetcore3.0Intro微软从 dotnetcore3.0 开始已经开始支持 wpf 以及 winform 的开发#xff0c;dotnet core 3.0 preview7 已经发布#xff0c;官方称已经可以准备上生产了 Production Ready迁移这篇WPF的迁移还是比较不错的#… 迁移 WinForm 应用从 dotnet framework 到 dotnetcore3.0Intro微软从 dotnetcore3.0 开始已经开始支持 wpf 以及 winform 的开发dotnet core 3.0 preview7 已经发布官方称已经可以准备上生产了 Production Ready迁移这篇WPF的迁移还是比较不错的如果第一次迁移强烈推荐看一下 https://www.cnblogs.com/hippieZhou/p/10661181.html迁移的过程还算比较顺利因为我的依赖都是 netstandard2.0 和 net462项目格式也都是用的新的项目格式项目格式和包引用方式都无需修改。主要变更原来 winform 项目的依赖大都是 TargetFrameworksnet462;netstandard2.0/TargetFrameworks 现在直接去除 net462只保留 netstanard2.0 变更为 TargetFrameworknetstandard2.0/TargetFrameworkWinform 项目项目文件修改修改 TargetFramework 为 netcoreapp3.0 并且设置 UseWindowsFormstrue/UseWindowsForms如果是 WPF 项目需要设置 UseWPFtrue/UseWPF在 netframework 下我自己封装的一个基础类库 WeihanLi.Common 中有一个 ConfigurationHelper 的帮助类可以帮助更方便的获取和更新配置最初也是支持 netstandard2.0 的但是后面为了减少依赖就去掉了去 netstandard2.0 的支持这里我直接把这个文件添加到 winform 的项目中可以直接使用 完整的 ConfigurationHelper 代码单元测试的修改单元测试原来是 net462改成了netcoreapp2.1原来配置文件用的 app.config, 迁移到 dotnetcore 下面使用 appsettings.json 来代替了。单元测试依赖注入原来使用的 AutoFac现在改成微软的依赖注入框架了。完整的迁移过程可以参考这个 commit https://github.com/WeihanLi/DbTool/commit/8ea3fa8a01f951af565162c290d5af7d16511fdb发布微软从 netcore3.0 preview 5 支持开始发布成单文件可以使用下面的命令来发布成单文件dotnet publish -r win-x64 -c Release /p:PublishSingleFiletrue发布完看一下文件大小172M。。。我的天啊感觉好大虽然说集成了运行所需要的所有环境但还是觉得有些大在网上找一些解决办法发现从 dotnetcore3.0 preview6 开始支持一个 PublishTrimmed 的参数可以减小发布出来文件的大小下面我们来试一下dotnet publish -r win-x64 -c Release /p:PublishSingleFiletrue /p:PublishTrimmedtrue再看一下发布的文件的大小109M虽然还是很大可以看到相比没有 trim 还是小了很多。使用 PublishTrimmed 来压缩文件大小的时候会使用 ilinker 来减小文件的大小详细参考 https://github.com/dotnet/core/blob/master/samples/linker-instructions.md需要注意的是发布之后最好测试一下因为有时候可能会有问题参考这篇文章 https://dotnetcoretutorials.com/2019/06/27/the-publishtrimmed-flag-with-il-linker/ 这篇文章给出了一个使用反射 trim 发布之后不能正常工作的示例Referencehttps://devblogs.microsoft.com/dotnet/are-your-windows-forms-and-wpf-applications-ready-for-net-core-3-0/https://devblogs.microsoft.com/dotnet/announcing-net-core-3-0-preview-7/https://dotnetcoretutorials.com/2019/06/20/publishing-a-single-exe-file-in-net-core-3-0/https://dotnetcoretutorials.com/2019/06/27/the-publishtrimmed-flag-with-il-linker/https://www.cnblogs.com/hippieZhou/p/10661181.htmlhttps://github.com/dotnet/winformshttps://github.com/dotnet/wpf