git - 部署 ASP.Net MVC .Net Core 应用程序时出现错误 MSB4025

标签 git azure bitbucket asp.net-core-mvc visual-studio-code

我正在尝试部署在 Visual Studio Code 中的 Ubuntu 16.04 系统上创建的 ASP.Net MVC .Net Core 应用程序。当尝试将本地 git 部署推送到我的 Azure 应用程序到其 Azure 应用程序服务时。 在项目的根目录中,我运行了以下命令:

git push -u azure master

并得到以下结果:

D:\home\site\repository\project.json(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. remote: Failed exitCode=1, command=dotnet publish "project.json" --output "D:\local\Temp\8d436b77fda50dd" --configuration Release remote: An error has occurred during web site deployment. remote: remote: Error - Changes committed to remote repository but deployment to website failed. To https: //[email protected]:443/mayappname.git * [new branch] master -> master Branch master set up to track remote branch master from azure.

从 Bitbucket 上的相同存储库进行部署时,我收到了几乎相同的错误消息。

我在处理持续集成平台时发现了对此错误的引用,但其他人在尝试部署 ASP.Net MVC .Net Core 应用程序时是否见过此错误?这是project.json 文件:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Microsoft.EntityFrameworkCore": "1.1.*",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer":"1.1.*",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0"
  },

  "tools": {
    "BundlerMinifier.Core": "2.2.306",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
     "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "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": {
    "precompile": [ "dotnet bundle" ],
    "prepublish": [ "bower install" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },

  "tooling": {
    "defaultNamespace": "myNameSpace"
  }
}

最佳答案

解决方案是将 global.json 文件添加到包含 .net core SDK 版本的根目录:

{
  "sdk": {
  "version": "1.0.0-preview2-1-003177"
  }
 }

如果没有 global.json 文件,Azure 持续集成过程将尝试使用 MSBuild 构建基于 project.json 的项目,但该项目将无法工作。 请参阅https://github.com/aspnet/Mvc/blob/dev/global.json

关于git - 部署 ASP.Net MVC .Net Core 应用程序时出现错误 MSB4025,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41527391/

相关文章:

linux - 使用 sudo 制作 git clone

azure - 在 Visual Studio 2017 预览版中使用 github 和 azure function 项目进行持续部署

postgresql - 使用powershell在azure ubuntu虚拟机中安装postgres

git - Jenkins bitbucket 集成

git - SSH windows->Linux : key-based login steps have no effect. 仍然要求输入密码

git - 从预提交 Hook 中排除某些文件类型

git - 在克隆 bitbucket 存储库时连接后从代理接收到 HTTP 代码 302

bitbucket - 在 bitbuck 上留下存储库

Git 列出不存在的 Remote

azure - "Add-AzureAccount"出现错误 : Returned by service does not match user 'XXX' in the request