How do I fix MSB3073 error in my post-build event?

后端 未结 14 2564
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-05 04:48

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 m

相关标签:
14条回答
  • 2020-12-05 05:16

    This is too late but posting my experience for people looking at it later:-

    In MS VS 2010 I had the same issue. It got resolved by putting quotes to post build copy command args which contained spaces!

    In Project Properties --> Configuration Properties --> Build Events --> Post-Build Event --> Command Line change:

    copy $(ProjectDir)a\b\c $(OutputPath)

    to

    copy "$(ProjectDir)a\b\c" "$(OutputPath)"

    0 讨论(0)
  • 2020-12-05 05:16

    I've found the issue happens when you have multiple projects building in parallel and one or more of the projects are attempting to copy the same files, creating race conditions that will result in occasional errors. So how to solve it?

    There's a lot of options, as above just changing things around could solve the issue for some people. More robust solutions would be...

    • Restrict the files being copied i.e. instead of xcopy $(TargetDir)*.*"... instead do xcopy "$(TargetDir)$(TargetName).*"...

    • Catch the error and retry i.e:

        :loop
        xcopy /Y /R /S /J /Q  "$(TargetDir)$(TargetName).*" "somewhere"
        if ErrorLevel 1 goto loop
    
    • Use robocopy instead of xcopy

    • You probably won't want to do this as it will increase your build times, but you could reduce the maximum number of parallel project builds to 1 ...

    0 讨论(0)
提交回复
热议问题