我从此链接下载了下载" .NET Core 1.0.1工具预览2" : https://www.microsoft.com/net/core#windowsvs2015
当我启动visual studio时,我尝试清理并重建我创建的项目(ASP.NET Core)。
当我重建时,我从ASPNETCore库和扩展中得到了很多错误,因此下一步是尝试通过Package Manager控制台调用dotnet restore。
但是我收到了这个错误:
"错误:从JsonReader读取JToken时出错。路径'',第1行, 位置1454。"
知道我忘记了什么吗?
我的问题的步骤:
我的问题片段:(
project.json文件:
{
"dependencies": {
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"net46": { }
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
答案 0 :(得分:1)
从我在这里看到的,您创建了一个.NET Core项目,在project.json文件中添加了对.NET Framework 4.6的支持:
"frameworks": {
"net46": { }
},
这可能会导致依赖项兼容性方面的一些问题。您可以在屏幕上看到很多错误,例如IHostingEnvironment
或ConfigurationBuilder
。您有这个错误,因为您已经为.NET 4.6(https://i.imgur.com/retgjzF.png)
解决此错误的一种“简单”方法是通过将frameworks
部分替换为:
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
}
您只支持.NET Core框架并避免与其他框架(如.NET 4.6等)的兼容性错误。
我猜你也忘了添加这种依赖:
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
希望它有所帮助。
答案 1 :(得分:0)
解决了这个问题! 对于正在经历这种情况(或将要去)的其他人。 请记住清除NuGet缓存。
nuget.exe locals -clear all
并运行
dotnet restore
关于你的项目!