发布ASP时缺少DLL's.. NET Core web应用

本文关键字:NET Core 应用 web ASP DLL 发布 | 更新日期: 2023-09-27 18:05:41

当我发布我的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是一个发布的web应用程序所需要的,或者为什么这甚至发生在所有。显然Visual Studio应该为我们处理这类事情。现在,当我发布时,我没有它首先清除所有文件(所以我手动复制的DLL留在那里),但我想知道为什么,如果需要这些DLL,它们不包括作为部署过程的一部分吗?

这是我的项目。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" ] }
    }
  }
}

任何想法?

谢谢大家!

发布ASP时缺少DLL's.. NET Core web应用

好了,我解决了这个问题。我创建了一个新的ASP。. NET Core(。. NET Framework) web应用程序项目,并且能够毫无问题地发布。所以我比较了project.json/global中的值。Json文件与版本在我的项目。我在项目中将所有的版本都更新到了最新的版本。Json,但这并没有解决它。但在全局更新关键"sdk:version"之后。Json到"1.0.0-preview2-003131"就可以了。我不敢相信这是问题所在,但它起作用了。

在经历了很多头痛之后,我也能够让Web Deploy工作了。光是发表就花了太多精力!