1
votes

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

2
Do you have two version of the CLI installed? Could you please provide the dotnet info to us? You can get that info by type “dotnet --info” on the Package Manager Console. What is the build result if you create a new ASP.Net Core Web API Project without any modification?Leo Liu-MSFT
Hi, 1) How to tell if I have 2 versions of CLI installed? 2) I've provided the dotnet info as an update (see the end of my question above). 3) I created a new ASP.Net Core Web API Project from scratch and that builds (no errors). The strangest thing is, I went back to a working version of the Project before adding sqlite or changing Microsoft.Netcore.App and even that project is popping up that error message as soon as I opened it in VS 2015. I can send you a zip of it if you like (it's a PluralSight walkthrough I wrote, so nothing confidential in code).Shiva
thanks for you reply. what is the build result after you change the sdk version to "1.0.0-preview2-003131" in the global.json? If sdk not found, please download from go.microsoft.com/fwlink/?LinkID=830694 and install it, restart VS, then build it again. if not works, Please upload the file to onedrive.live.com and share the link here.Leo Liu-MSFT
@ Shiva, what about this issue? Would you please let me know the latest information about this issue?Leo Liu-MSFT

2 Answers

1
votes

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

0
votes

For .Net Core , Same error code and I was not able to run ef commands in command line. Check this solutions, It works for me.

https://stackoverflow.com/a/58024947/1415927