You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何判断.csproj使用.NET Project System还是Common Project System?

How to Identify Your C# Project's System (New vs. Legacy CPS) & Who Controls It

Great question! Let’s break this down into two clear, actionable parts: how to spot which project system your C# project uses, and who’s actually calling the shots here.

Ways to Identify the Project System

  • Check the .csproj file directly (most reliable)

    • New Project System (SDK-style): The file starts with <Project Sdk="Microsoft.NET.Sdk"> (or variants like Microsoft.NET.Sdk.Web for web projects). It’s super streamlined—you’ll see minimal boilerplate, with key settings like <TargetFramework>net8.0</TargetFramework> instead of scattered, verbose properties. No messy <Import> statements for old MSBuild common props/targets, and almost never any <ProjectTypeGuids> entries.
    • Legacy Common Project System (CPS): The file opens with a basic <Project> tag (no Sdk attribute). You’ll find imports like <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" /> and <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />. It’ll also have explicit properties like <AssemblyName>MyLegacyProject</AssemblyName> and <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>, plus often <ProjectTypeGuids> for specialized project types (e.g., WPF/WinForms).
  • Visual Studio UI Clues

    • New SDK-style projects load faster and have a simplified Properties window (with tabs like Application, Build, Debug focused on modern .NET settings). Right-clicking the project will show clean, direct options like Add > Class without clunky legacy submenus.
    • Legacy CPS projects may take longer to load, have a more cluttered Properties window with classic .NET Framework settings, and might use a legacy project icon (e.g., a yellow class library instead of the modern blue .NET icon).
  • Command Line Build Behavior

    • New SDK-style projects work seamlessly with dotnet build/dotnet run CLI commands. Run these on a legacy CPS project, and you’ll get errors telling you to use MSBuild directly—legacy projects don’t support the .NET CLI.

Who Controls the Project System Type?

Short answer: Your .csproj file dictates which project system Visual Studio uses—not the other way around.

Visual Studio detects the project format from the .csproj and loads the corresponding system automatically:

  • If the file uses the SDK-style structure, VS fires up the new Project System.
  • If it’s the legacy non-SDK format, VS falls back to the older CPS.

That said, VS version does play a small role: Older versions (pre-2019) don’t support SDK-style projects at all, but modern VS (2019+) works with both. As you noted, Microsoft is phasing out CPS, so migrating to SDK-style projects is recommended for better performance, CLI support, and long-term compatibility.

内容的提问来源于stack exchange,提问作者Turner Bass

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:20:10