我构建了一个相对简单的ASP.Net Core Web应用程序,该应用程序使用Angular 2&前端的bootstrap和后端的WebApi。
我能够在本地构建和运行我的应用程序(到IIS Express)并且它工作正常,但是,当我尝试使用Build -> Publish
菜单时,我遇到了一个非常糟糕的NullReferenceException错误。这是我运行Publish时的输出:
1>------ Publish started: Project: MyProject, Configuration: Release Any CPU ------
Connecting to C:\ProjectDir\MyProject\./bin/Release/PublishTest...
rmdir /S /Q "C:\Users\UserName\AppData\Local\Temp\PublishTemp\MyProject86\"
Environment variables:
Path=%PATH%;.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git
C:\Program Files\dotnet\dotnet.exe publish "C:\ProjectDir\MyProject" --framework net452 --output "C:\Users\UserName\AppData\Local\Temp\PublishTemp\MyProject86" --configuration Release --no-build
Publishing MyProject for .NETFramework,Version=v4.5.2/win7-x64
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): Error : Object reference not set to an instance of an object.
1>Publish failed due to build errors. Check the error list for more details.
========== Build: 0 succeeded, 0 failed, 3 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
我试图将FileSystem发布到运行IIS的服务器上的目录以及本地目录,并且在这两个实例中都得到相同的输出。
我已经清理了我的解决方案,重建并重新启动了Visual Studio,以防万一它处于糟糕的状态。我创建了一些不同的发布配置文件,只是为了确保某些内容没有错误配置(其中一些是在VS2015重新启动后创建的)。
此外,我确定在我遇到此问题后更新VS2015,现在我正在运行版本14.0.25425.01更新3.我还安装了最新的Web工具。
这是我的project.json文件:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"type": "platform"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
}
},
"frameworks": {
"net452": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
],
"dependencies": {
"aDependency": {
"target": "project"
}
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
我一直在寻找有这个问题的其他人,我相信我找到了一两个其他地方似乎遇到了这个问题,但我没有找到任何回复过解决方案甚至理论的人正在发生。任何帮助,理论或线索都将受到赞赏。
感谢您的时间。
编辑:正如评论中所建议的那样,自1.0.0发布以来我创建了一个新的ASP.NET核心应用程序并查看了这些差异。无论如何,对于遇到这个问题(虽然暂时有限)的其他人来说,这是有用的,我觉得很愚蠢,这里是固定的project.json文件:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
],
"dependencies": {
"aDependency": {
"target": "project"
}
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
答案 0 :(得分:1)
我认为你应该将你的应用程序从RC2更新到1.0.0,你可能想要创建一个新的web应用程序1.0.0和dot.net的最新工具/ vs项目模板然后比较project.json和启动代码到现有应用程序并更新现有应用程序