编译并调试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="..frameworkGrapeCity.Framework.InputMan.csproj" />
    <ProjectReference Include="..inputInput.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="D:PersonalDataGitHubwinformsartifactsinWinformsControlsTestDebug
etcoreapp5.0System.Windows.Forms.dll" />
    <Reference Include="D:PersonalDataGitHubwinformsartifactsinWinformsControlsTestDebug
etcoreapp5.0System.Windows.Forms.Primitives.dll" />
    <Reference Include="D:PersonalDataGitHubwinformsartifactsinWinformsControlsTestDebug
etcoreapp5.0
untimeswinlib
etcoreapp3.0System.Drawing.Common.dll" />
    <Reference Include="D:PersonalDataGitHubwinformsartifactsinSystem.Windows.Forms.TestsDebug
etcoreapp5.0System.Security.Permissions.dll" />
    <Reference Include="C:Program FilesdotnetsharedMicrosoft.NETCore.App5.0.0-preview.4.20216.4Microsoft.Win32.Registry.dll" />
  </ItemGroup>

</Project>
原文地址:https://www.cnblogs.com/chenyingzuo/p/12716474.html