简体   繁体   English

dotnet构建抛出nullreference异常

[英]dotnet build throwing nullreference exception

I have a project that builds and runs fine locally. 我有一个可以在本地正常运行的项目。 However, it is failing to build when I push it up to my server (Windows Server 2012 R2). 但是,将其推送到服务器(Windows Server 2012 R2)时无法构建。 It does not give me any detail as to why it is failing. 它没有给我任何有关失败原因的细节。 Even when I add the verbose flag. 即使添加了详细标志。

PS C:\\projectroot> dotnet -v build PS C:\\ projectroot> dotnet -v构建

Telemetry is: Enabled 遥测为:已启用

Object reference not set to an instance of an object. 你调用的对象是空的。

I don't see anything in the event logs. 我在事件日志中什么都看不到。 Is there anywhere else I can look for error info to get this narrowed down? 还有其他地方我可以寻找错误信息以缩小范围吗? Any other ideas? 还有其他想法吗?

I suspect it may be some missing dependency since it works locally, but don't know where to look next to figure it out. 我怀疑这可能是缺少某种依赖关系,因为它可以在本地运行,但是不知道在哪里寻找它。

Here's a copy of my project.json. 这是我的project.json的副本。 I tried several combinations of things before arriving at the workaround of building the projects individually. 在达到单独构建项目的变通方法之前,我尝试了几种方法的组合。

{
"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
    }
}

} }

Did you attempt to clean the project before running? 您是否尝试在运行之前清理项目? Because the "cached" files when building in your own laptop/workstation might have been reused on the server. 因为在您自己的便携式计算机/工作站中构建时,“缓存”文件可能已在服务器上重用。

In your project.json, 在您的project.json中,

I noticed that you're using the 461 framework. 我注意到您正在使用461框架。 Not sure if .NET Core uses that too because I've always been using this 不知道.NET Core是否也使用了它,因为我一直都在使用它

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

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

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