如何修复构建后事件中的MSB3073错误? [英] How do I fix MSB3073 error in my post-build event?

查看:181
本文介绍了如何修复构建后事件中的MSB3073错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目上,该项目要求将通过构建解决方案而生成的DLL从bin文件夹复制到另一个文件夹,这两个文件夹都在我的计算机上的C驱动器中.我编写了一个使用xcopy来完成此操作的批处理文件,您可以在此处看到它:

xcopy /s /y /q "C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Server\bin\Debug\Organizr.Services.dll" "C:\inetpub\wwwroot\AppServer\bin\"
xcopy /s /y /q "C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Server\bin\Debug\Organizr.Services.pdb" "C:\inetpub\wwwroot\AppServer\bin\"

现在,我已经尝试了此文件的多次迭代,该文件位于:

C:\Users\scogan\Desktop\CopyFiles.bat

所以我的构建后事件命令行如下所示:

call C:\Users\scogan\Desktop\CopyFiles.bat

我已经自己运行了该批处理文件,并在桌面上的文件夹中运行了两个文本文件,并且运行良好.我也使用它自己复制的文件来运行它,并且效果也很好.但是,当我尝试将其作为生成后事件运行时,得到以下输出:

1>  Organizr -> C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Client\bin\Debug\Organizr.exe
1>  File not found - Organizr.Services.dll
1>  0 File(s) copied
1>  0 File(s) copied
1>  File not found - Organizr.Services.pdb
1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(4291,5): error MSB3073: The command "call C:\Users\scogan\Desktop\CopyFiles.bat" exited with code 4.

我已经进行了一些研究,发现错误代码4表示发生初始化错误.没有足够的内存或磁盘空间,或者您在命令行上输入了无效的驱动器名称或无效的语法."

我也查看了MSB3073是什么,并且并没有真正找到可以帮助我的东西.所以,我的问题是我做错了什么?绝对路径搞砸了吗?感谢您的任何帮助.

解决方案

在使用不同的项目属性时,我发现问题在于项目构建顺序.生成要复制的文件的项目是 second 构建的,但是将批处理文件作为构建后事件运行的项目是 first 构建的,所以我只是而是将build事件附加到第二个项目,并且工作正常.谢谢大家的帮助.

I'm working on a project that requires that DLLs generated by building my solution to be copied from the bin folder to another folder, both of which are on my machine, in my C drive. I've written a batch file that uses xcopy to accomplish this, which you can see here:

xcopy /s /y /q "C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Server\bin\Debug\Organizr.Services.dll" "C:\inetpub\wwwroot\AppServer\bin\"
xcopy /s /y /q "C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Server\bin\Debug\Organizr.Services.pdb" "C:\inetpub\wwwroot\AppServer\bin\"

Now, I've tried numerous iterations of this file, which is located at:

C:\Users\scogan\Desktop\CopyFiles.bat

so my post-build event command line looks like this:

call C:\Users\scogan\Desktop\CopyFiles.bat

I've run this batch file on its own with two text files in folders on my desktop, and it works fine. I've also run it as it is with the files I need to copy on its own, and that works fine, too. However, when I try to run this as a post-build event, I get this output:

1>  Organizr -> C:\Users\scogan\Documents\Visual Studio 2012\Projects\Organizr\Client\bin\Debug\Organizr.exe
1>  File not found - Organizr.Services.dll
1>  0 File(s) copied
1>  0 File(s) copied
1>  File not found - Organizr.Services.pdb
1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(4291,5): error MSB3073: The command "call C:\Users\scogan\Desktop\CopyFiles.bat" exited with code 4.

I've done some research, and found that error code 4 means that "Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line."

I've also looked up what MSB3073 is, and haven't really found much that can help me there. So, my question is what am I doing wrong? Are the absolute paths messing it up? Any help here is appreciated.

解决方案

Playing around with different project properties, I found that the project build order was the problem. The project that generated the files I wanted to copy was built second, but the project that was running the batch file as a post-build event was built first, so I simply attached the build event to the second project instead, and it works just fine. Thanks for your help, everyone, though.

这篇关于如何修复构建后事件中的MSB3073错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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