c# - Visual Studio Community 2019 creates a project but cannot open the project it created?
问题描述
I have Visual Studio Community 2019 v16.3.7.
According to dotnet --list-sdks
I have the following SDKs installed
2.1.802 [C:\Program Files\dotnet\sdk]
2.2.301 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Users\bugma\scoop\apps\dotnet-sdk\current\sdk]
I just created a .NET Core DLL project. It created the following sln
and csproj
files:
Solution:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {26BC7AEA-9E58-472D-8800-8D620A97AED6}
EndGlobalSection
EndGlobal
CSProj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
a Class1.cs file is also in the folder.
If I shutdown Visual Studio and launch Visual Studio from the .sln file, the Solution Explorer tells me that 0 projects have been loaded.
If I shutdown Visual Studio again and launch from the .csproj file, I get a dialog box that says, "One or more errors occurred." I click on the "OK" button and select "View > Output" and "View > Error List" but both panels are empty. So where do I find information about the error?
This is all a bit weird and frustrating. You'd expect that a project that Visual Studio creates is then able to be opened in Visual Studio and worked on.
LATER
I have stripped out the scoop
-installed dotnet SDK. Now dotnet --list-sdks
says
1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
This has not improved anything though.
解决方案
我认为您错过了 Project 文件中的 OutputType,因此它无法正常工作。请添加属性 <OutputType>Exe</OutputType>
。让我知道它是否对您有用
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
推荐阅读
- javascript - 为字符串的特定部分着色
- google-cloud-functions - Stackdriver Logging 未正确处理 Google Cloud Function 中的 python 退出(代码)堆栈跟踪,还有其他选择吗?
- python - 如何在 Python 的末尾发出声音?
- c++ - Debian gcc 不良行为
- jsf - 使用提交按钮调用 bean-method 并处理方法中文本字段的输入
- elasticsearch - 可以列出丢失数据的 UniqueID 的 Elasticsearch 查询
- c# - 在 EF Core 中自动填充 Created 和 LastModified
- algorithm - 证明 ak 级流水线最多可以比非流水线的快 k 倍
- c# - 我尝试使用 webBrowser1 更改链接
- php - 允许用户代表我从 Google 云端硬盘下载文件