将exe文件获取到生成输出目录中 [英] Get exe file into the build output directory
问题描述
使用WinSCP .NETassembly从C#程序获得SFTP支持.在Visual Studio中构建项目时,我希望将WinSCP.exe
和WinSCPnet.dll
复制到bin
输出目录. WinSCPnet.dll
很容易-将其添加为程序集引用,只需将"Copy Local" 设置为true,然后完成即可.
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.
但是WinSCP.exe
呢?
我能想到的两件事:
-
将文件
WinSCP.exe
添加到项目的根目录,并将复制到输出目录" 设置为始终复制" .
add the file
WinSCP.exe
to the root of the project, and set "Copy To Output Directory" to "Copy always".
在项目属性 Build Events 中,使用build-build事件命令行通过命令行copy
命令复制文件.
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.
引用在Visual Studio中使用该程序集的WinSCP文档:
您可能想将
winscp.exe
添加到Visual Studio项目中,以将其自动复制到输出路径(通过将文件属性 Copy to Output Directory 设置为如果更新则复制). 构建操作应该自动设置为 Content ,这意味着在部署应用程序(例如ASP.NET Web应用程序或Azure WebJob应用程序)时将包含该文件.
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).
实际上,您最好通过NuGet软件包安装程序集.
WinSCP NuGet软件包会自行处理这些设置.
WinSCP NuGet package takes care of these settings itself.
这篇关于将exe文件获取到生成输出目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!