c#工程由传统的.NET Framework格式改成SDK格式

.NET Framework格式

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\...\Microsoft.Common.props" .../>
  <PropertyGroup>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>   ← 老式属性
    <UseWPF>true</UseWPF>                                    ← 这行在这里是无效的
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System.Windows.Forms"/>              ← 老式程序集引用
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Form1.cs"/>                            ← 每个 .cs 手工登记
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project>

改成新的SDK风格

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net48</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <UseWPF>true</UseWPF>
    <RootNamespace>Host.Lab.WinForms</RootNamespace>
    <AssemblyName>Host.Lab.WinForms</AssemblyName>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\..\MDVision.Sdk\MDVision.Sdk.csproj" />
    <ProjectReference Include="..\..\..\MDVision.Plugins.Communication\MDVision.Plugins.Communication.csproj" />
    <ProjectReference Include="..\..\..\MDVision.Plugins.Diagnostics\MDVision.Plugins.Diagnostics.csproj" />
  </ItemGroup>

</Project>

删掉下面的文件
Properties\AssemblyInfo.cs

posted @ 2026-09-14 15:22  大馒头不好吃  阅读(8)  评论(0)    收藏  举报