简体   繁体   中英

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.

I think you have missed the OutputType in Project file, So that, it's not working properly. Please add the property <OutputType>Exe</OutputType> . Let me know, whether it's worked for you or not

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

<PropertyGroup>
    <OutputType>Exe</OutputType>
  <TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

</Project>

If you transferred the project file some important files must have been lost.This is the only reason for your trouble.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM