.net 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物理文件位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4664386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy bin files on to Physical file location on Post Build event in VS2010
提问by Praneeth
I want to copy my dll generated in bin folder to a file location on Post Build Event in vs2010.
我想将在 bin 文件夹中生成的 dll 复制到 vs2010 中 Post Build Event 上的文件位置。
Can some one help me on that.
有人可以帮助我吗。
Thanks
谢谢
回答by adrianbanks
You want to add something like:
您想添加如下内容:
xcopy /Q /Y "$(TargetPath)" "C:\path\to\somewhere\"
to you post-build event on the Build Eventstab in the project properties page. The /Ywill stop it from prompting you to confirm an overwrite.
在项目属性页面的“构建事件”选项卡上向您发送构建后事件。这/Y将阻止它提示您确认覆盖。
If you also need to copy the .pdbfile, you will need something like this:
如果您还需要复制.pdb文件,您将需要如下内容:
xcopy /Q /Y "$(TargetDir)$(TargetName).*" "C:\path\to\somewhere\"
You can see more substitution tokens (the $XXX values) by clicking the Edit Post-build...button in the properties tab and then expanding the Macros>>button.
通过单击属性选项卡中的Edit Post-build...按钮,然后展开Macros>>按钮,您可以看到更多替换标记($XXX 值)。
回答by user541686
Right-click the project, then go to Properties->Build Events->Post-build command line.
右键单击该项目,然后转到 Properties->Build Events->Post-build command line。
Then type this in:
然后输入:
Cmd /C Copy "$(TargetPath)" "<YourTargetDirHere>"
Does that help?
这有帮助吗?
回答by Michael Shimmins
We use the following post build event for copying plugin dlls to the web application's plugin directory:
我们使用以下构建后事件将插件 dll 复制到 Web 应用程序的插件目录:
copy $(TargetPath) $(SolutionDir)Convergence.WebApp\home\plugins\$(TargetFileName)
复制 $(TargetPath) $(SolutionDir)Convergence.WebApp\home\plugins\$(TargetFileName)
This works across multiple machines where the physical path may be different, but relies upon the destination being relative to the $(SolutionDir).
这适用于物理路径可能不同的多台机器,但依赖于相对于 $(SolutionDir) 的目标。
回答by Mihail Shishkov
For those of you that want to copy everything from the Output folder
对于那些想要从 Output 文件夹中复制所有内容的人
xcopy "$(TargetDir)*" "C:\testpublish\updater\" /s /Y

