简体   繁体   English

.NET Core 2.0构建不包括依赖项

[英].NET Core 2.0 Build not including dependencies

When I build my .NET Core 2.0 console app, I move it over to the server and I then try and run it. 构建.NET Core 2.0控制台应用程序时,将其移至服务器,然后尝试运行它。 I am getting the error "An assembly specified in the application dependencies manifest..." 我收到错误“在应用程序依赖清单中指定的程序集...”

I add the dlls to the local folder that it is searching for, but it ends up still needing system dlls like Data.SqlClient. 我将dll添加到要搜索的本地文件夹中,但最终仍然需要像Data.SqlClient这样的系统dll。

How do I build the project where it includes all the dependencies in the output files? 如何在包含所有依赖项的输出文件中构建项目? I've published the project with Visual Studio 2017, however, it still says things are missing when I copy all those files over. 我已经在Visual Studio 2017中发布了该项目,但是它仍然说当我复制所有这些文件时缺少任何东西。 I've tried building and publishing with VSCode and have the same problem. 我已经尝试使用VSCode进行构建和发布,并且遇到了同样的问题。

Thanks. 谢谢。

Nick 缺口

I faced a similar problem. 我遇到了类似的问题。 When I deployed my application in host environment and executed with dotnet command like "dotnet myapp.dll" it worked fine using the host environment's .NET Core runtime. 当我将应用程序部署到主机环境中并通过dotnet命令(例如“ dotnet myapp.dll”)执行时,它在主机环境的.NET Core运行时中运行良好。 But when I packaged the same application as a Standalone application with an .exe file included to start the application, I faced this error for Newtonsoft.json Nuget Package when .exe file is executed. 但是,当我将包含一个.exe文件的独立应用程序打包为一个独立应用程序以启动该应用程序时,执行.exe文件时,Newtonsoft.json Nuget Package遇到了此错误。 My observation is as below, and I was able to solve the problem accordingly. 我的观察如下,并且我能够相应地解决问题。

Framework-dependent deployment: 框架相关的部署:
If the application uses third-party libraries and intention is to use the .NET Core runtime in the host environment, then the checkbox in the "Manage Packages for Solution" has to be checked in the Nuget Package Manager (as shown in the screenshot). 如果应用程序使用第三方库,并且打算在主机环境中使用.NET Core运行时,则必须在Nuget软件包管理器中选中“管理解决方案的软件包”中的复选框(如屏幕截图所示)。 。

在此处输入图片说明

Self-contained deployment: 独立部署:
If the published application is supposed to be a stand alone application in the host environment (even with an .exe file), then the application's .csproj file should include the RuntimeIdentifiers (.NET Core RIDs) specified. 如果发布的应用程序应被认为是主机环境中的独立应用程序(即使带有.exe文件),则该应用程序的.csproj文件应包括指定的RuntimeIdentifiers (.NET Core RID) Also the third party libraries have to be included in PackageReference. 第三方库也必须包含在PackageReference中。 For example, 例如,

在此处输入图片说明

Reference: https://docs.microsoft.com/en-us/dotnet/core/deploying/deploy-with-vs 参考: https : //docs.microsoft.com/zh-cn/dotnet/core/deploying/deploy-with-vs

您需要发布应用程序以包含所有依赖项

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

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