ASP.Net Core Web API Build Error - MSB4019 The imp

2019-07-26 08:36发布

I am getting the following error in my ASP.Net Core Web API Project, after I added Sqlite Reference (see below) and also changed the Microsoft.NETCore.App dependency version in project.json from 1.0.1 (which was working) to 1.1.0 (which is breaking the build with the following error).

Error MSB4019 The imported project "C:\Program Files\dotnet\sdk\1.0.1\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. Cities.API C:\Shiva\PluralSight\Cities.API\Cities.API.xproj 8

Please don't mark this as duplicate of either

  1. External VS2013 build error “error MSB4019: The imported project was not found” or
  2. External VS2013 build error “error MSB4019: The imported project was not found”

I looked at these 2 and they apply to Visual Studio 2013 and not the .Net Core version, which has a different project and config file structure.

Here's my projects.json

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Mvc.Formatters.Xml": "1.0.1",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "NLog.Extensions.Logging": "1.0.0-rtm-alpha5",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.1.1",
    "Microsoft.EntityFrameworkCore.Sqlite.Design": "1.1.1",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0",
    "AutoMapper": "5.2.0",
    "Microsoft.AspNetCore.ResponseCompression": "1.0.0"
  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

and here's the error message when I do a build with the new updated 1.1.0 for the Microsoft.NETCore.App dependency. NOTE: the 1.1.0 does show up in the intellisense dropdown when I did the beginning " which means that it is present on my machine.

enter image description here

Output of dotnet --info

[ Update 15.Mar.2017] Per @Leo-MSFT's request, here's the output of dotnet --info

enter image description here

1条回答
趁早两清
2楼-- · 2019-07-26 08:39

I had a similar error (see this question: Swagger-codegen: error building Pet Store example for .NET Core)

The fix for me was to run dotnet migrate which updates the project to use a .csproj and moves the .xproj and project.json out of the way.

More information here: https://docs.microsoft.com/en-us/dotnet/core/migration/#dotnet-migrate

查看更多
登录 后发表回答