`dotnet sln add`错误的项目类型GUID(`dotnet sln add` wrong project type GUID)

编程入门 行业动态 更新时间:2024-10-28 14:34:38
`dotnet sln add`错误的项目类型GUID(`dotnet sln add` wrong project type GUID)

当我为.NET核心/标准项目dotnet sln add {myProject.csproj} ,它将它添加为项目类型(我认为) {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}而不是.NET Core的{9A19103F-16F7-4668-BE54-9A1E7A4F7556} 。 因此,当我在Visual Studio中打开解决方案时,它会抱怨并将csproj “升级”为.NET Framework csproj ,而不是.NET Core。 我可以手动编辑sln但它是一件杂事。

难道我做错了什么? 我缺少的论据吗?

When I do dotnet sln add {myProject.csproj} for a .NET Core/Standard project, it adds it as project type (I think) {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} instead of .NET Core's {9A19103F-16F7-4668-BE54-9A1E7A4F7556}. Hence, when I open the solution in Visual Studio, it complains and "upgrades" the csproj to a .NET Framework csproj, not a .NET Core one. I can manually edit the sln but its a chore.

Am I doing something wrong? Are there arguments I'm missing?

最满意答案

CLI实际上在做正确的事情,这是一个VS / Project系统错误。

CLI调用msbuild以获取要使用的默认项目类型GUID。 MSBuild将C#和VB项目的$(DefaultProjectTypeGuid)为“经典”项目,以允许CLI将“经典”和“SDK风格”项目添加到解决方案中。

传统的GUID( FAE04EC0… )会触发一个选择逻辑,查看项目中是否设置了TargetFramework或TargetFrameworks ,以确定是否使用“新”或“经典”项目系统。 这个想法是,在某些时候只有新的项目系统会被使用,并且经典的项目系统可能不再是VS在未来更新中的一部分(这是GitHub上很多评论的基调)。

根据记录的GitHub问题 ,错误在于当新项目系统被选中时,解决方案被更新为VS /解决方案不应该看到的“新”GUID。

The CLI is actually doing the right thing here, this is a VS/Project System bug.

The CLI calls into msbuild to get the default project type GUID to use. MSBuild sets the $(DefaultProjectTypeGuid) for C# and VB projects to the "classic" one to allow the CLI to add both "classic" and "SDK-style" projects to a solution.

The classic GUID (FAE04EC0…) is then triggering a selection logic that looks if TargetFramework or TargetFrameworks is set in the project to determine if the "new" or "classic" project systems will be used. The idea is that at some point only the new project system will be used and the classic project system may no longer be part of VS in some future update (this is the tone of a lot of comments on GitHub).

According to the logged GitHub issue, the bug is that when the new project system is elected, the solution is updated to the "new" GUID which VS/the solution shouldn't see.

更多推荐

本文发布于:2023-07-22 20:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1223277.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   类型   项目   add   dotnet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!