简体   繁体   English

由于缺少project.json中的引用,因此无法在VS 2015中发布.Net核心Web App

[英]Publishing .Net core Web App in VS 2015 not working because of missing references in project.json

I am currently trying to publish a web application out of VS2015. 我目前正在尝试从VS2015中发布Web应用程序。 The solution is building, but when I want to publish I continuously get the error message: "Your project is not referencing the ".NETFrameworkVersion=v2.0" framework. Add a reference to ".NETFramewor, Version=v2.0" in the "frameworks" section of your project.json, and then re-run NuGet restore. 解决方案正在构建中,但是当我要发布时,我不断收到错误消息:“您的项目没有引用“ .NETFrameworkVersion = v2.0”框架。在其中添加对“ .NETFramewor,Version = v2.0”的引用在project.json的“框架”部分,然后重新运行NuGet restore。

I already tried to change project.json in several ways that were suggested in StackOverflow ansers, but this was not working. 我已经尝试过用StackOverflow ansers中建议的几种方式来更改project.json,但这是行不通的。

Can someone please help me out? 有人可以帮我吗?

As a reference, I will add my project.json file and a screenshot of the problem. 作为参考,我将添加我的project.json文件和问题的屏幕截图。

Screenshot of the problem: https://imgur.com/l9a4Eru 问题的屏幕截图: https//imgur.com/l9a4Eru

`{
  "userSecretsId": "aspnet-KrisnaldoApp-009a51e2-478c-4020-ac03-0a98477155a1",
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Authentication.Cookies": "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.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.EntityFrameworkCore.SqlServer": "1.0.1",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": {
      "version": "1.0.1",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "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",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "System.Xml.XmlSerializer": "4.0.11",
    "System.Xml.XmlDocument": "4.0.1"
  },
  "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",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "imports": [
        "portable-net45+win8"
      ],
      "version": "1.0.0-preview2-final"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "System.ServiceModel.Duplex": "4.0.1",
        "System.ServiceModel.Http": "4.1.0",
        "System.ServiceModel.NetTcp": "4.1.0",
        "System.ServiceModel.Security": "4.0.1"
      },
      "imports": [
        "dotnet2.0",
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": 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%"
    ]
  }
}`

I usually resolve this by clicking on Restore Nuget Packages at the solution level. 我通常通过在解决方案级别上单击Restore Nuget Packages来解决此问题。 Also try to save your project.json to a different file, Delete the one in your solution and clean your project and add it back manually. 还要尝试将project.json保存到其他文件中,在解决方案中删除该文件并清理项目,然后手动将其重新添加。 Sometimes these files become locked. 有时这些文件被锁定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM