编译并调试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>
复制代码

 

posted @   内心澎湃的水晶侠  阅读(617)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 【杂谈】分布式事务——高大上的无用知识?
点击右上角即可分享
微信分享提示