如何创建.NET Core 2.0项目?VS2017创建项目遇导入缺失错误求助
Fixing "Project file is incomplete. Expected imports are missing" Error & Creating .NET Core 2.0 Projects
Troubleshooting the Project Import Error
Let’s work through the error you’re hitting first. Since you noted the issue ties to the folder structure C:\Novatek.Monitoring.Web..., here are targeted fixes to resolve it:
- Use a simpler folder path: The dotted structure in your project directory (like
Novatek.Monitoring.Web) can confuse Visual Studio’s project file parser, which might misinterpret the dots as nested namespace or project markers. Try creating the project in a path without consecutive dots, e.g.,C:\Projects\NovatekMonitoringWeb, and check if the error clears up. - Check and repair your .csproj file: Right-click the problematic project in Solution Explorer, select Edit
.csproj , and verify these critical import lines exist:
If they’re missing, add them manually, save the file, and reload the project.<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.Web" /> <!-- Other project configurations --> <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.Web" /> - Clear Visual Studio’s component cache: Close VS completely, then delete all files in the folder
%LOCALAPPDATA%\Microsoft\VisualStudio\15.0_*\ComponentModelCache(replace*with your specific VS instance ID). Restart VS and try opening the project again. - Repair your VS installation: Even though you selected the Web and .NET Core workloads during reinstall, some components might be corrupted. Open the Visual Studio Installer, select your 2017 installation, click Modify, then choose Repair to ensure all required components are properly set up.
Creating a New .NET Core 2.0 Project
Here’s a step-by-step guide to building a valid empty ASP.NET Core 2.0 project in VS 2017 15.6.2:
- Open Visual Studio 2017 and click Create a new project.
- In the search bar, type ASP.NET Core Web Application, select the matching template, then click Next.
- Enter your project name, pick a save path (stick to simple, non-dotted paths to avoid the earlier error), and click Create.
- In the "New ASP.NET Core Web Application" window:
- Under Select a template, choose Empty.
- Ensure Target framework is set to .NET Core 2.0 (if this option is missing, confirm the .NET Core 2.0 SDK and related workloads are installed via the VS Installer).
- Click Create to finish setting up the project.
If you need to create a .NET Core 2.0 console project (which you mentioned works fine), the process is similar: search for Console App (.NET Core) in the project templates, select it, and confirm the target framework is set to .NET Core 2.0 during setup.
内容的提问来源于stack exchange,提问作者Horosho
相关产品推荐
相关产品推荐

