dotnet build throw nullreference exception

时间:2016-10-14 22:52:42

标签: asp.net .net asp.net-core .net-core

我有一个在本地构建和运行良好的项目。但是,当我将其推送到我的服务器(Windows Server 2012 R2)时,它无法构建。它没有给我任何关于它为什么失败的细节。即使我添加了详细的标志。

  

PS C:\ projectroot> dotnet -v build

     

遥测是:已启用

     

对象引用未设置为对象的实例。

我在事件日志中看不到任何内容。有没有其他地方我可以找到错误信息来缩小范围?还有其他想法吗?

我怀疑它可能是一些缺失的依赖,因为它在本地工作,但不知道接下来要去哪里看出来。

这是我的project.json的副本。在尝试单独构建项目的解决方法之前,我尝试了几种组合。

{
"webroot": "wwwroot",
"userSecretsId": "secret",
"version": "1.0.0-*",
"dependencies": {
    "Microsoft.AspNetCore.Mvc.Core": "1.0.1",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
    "Microsoft.AspNetCore.Identity": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.Configuration.Abstractions": "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.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.EntityFrameworkCore": "1.0.1",
    "AutoMapper": "4.1.1",
    "MyApp.Domain": "1.0.0-*",
    "MyApp.Configuration": "1.0.0-*",
    "MyApp.Data": "1.0.0-*",
    "MyApp.Data.EF6": "1.0.0-*",
    "MyApp.Services": "1.0.0-*",
    "MyApp.Services.ETL": "1.0.0-*",
    "Scrutor": "1.3.1",
    "System.Linq": "4.0.0",
    "HtmlSanitizer": "3.2.105",
    "Microsoft.AspNet.Identity.Core": "2.2.1",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.EntityFrameworkCore.Design": {
        "type": "build",
        "version": "1.0.0-preview2-final"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
        "type": "build",
        "version": "1.0.0-preview2-final"
    }
},
"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"
},
"frameworks": {
    "net461": {
    }
},
"publishOptions": {
    "include": [
        "wwwroot",
        "Views",
        "Areas/**/Views/**/*.cshtml",
        "web.config",
        "config.json",
        "logs",
        "Aspose.Pdf.lic"
    ]
},
"scripts": {
    "prepublish": [
        "npm install",
        "bower install",
        "gulp clean",
        "gulp min"
    ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "compile": {
        "exclude": [
            "wwwroot",
            "node_modules",
            "bower_components"
        ]
    }
},
"runtimeOptions": {
    "configProperties": {
        "System.GC.Server": true
    }
}

}

1 个答案:

答案 0 :(得分:0)

您是否在跑步前尝试清理项目?因为在您自己的笔记本电脑/工作站中构建时的“缓存”文件可能已在服务器上重复使用。

在你的project.json中,

我注意到你正在使用461框架。不确定.NET Core是否也使用它,因为我一直在使用这个

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