Visual Studio 2008中的批处理文件 [英] Batch files in Visual Studio 2008

查看:83
本文介绍了Visual Studio 2008中的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关Visual Studio 2008令人沮丧的问题的帮助.
我在C#中有一个项目,该项目在预编译阶段调用一个批处理文件,该文件将一些dll复制到项目本身的子目录中. Visual Studio经常会报告由批处理文件的执行引起的错误:它说执行已用代码1终止.此后,再次编译该项目的唯一解决方案是重新启动Visual Studio.重新启动后,编译不会报告任何问题.
有谁报告同样的问题?
您知道解决该问题的方法吗?
非常感谢.

I need help with a very frustrating problem with Visual Studio 2008.
I have a project in C# which calls, during the pre-compilation phase, a batch file which copies some dlls into a sub-directory of the project itself. It often happens that Visual Studio reports an error caused by the execution of the batch file: it says that the execution had terminated with code 1. After that, the only solution to compile again the project is restarting Visual Studio. Once restarted, the compilation doesn't report any problem.
Is there anyone who report the same problem?
Do you know a way to resolve it?
Thank you very much.

推荐答案

请改用<copy/>任务.这将为您提供更好的错误处理.

Use a <copy/> task instead. This will give you better error handling.

将所有DLL从C:\SourceDir复制到LocalDir的示例:

Example to copy all DLLs from C:\SourceDir to LocalDir:

<ItemGroup>
  <SourceFiles Include="C:\SourceDir\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(SourceFiles )" DestinationFolder="LocalDir\" />

另请参见 MSDN CopyTask参考.

根本原因可能是工作室本身仍通过"Visual Studio托管过程"打开了程序集.您可以在调试",启用Visual Studio托管过程"下的项目属性中禁用它.有关详细信息,请参见调试和托管过程文章.

The root cause is probably the studio itself having still the assemblies open via the "Visual Studio hosting process". You can disable this in the project's properties under "Debug", "Enable the Visual Studio hosting process". See the Debugging and the Hosting Process article for details.

这篇关于Visual Studio 2008中的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆