Post Build exited with code 1

后端 未结 18 1860
囚心锁ツ
囚心锁ツ 2020-12-04 16:11

I have a project with a post build event:

copy $(ProjectDir)DbVerse\\Lunaverse.DbVerse.*.exe  $(TargetDir)

It works fine every time on my m

18条回答
  •  醉梦人生
    2020-12-04 16:34

    Yet another answer ...

    In my case I had a Visual Studio 2017 project targeting both .Net Standard 1.3 and .Net Framework 2.0. This was specified in the .csproj file like this:

    netstandard1.3;net20
    

    I also had a post-build event command line like this:

    copy "E:\Yacks\YacksCore\YacksCore\bin\net20\Merlinia.YacksCore.dll" "E:\Merlinia\Trunk-Debug\Shared Bin\"
    

    In other words I was trying to copy the .Net Framework .dll produced by the build to an alternative location.

    This was failing with this error when I did a Rebuild:

    MSB3073 The command "copy "E:\Yacks\YacksCore\YacksCore\bin\net20\Merlinia.YacksCore.dll" "E:\Merlinia\Trunk-Debug\Shared Bin\"" exited with code 1.
    

    After much frustration I finally determined that what was happening was that Rebuild deleted all of the output files, then did the build for .Net Standard 1.3, then tried to run the post-build event command line, which failed because the file to be copied wasn't built yet.

    So the solution was to change the order of building, i.e., build for .Net Framework 2.0 first, then for .Net Standard 1.3.

    net20;netstandard1.3
    

    This now works, with the minor glitch that the post-build event command line is being run twice, so the file is copied twice.

提交回复
热议问题