2017-02-24 69 views
0

我下载的下载” .NET核心1.0.1工具预览版2"从这个链接: 未能建立或恢复ASP.NET核心项目

当我开始我的Visual Studio中,我尝试清洁并重建我创建的项目(ASP.NET Core)。

当我重建时,我从ASPNETCore库和扩展中收到很多错误,所以下一步是尝试通过软件包管理器控制台调用dotnet恢复。

但是我得到这个错误:

"error: Error reading JToken from JsonReader. Path '', line 1, position 1454."

任何想法,我都忘记了?

步骤来我的问题:

  1. 安装DotNetCore
  2. 启动Visual Studio并创建ASP.NET核心的Web应用程序(.NET核心)
  3. 干净,项目已创建
  4. 后重建
  5. 如果它不起作用,去包管理控制台并键入“dotnet恢复”

我的问题的片段:(

enter image description here

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

也许你在'nuget.Config'中改变了你的nuget repository配置设置,这就是为什么它找不到任何nuget软件包?如果您在项目目录中手动运行'dotnet restore'会怎么样? –

+0

根本没有改变nuget.Config中的任何内容。我通过PowerShell手动运行dotnet恢复。仍然得到相同的错误 –

+0

什么是你定义的依赖关系,它似乎出现了一些错误。也许nuget会尝试读取某些内容,但响应时间过长,因此它会被截断,Jreader无法解析字符串。但我不会为你解决。 (您可以使用提琴手来查看当您执行'dotnet restore'时发生的http请求。 –

回答

0

解决了这个问题! 对于正在经历(或将要)的其他人。 记得清除NuGet缓存。

nuget.exe locals -clear all 

并运行你的项目

dotnet restore 

1

从我所看到这里,你已经创建了一个.NET的核心项目在项目中增加了对.NET框架4.6的支持.json文件:

"frameworks": { 
    "net46": { } 
    }, 

这可能会导致与依赖关系兼容性的一些问题。您可以在屏幕上看到很多错误,如IHostingEnvironmentConfigurationBuilder。因为你已经确立了自己intelissence为.NET 4.6(https://i.imgur.com/retgjzF.png

一个“简单”的方法来解决这个错误你有这样的错误,是通过更换您的frameworks部分删除的.NET 4.6的支持:

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

您将只支持.NET框架的核心,并避免与其他框架兼容性错误(如.NET 4.6,等...)

我想你也忘了添加这种依赖性:

"Microsoft.NETCore.App": { 
     "version": "1.0.1", 
     "type": "platform" 
    }, 

希望它有帮助。

+0

尝试过。 –

相关问题