.net - dotnet 添加项目配置错误
问题描述
前段时间我评估了 .NET Core-CLI 的使用情况。这非常简单易用。我用它将几个项目添加到现有的解决方案文件中。在构建服务器上构建我的解决方案后,我有一个奇怪的行为。即使对于发布配置,也会构建调试配置。经过一番调查,我发现 .NET Core-CLI 的使用导致了这个问题。
我用一个空的解决方案复制了它,我只想添加一个项目。
空解决方案:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BD04E6CD-1AA7-4995-8A25-E0559BC2E184}
EndGlobalSection
EndGlobal
使用 Visual Studio 添加项目手册后:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BD04E6CD-1AA7-4995-8A25-E0559BC2E184}
EndGlobalSection
EndGlobal
一切看起来都很好,添加了 Debug 和 Release 的配置。
如果我尝试使用 .NET Core-CLI:
dotnet sln ClassLibrary1.sln add ClassLibrary1/ClassLibrary1.csproj
结果与我的预期结果有点不同:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}"
EndProject
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BD04E6CD-1AA7-4995-8A25-E0559BC2E184}
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Debug|x64.ActiveCfg = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Debug|x64.Build.0 = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Debug|x86.ActiveCfg = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Debug|x86.Build.0 = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Release|Any CPU.Build.0 = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Release|x64.ActiveCfg = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Release|x64.Build.0 = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Release|x86.ActiveCfg = Debug|Any CPU
{8492F4EC-BE0F-439A-B28F-E5DB871C9F95}.Release|x86.Build.0 = Debug|Any CPU
EndGlobalSection
EndGlobal
项目已成功添加,但所有配置都指向 Debug。这就是为什么还要在发布配置中构建调试的解释。
有人解释这种行为还是我做错了什么?
.Net Core 版本为 3.1.408.15681
解决方案
推荐阅读
- reactjs - 如何在 React Native 0.60+ 中更改第三方包
- sitefinity - 将按钮添加到动态模块后端列表 sitefinity
- firebase - 颤振:Firebase Google 身份验证不起作用
- sql - SQL - 前 n 个非空列
- node.js - 无法通过节点 js 连接到 MongoDB
- clojure - 如何防止评估 clojure 函数的参数?
- php - 无法检索存储在 Laravel 的 switch/case 中的会话
- eclipse-plugin - 使用 Eclipse SWT 核心表达式隐藏菜单项
- java - 这个变量是否覆盖
- python - 如何将从.txt文件解析的空字符串转换为None?