Get exe file into the build output directory

走远了吗. 提交于 2019-12-08 01:39:28

问题


Using WinSCP .NETassembly for SFTP support from a C# program. When building my project in Visual Studio, I would like WinSCP.exe and WinSCPnet.dll to be copied to the bin output directory. WinSCPnet.dll is easy enough - as its added as an assembly reference, just set "Copy Local" to true, and its done.

But what about WinSCP.exe?

Two things I can think of:

  1. add the file WinSCP.exe to the root of the project, and set "Copy To Output Directory" to "Copy always".

  2. in project properties Build Events, use post-build event command line to copy the file using command line copy command.

Both seem a bit clunky. Is there a better way?


回答1:


The 1. is the correct approach. Except that you want "Copy if newer". I do not see anything "clunky" about it.


Quoting WinSCP documentation for using the assembly in Visual Studio:

You may want to add winscp.exe to your Visual Studio project, to have it copied to the Output path automatically (by setting file property Copy to Output Directory to Copy if newer). The Build Action should be automatically set to Content, what means that the file will be included when deploying your application (e.g. an ASP.NET web application or Azure WebJob application).


You actually better install the assembly via NuGet package.

WinSCP NuGet package takes care of these settings itself.



来源:https://stackoverflow.com/questions/43246318/get-exe-file-into-the-build-output-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!