得到奇怪的编译错误 - .Net Core

时间:2016-09-30 12:05:07

标签: .net-core asp.net-core-1.0 project.json

我不确定我最近做了什么。但这一直持续到一周前。当我试图编译项目时突然间。它给了我8463编译错误。下面给出了一些。

enter image description here

如果你们中的任何人以前遇到过这个问题,请帮帮我。我正在使用.net核心应用程序1.0.0。但是我的电脑上也安装了1.0.1。

当我尝试使用dotnet build cli进行编译时,我收到以下错误消息。

  

找不到框架的运行时目标' .NETCoreApp,Version = v1.0'与目标运行时之一兼容:' win7-x64'。可能的原因:

     
      
  1. 项目尚未恢复或恢复失败 - 运行dotnet restore
  2.   
  3. 该项目没有列出其中一个' win7-x64'在'运行时'部分。
  4.   
  5. 您可能正在尝试发布不受支持的库。使用dotnet pack分发库。
  6.   

我已经跑了dotnet restore。我不确定第二点。因为它之前在同一台机器上工作。

此外,我还没有runtimes

中提到的任何project.json部分

更新:

如其他帖子所述。我添加了

  "runtimes": {
        "win7-x64": { }
      }

但没有工作。

Project.Json:

{
  "userSecretsId": "aspnet-IdentityServer-db76f1cf-15a8-4dc0-8200-221a224b454c",
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.DependencyInjection": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Caching.Abstractions": "1.0.0",
    "Microsoft.Extensions.Caching.Memory": "1.0.0",
    "System.Security.Cryptography.Algorithms": "4.2.0",
    "Serilog": "2.2.1",
    "Serilog.Sinks.Literate": "2.0.0",
    "Serilog.Extensions.Logging": "1.0.0",
    "IdentityServer4": "1.0.0-beta5",
    "IdentityManager.V2.Entities": "1.0.0-*",
    "IdentityManager.V2.Data": "1.0.0-*",
    "Microsoft.AspNetCore.Authentication.Google": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Twitter": "1.0.0",
    "Serilog.Sinks.Seq": "3.0.1",
    "System.Runtime": "4.1.0"
  },
  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net452+win81"
      ]
    }
  },

  "runtimes": {
    "win7-x64": {}
  },

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

  "runtimeOptions": {
    "gcServer": true
  },

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

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

1 个答案:

答案 0 :(得分:6)

当我们更新软件包时,它会删除"键入":" platform"从
" Microsoft.NETCore.App":{       "版本":" 1.1.0",       "输入":"平台"     }

在Project.json文件中

。更新后它看起来像" Microsoft.NETCore.App":" 1.1.0" 。 解决此错误的方法是使用此行更新Json文件,例如

" Microsoft.NETCore.App":{       "版本":" 1.1.0",       "输入":"平台"     }