编译并调试Dot Net Core WindowsForm 源代码
1. 克隆源代码:
https://github.com/dotnet/winforms
2. 安装项目需要的 .net core sdk:
运行这个脚本:
方法:
1. 输入PowerShell,并右键管理员权限打开
2. 输入Set-ExecutionPolicy RemoteSigned
3. 输入A,回车
4. & "路径\xxx.ps1"
3.到克隆的仓库,找到工程文件,直接用VS2019打开,编译
4.编译成功
调试源代码:
1. 新建一个 winform .net core 工程
2. 手动加引用,引用之前产出的dll
3. 编写代码,简单测试,创建一个 TextBox,并添加到窗体里
4.运行,打断点,调试
F11,跟进去看看创建时 dot net core都做了什么事情
记录一个简单的winform工程文件,专门为调试源代码用:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>netcoreapp5.0</TargetFramework> <!--<UseWindowsForms>true</UseWindowsForms>--> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\xxx.csproj" /> <ProjectReference Include="..\xxx.csproj" /> </ItemGroup> <ItemGroup> <Reference Include="D:\PersonalData\GitHub\winforms\artifacts\bin\WinformsControlsTest\Debug\netcoreapp5.0\System.Windows.Forms.dll" /> <Reference Include="D:\PersonalData\GitHub\winforms\artifacts\bin\WinformsControlsTest\Debug\netcoreapp5.0\System.Windows.Forms.Primitives.dll" /> <Reference Include="D:\PersonalData\GitHub\winforms\artifacts\bin\WinformsControlsTest\Debug\netcoreapp5.0\runtimes\win\lib\netcoreapp3.0\System.Drawing.Common.dll" /> <Reference Include="D:\PersonalData\GitHub\winforms\artifacts\bin\System.Windows.Forms.Tests\Debug\netcoreapp5.0\System.Security.Permissions.dll" /> <Reference Include="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.0-preview.4.20216.4\Microsoft.Win32.Registry.dll" /> </ItemGroup> </Project>