The project file is incomplete. No expected imports

After formatting the computer, I reinstalled Vs 2017 V 15.6.3 and installed the ASP.Net Core SDK from Microsoft 2.1.4

But when I create a new asp core VS application failed with an error

"The project file has not been completed. The expected import is missing."

Can someone please help?

Error after while creating ASP core application

+76
source share
33 answers

Decided

  1. Even after deleting a specific version from the control panel, files and folders with the deleted version will be found in C: \ Program Files \ dotnet \ sdk

  2. Please go and delete the folder with the unwanted version

  3. Try reloading the project.

It worked for me

+9
source

I had the same problem. In my case, removing global.json and appsettings solved the problem.

+58
source

You can check the global.json file, which you can find in the root directory of the solution, and make sure that the target version of the SDK is installed on your computer, or upgrade it to the one that is already installed, for example, if you have installed the SDK version 2.1 .4. your global.json should look like this

{ "sdk": { "version": "2.1.400" } } 
+19
source

Repairing the latest Core installation worked for me

+18
source

Another potential reason is that you installed a version of .NET Core that is not compatible with Visual Studio . This may not be related to the original OP question, as it relates to different version numbers, but since I got to this page looking for help, I thought it might be useful for others.

At the time of this writing, I installed .NET Core 2.2.203, which is not compatible with Visual Studio 2017 (Professional 15.9.11).

The .NET Core download page contains a separate download for Visual Studio 2017. Be sure to download it if you intend to use Visual Studio 2017. The current supported version of .NET Core 2.2.106 .

+17
source

In my case, I had two versions of Visual Studio installed (15.7 and 15.6). 15.7 did not have installed web loads, although the .net 2.1 RC1 kernel was already installed. I installed the asp.net workload in VS2017 and then fixed the .net kernel installation for a good measure. Definitely something in this process reversed my c: \ program files (x86) \ dotnet and c "\ program files \ dotnet along this path, and Visual Studio (15.7) will not open my web project.

I just edited the System Environment variables, moved the x86 folder down one and voila - opened Visual Studio again, and now it loaded my project. System environment variables

+15
source

Eh, a beginner’s error, I had Visual Studio SSDT open and I tried to open an existing .Net Core project that produces the same error:

"The project file has not been completed. The expected import is missing."

The solution was to use Visual Studio, not SSDT, see Help> About:

enter image description here

+13
source

Recently, I solved this problem a couple of times by closing Visual Studio and running the following commands

  1. nuguet locals -c all
  2. will hold clean
  3. reaches the build

There seem to be times, especially at the beginning of projects when nuget crashes (technical term).

+8
source

After installing VS2019 , I got the same error when opening existing .Net Core solutions in VS2017.
In the Visual Studio installer, I updated VS2017 to the latest version (15.9.11), and the problem disappeared.

Later, after upgrading VS2019 to the latest version, I got the same errors and had to upgrade VS2017 again.

+7
source

I started getting this error when I uninstalled all my old .NET Core SDKs and installed the latest, 2.1.5 at the time of publication. I tried all the solutions here without any luck, so I decided to check the current version of the SDK after all the errors that I made, because I thought it was causing a problem, and I was right - I ran the command line and wrote dotnet --version and I received the message "Did you want to run the dotnet SDK commands? Please install the dotnet SDK from:". Strange, the SDK is installed, but the system does not see it. Then I looked in my environment variables, and the PATH variable contained the x86 path for dotnet in front of the usual Program Files (x64 one) path. Therefore, I moved x64 to x86 and voila, everything returned to normal.

I hope I helped someone.

+5
source

I have the same problem. I could not create a new ASP.Net Core 2 on a new installed VS2017 or open an existing one that works fine on another computer with VS2017.

It started working for me after removing all .NET Core Runtime and .NET Core Windows Server Hosting from Windows. SDKs were left only and everything works, finally. enter image description here

I probably only needed to remove the .NET Core Runtime or .NET Core Windows Server Hosting from Windows, and that would be enough.

+4
source

I had the same symptoms from the damaged dotnet kernel SDK (from the command line I could not start dotnet -v where I could before). My project failed to load after the installation of the IIS web platform failed. Reinstalling the .NET core SDK resolved the issue.

+3
source

The only thing that worked for me was to update Visual studio:

enter image description here

enter image description here

+3
source

in my case, I went to the C: \ Program Files \ dotnet \ sdk folder, deleted the sdk preview folder, then at the command prompt I ran:

Reaching SDK 2.1.200

Install the correct version of the SDK for the asp.net kernel. this solved the problem.

+2
source

I had the same problem. I calmed down a bit to figure this out. In my case, I tried to open a new ASP.NET Core application and got 0 projects similar to the one described in this post.

What I tried: I tried to change environment variables in Control Panel \ System and Security \ System (click advanced settings)

enter image description here

Then click Environment Variables

enter image description here

Then check if the dotnet path is included, whether it is in the "Program Files" or "Program Files" (x86) section enter image description here

Some people have suggested moving up (x86) up based on Microsoft documentation

What solved my problem: it turned out that I had the wrong version installed and it was not compatible with Visual Studio 2017 enter image description here

Then I deleted the other installations and reinstalled the version that is compatible with VS17 and works like magic. Hope this helps someone in the future.

+2
source

Thanks guys, I reinstalled the old version of visual studio 2017 and it works well. My version is VS 15.4 and that's fine

+1
source

This happened to me when I deleted the instance of Visual Studio VS2015 that worked for me next to VS2017.

I had to exit and reinstall the .Net Core SDK / Runtime with x86. I already manually made x64 versions of these versions, but did not think about Visual Studio running in the 32-bit version.

These are the files:

  • Dotnet-sdk-haya-win-win x86.exe

  • DotNetCore.xxx-WindowsHosting.exe

+1
source

I ran into the same problem. I ran my project on .Net core 2.2. I tried every solution given here, but nothing worked. I repaired my visual studio and now it works fine.

+1
source

I solved this problem by changing the first line in the .csproj file from:

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

so that:

 <Project Sdk="Microsoft.NET.Sdk"> 
+1
source

I ran into the same problem. Below is a screenshot

enter image description here

0
source

I had the same problem with an ASP.net Core 2.0 project after I installed DotNetCore.2.0.5-WindowsHosting Framework on my development machine. I was able to solve this problem after uninstalling the WindowsHosting Framework and all .net Core packages. After that, I reinstalled the dotnet-sdk-2.1.200-win-x64 package and everything worked fine.

0
source

Removing the bin and obj folders for the project fixed this for me.

0
source

Same problem ... it took me a while to find out. Since I was working on an ASP.NET Core project targeting .NET Core 1.1, I thought I still needed the installed .NET Core 1.1 SDK. Since I also had the .NET Core SDK 2.1 installed, a conflict arose and I could not open the project file. After uninstalling .NET Core 1.1, I was able to open my project.

0
source

Run dotnet restore at the command prompt to resolve.

Tip. If you uninstalled the latest version of the .net kernel, say 2.1.403, and installed the previous one, make sure that the 2.1.403 folder is really deleted along the path

C: \ Program Files \ dotnet \ sdk \

I had a problem due to the fact that there remained an empty folder from 2.1.403

0
source

Delete all generated bin and obj folders . This worked for me after renaming the project and trying to reload the solution. Not quite sure about the true reason for incompatible downloads.

0
source

I am having the same problem and I am starting Visual again with administrative privileges. This helps me open the project by number.

0
source

It turns out that my project depended on another project in a solution that could not solve the problems with NuGet dependencies, which, in turn, was due to the fact that the target platform in the project properties was empty.

I opened the .csproj file to check the target framework, downloaded the target framework and selected “repair”, then restarted Visual Studio and everything was fine again!

0
source

Installing the latest version of dot net core worked for me.

0
source

I had the same problem when installing the new pre-release version of VS 2019. I fixed it by uninstalling the latest update, which in turn removed the latest downloaded version of the kernel. Which I suppose caused a mismatch.

0
source

I decided to update Visual Studio 2017 to 15.9.11 for me (I can’t remember the version that didn’t work). Perhaps repairing Visual Studio would also work. Restoring a .NET Core installation and clearing build artifacts and temporary files did not help.

0
source

Source: https://habr.com/ru/post/1276022/


All Articles