You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何创建.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:
    <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.Web" />
    <!-- Other project configurations -->
    <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.Web" />
    
    If they’re missing, add them manually, save the file, and reload the project.
  • 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:

  1. Open Visual Studio 2017 and click Create a new project.
  2. In the search bar, type ASP.NET Core Web Application, select the matching template, then click Next.
  3. Enter your project name, pick a save path (stick to simple, non-dotted paths to avoid the earlier error), and click Create.
  4. 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:12:00