将项目工件复制到成功构建事件批处理文件上的 bin 文件夹

发布于 2024-11-24 12:20:12 字数 771 浏览 1 评论 0原文

我想在成功构建时将项目文件和文件夹复制到 bin\debug 文件夹。 我正在尝试让 xcopy 执行此操作,但它要么复制 0 个文件,要么告诉我它无法循环复制。
我想做的与此类似 问题: 这是我的批处理文件:

@echo off

REM Set up the files and folders to exclude
echo \bin\ > exclude.txt
echo exclude.txt >> exclude.txt
echo Helper.cs >> exclude.txt
echo Program.cs >> exclude.txt

REM Set up the variables
set sourceBase="D:\Devprojects\WebApplications\GenerateTabbedHTML"
set destinationBase="D:\Devprojects\WebApplications\GenerateTabbedHTML\bin\Debug\"
set params=/E /C /I /R /Y /Exclude:exclude.txt

xcopy %sourceBase% %destinationBase% %params%

我的处理方式正确吗?或者有更简单的方法来完成这个任务吗?

I'd like to copy project files and folders to the bin\debug folder on successful build.
I'm trying to get xcopy to do it, but it either copies 0 files or tells me it can't copy cyclicly.
What I'm trying to do is similar to this question:
Here's my batch file:

@echo off

REM Set up the files and folders to exclude
echo \bin\ > exclude.txt
echo exclude.txt >> exclude.txt
echo Helper.cs >> exclude.txt
echo Program.cs >> exclude.txt

REM Set up the variables
set sourceBase="D:\Devprojects\WebApplications\GenerateTabbedHTML"
set destinationBase="D:\Devprojects\WebApplications\GenerateTabbedHTML\bin\Debug\"
set params=/E /C /I /R /Y /Exclude:exclude.txt

xcopy %sourceBase% %destinationBase% %params%

Am I going about this the right way? Or is there an easier way to accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无可置疑 2024-12-01 12:20:12

看起来 xcopy 不喜欢您的目标文件夹位于源文件夹内这一事实。你确实排除了它,但我想它无论如何也无法处理这种情况。尝试使用不在源代码下的中间文件夹。首先将文件复制到那里,然后再复制到目标。

Looks like xcopy doesn't like the fact that your dest folder is inside your source folder. You do exclude it, but I guess it can't handle the situation anyway. Try using an intermediate folder, which is not under the source. Have the files first copied there, and then to the target.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文