Fukuoka .NET Conf
#fukuten #dotnetconf
.NET Core 3.0
for Windows Desktop
Yuta Ishibashi
@rupic_jp
IntroducAon
• Yuta Ishibashi (@rupic_jp)
• 製造業 品質管理
• 業務アプリケーション企画〜保守
• C# VB Javascript Python
• Oracle SQLServer Postgres
https://garrawayf.com/
・内製 or 外注 企画〜運⽤保守
・業務アプリケーション、製品の良否判定
検査設備の予防/予兆保全など
対象 :従業員
開発⾔語:C#
チームとしての役割
完成⾞両の品質管理に関する
アプリケーション作成
Fukuoka.NET
(ふくてん)
• Termination of .NET Framework and future of .NET Core
• Why Windows Desktop on .NET Core
• Convert Windows Desktop App
DEMO
• Portability Analyzer
• Try Convert
• WinForms Designer
Agenda
.NET
Termination of .NET Framework
and future of .NET Core
1.0 1.1 2.0 3.0 3.5 4.0 4.5 4.6 4.7 4.8
2000, XP
2000, XP,
Vista
2000,
XP, Vista, 7,
8, 8.1, 10
XP, Vista, 7, 8, 8.1, 10 XP, Vista, 7
Vista,
7, 8, 8.1
Vista, 7, 8,
8.1, 10
7, 8.1, 10,
10 Creators
Update
7, 8.1, 10
2000, 2003
2000, 2003,
2008
2000, 2003,
2008, 2012,
2016
2003, 2008, 2012, 2016 2003, 2008 2008, 2012
2008,
2012, 2016
2008, 2012,
2016
2008, 2012,
2016, 2019
2002 2003 2005 2008, 2010 2012 2013 2015 2017 2019
1.0 1.2 2.0 3.0 4.0 5.0 6.0 7.0 7.3
.NET Framework History
Jan.2002 Apr.2003 Nov.2005 Nov.2006 Nov.2007 Apr.2010 Aug.2012 Jul.2015 Apr.2017 Apr.2019
1.0 1.1 2.0 2.1 2.2 3.0
7, 8, 8.1, 10 7, 8, 8.1, 10 7, 8, 8.1, 10 7, 8, 8.1, 10 7, 8, 8.1, 10 7, 8, 8.1, 10
2012, 2016 2012, 2016 2012, 2016 2012, 2016 2012, 2016 2012, 2016
2015 Update 3
2015 Update 3,
2017
2017 15.5 2017 15.8.6 2017 15.9 2017 16.0, 2019
6.0 6.0 7.1 7.2 7.3 8.0
.NET Core History
Jun.2016 Mar.2017 Aug.2017 May.2018 Dec.2018 Sep.2019
.NET Schedule
July 2019
.NET Core
3.0
RC
Sept 2019
.NET Core
3.0
Nov 2019
.NET Core
3.1
LTS
Nov 2020
.NET 5.0
Nov 2021
.NET 6.0
LTS
Nov 2022
.NET 7.0
Nov 2023
.NET 8.0
LTS
https://devblogs.microsoft.com/dotnet/introducing-net-5/
Application models not included in .NET 5
ASP.NET Web Forms
→ Blazor
WF (Windows Workflow Foundation)
→ Open source core workflow for Windows workflow
WCF (Windows Communication Foundation)
→ gRPC for WCF server and remoting
.NET Framework 4.8 が
最後のメジャーバージョン
.NET Framework 4.8 〜
• サポートライフサイクルポリシーは変更なし
• インストール先のWindows OS と同じライフサイクルポリシーが適⽤
(参考) ライフサイクルに関する FAQ ‒ .NET Framework :
https://support.microsoft.com/ja-jp/help/17455/lifecycle-faq-net-framework
既存 .NET Framework ベースの
アプリケーションはそのまま利⽤可能
.NET
Why Windows Desktop
on .NET Core
• Deployment Flexibility
• side-by-side support
• Machine global or app local framework
• Self-contained EXEs
• Core runtime and API improvements
• Performance
Why Windows Desktop on .NET Core
.NET Core 3.0 ベースで Windows Forms, WPF アプリが開発可能に
※Windowsデスクトップ環境でのみ動作
leave on?
What will you do?
modernize?or
• 新しく作成するアプリケーション
> .NET Core 推奨
.NET Framework or .NET Coreの考え方参考
• 既存のアプリケーション
• 頻繁に開発されている
> .NET Core への移植を検討
• その他
> .NET FrameworkのままでOK
> そもそも必要なのか?の検討も
例 : とある部署の管理アプリケーション
1
5
15
43
50
0 10 20 30 40 50 60
ASP.NET Core MVC
Windows Service
ASP.NET MVC
WPF
WindowsForm
業務アプリケーション内訳
オンプレDBサーバー
.NET Framework 2.0 ~ 4.7.2
社内NuGet Serverでライブラリを管理
.NET Core 2.2
App Service + Azure SQL Server
1
0
13
30
15
0
5
2
13
35
0 10 20 30 40 50 60
ASP.NET Core MVC
Windows Service
ASP.NET MVC
WPF
WindowsForm
開発の状況
Active Completed
Desktop Appは継続的に開発しているものあり
Desktop→Webに変更も検討
ASP .NET MVCについては.NET Coreに移⾏中
.NET
Convert
Windows Desktop App
Overview of the porAng process
サードパーティの依存関係
サードパーティの依存関係
packages.config/PackageReferenceで確認
.NET Coreでも動作するのか?
Overview of the porting process
サードパーティの依存関係
.NET Framework 4.7.2 以降へ
再ターゲット
.NET Core で特定の API がサポートされない場合に、
.NET Framework 固有のターゲットに対して API の代替を
確実に使⽤できる
Overview of the porting process
サードパーティの依存関係
移植計画の作成
.NET Framework 4.7.2 以降へ
再ターゲット
.NET Framework とターゲットの .NET Core プラットフォームの間の
コードの移植性を調査
ターゲットの .NET Core プラットフォームにない型と API
⾮推奨API検出
互換性の問題
Portability Analyzer
https://aka.ms/portabilityAnalyzer 現在サポートされていない特定のAPIを含め、プロジェク
トと.NET Core 3.0との互換性のレベルを報告するExcelスプ
レッドシートを⽣成
⽣成した分析結果をMicrosoftの.NET チームへ送信し
ユーザーがよく使うAPIを把握
Visual Studio拡張機能 or 専⽤のWindows Form
.NETDemo:Portability Analyzer
Overview of the porAng process
サードパーティの依存関係
移植計画の作成
⾮推奨API検出
互換性の問題
.NET Framework 4.7.2 以降へ
再ターゲット
テストコードの移植
コードの移植時にテストを実⾏できるように、テストを移植
.NET Core Support:MSTest、NUnit、xUnit
.NETDemo:Try Convert
アセンブリ情報の生成を修正
.NET Framework で作成された Windows Forms プロジェクト
AssemblyInfo.cs (⽣成されるアセンブリのバージョンなどのアセンブリの属性を格納)
SDK スタイルのプロジェクト
プロジェクトファイルに基づいて⾃動⽣成
2つのAssemblyInfoが競合してしまう為、以下のエラーが発⽣
アセンブリ情報の生成を修正
⾃動⽣成を無効にして、既存の AssemblyInfo.cs ファイルを
プロジェクトに強制的に使⽤させることで解決
Microsoft.Windows.Compatibility
Microsoft.Windows.Compatibility
https://www.nuget.org/packages/Microsoft.Windows.Compatibility
Windows 専⽤ API やプラットフォーム⾮依存 API などを提供
•コード ページ
•CodeDom
•構成
•ディレクトリ サービス
•描画
•ODBC
•アクセス許可
•ポート
•Windows アクセス制御リスト (ACL)
•Windows Communication Foundation (WCF)
•Windows 暗号化
•Windows EventLog
•WMI (Windows Management Instrumentation)
•Windows パフォーマンス カウンター
•Windows レジストリ
•Windows ランタイム キャッシュ
•Windows サービス
• NuGet package Microsoft.Windows.Compatibility
• Can be referenced from .NET Core & .NET Standard
• Has ~21k APIs (Windows-only as well as cross-platform)
Microsoft.DotNet.Analyzers.Compatibility
.NET Core 3.0 でWindows Form を作成
旧ProjectのcsファイルをIncludeする
Form Design の変更
旧ProjectのcsファイルをIncludeしているので...
旧Project側を変更すればOK
Self-contained 自己完結型発行
コマンド
>dotnet publish -c Release --self-contained true -r win-x64
Visual Studio
実⾏環境のランタイムに依存しない
ユーザーにランタイムのパッチ適⽤等を任せなくて良い
memo
WinForms Designer Preview 1
Pointer
Button
Checkbox
CheckedListBox
ComboBox
DateTimePicker
Label
LinkLabel
ListBox
ListView
MaskedTextBox
MonthCalendar
NumericUpDown
PictureBox
ProgressBar
RadioButton
RichTextBox
TextBox
TreeView
Visual Studio 2019 v16.3.0 Preview 4 ~
サポートされているコントロールはまだ少ない
Give us your feedback via Visual Studio !!
Support Controls
https://aka.ms/winforms-designer
.NETDemo:WinForms Designer
WinForms Designer
WinForms Designer
Controlはまだ少ない
IDEとデザイナが通信を開始
.NET
まとめ
• .NET Frameworkに⽐べ性能が良い
• ⾃⼰完結型の展開が可能
• クライアントマシンのフレームワークに依存しない
• ランタイムのパッチ適⽤等の展開不要
• 今後実装されるであろう便利な機能が利⽤可能
.NET Core 3.0 へ移植するメリット
• 新しく作成するアプリケーション
> .NET Core 推奨
.NET Framework or .NET Coreの考え方参考
• 既存のアプリケーション
• 頻繁に開発されている
> .NET Core への移植を検討
• その他
> .NET FrameworkのままでOK
> そもそも必要なのか?の検討も
参考URL
https://www.nuget.org/packages/Microsoft.Windows.Compatibility
Windows Compatibility Pack
https://devblogs.microsoft.com/dotnet/introducing-net-core-windows-forms-designer-preview-1/
WinForms Designer Preview 1
hfps://docs.microsog.com/ja-jp/dotnet/standard/analyzers/portability-analyzer
.NET Portability Analyzer
https://docs.microsoft.com/ja-jp/dotnet/core/porting/
.NET Frameworkから .NET Coreにコードを移植
https://docs.microsoft.com/ja-jp/dotnet/core/whats-new/dotnet-core-3-0
.NET Core 3.0 の新機能
.NET
Thanks

Dotnetcore30forwindesktop