更新时间:2022-10-19 18:56:27
我遇到了类似的错误(请参阅此问题:Swagger-codegen:为 .NET Core 构建 Pet Store 示例时出错)
对我来说修复是运行 dotnet migrate
更新项目以使用 .csproj
并移动 .xproj
和 >project.json
挡路.
此处的更多信息:https://docs.microsoft.com/en-us/dotnet/core/migration/#dotnet-migrate
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
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.
dotnet --info
[ Update 15.Mar.2017] Per @Leo-MSFT's request, here's the output of dotnet --info
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