发布ASP.NET核心Web应用程序时缺少DLL

时间:2016-09-05 21:25:18

标签: c# asp.net visual-studio-2015 asp.net-core-mvc asp.net-core-1.0

当我发布我的ASP.NET Core(v1.0.0)MVC 6应用程序时,它在查看任何页面时无法成功运行(即,服务器/主机启动正常但在发出GET请求时抛出错误) 。在命令提示符下启动应用程序时,我可以看到它抱怨缺少DLL。我将丢失的DLL添加到已发布的目录(应用程序由IIS / Krestel托管),然后它抱怨另一个DLL,然后是另一个,依此类推。最终,在成功运行之前,它需要以下DLL:

Microsoft.DotNet.Cli.Utils.dll
Microsoft.DotNet.ProjectModel.dll
Microsoft.Extensions.CommandLineUtils.dll
NuGet.Common.dll
NuGet.Configuration.dll
NuGet.DependencyResolver.Core.dll
NuGet.Frameworks.dll
NuGet.LibraryModel.dll
NuGet.Packaging.Core.dll
NuGet.Packaging.Core.Types.dll
NuGet.Packaging.dll
NuGet.ProjectModel.dll
NuGet.Protocol.Core.Types.dll
NuGet.Protocol.Core.v3.dll
NuGet.Repositories.dll
NuGet.RuntimeModel.dll
NuGet.Versioning.dll

我不确定为什么NuGet DLL对于已发布的网络应用程序是必需的,或者为什么甚至会发生这种情况。显然,Visual Studio应该为我们处理这类事情。现在,当我发布时,我没有先清除所有文件(因此我手动复制的DLL保留在那里)但我想知道为什么,如果需要这些DLL,是它们不包括在部署过程中?

这是我的project.json,如果有帮助:

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.AspNetCore.Session": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Serilog.Extensions.Logging": "1.2.0",
    "Serilog.Sinks.File": "2.2.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "System.Data.Common": "4.1.0",
    "System.Data.SqlClient": "4.1.0",
    "System.DirectoryServices.Linq": "1.2.2.1",
    "Microsoft.Extensions.Logging.Filter": "1.0.0",
    "BundlerMinifier.Core": "2.2.281"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net462": {}
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },

  "configurations": {
    "DEV": {
      "compilationOptions": { "define": [ "DEV" ] },
      "buildOptions": { "define": [ "DEV" ] }
    },
    "PROD_SRV": {
      "compilationOptions": { "define": [ "TEST_SRV" ] },
      "buildOptions": { "define": [ "TEST_SRV" ] }
    },
    "PROD_SRV_DEV": {
      "compilationOptions": { "define": [ "TEST_SRV_DEV" ] },
      "buildOptions": { "define": [ "TEST_SRV_DEV" ] }
    },
    "TEST": {
      "compilationOptions": { "define": [ "TEST" ] },
      "buildOptions": { "define": [ "TEST" ] }
    },
    "TEST_SRV": {
      "compilationOptions": { "define": [ "TEST_SRV" ] },
      "buildOptions": { "define": [ "TEST_SRV" ] }
    },
    "TEST_SRV_DEV": {
      "compilationOptions": { "define": [ "TEST_SRV_DEV" ] },
      "buildOptions": { "define": [ "TEST_SRV_DEV" ] }
    }
  }
}

有什么想法吗?

谢谢你们和女孩们!

1 个答案:

答案 0 :(得分:2)

好吧,我解决了这个问题。我创建了一个新的ASP.NET核心(.NET Framework)Web应用程序项目,并且能够毫无问题地发布。所以我将project.json / global.json文件中的值与我项目中的版本进行了比较。我将所有版本更新到project.json中的最新版本,但是没有修复它。但是在将global.json中的关键“sdk:version”更新为“1.0.0-preview2-003131”之后,它运行了。我不敢相信这是问题,但它确实奏效了。

经过很多头痛之后,我也能够让Web部署工作。发布的努力太多了!

相关问题