3

While I'm trying to build my windows application, I'm getting following error.

The command

"C:\repos\CommunityLive\CL_GateApp\signing\StrongNameUnsignedAssemblies.bat C:\repos\CommunityLive\CL_GateApp\signing" exited with code 2.

Following is my Pre-Build event command line

$(ProjectDir)signing\StrongNameUnsignedAssemblies.bat $(ProjectDir)signing\

Here is the Macros details

Macros

RBT
  • 24,161
  • 21
  • 159
  • 240
Ishan Malik
  • 139
  • 3
  • 12
  • 2
    An error code (also exit code) of 2 means "File not found". You would check the path in your side, and also view the bat file in your side even if we don't know how you write it. – Jack Zhai Jun 21 '18 at 02:11
  • batch file is available at the expected location but still getting this issue. – Ishan Malik Jun 21 '18 at 10:28
  • Actually I mean that how you write your bat file, just to make this issue clearly, could you run your bat file manually in your side? If possible, you could share us a simple sample using one drive, so we could really test it in our side. – Jack Zhai Jun 22 '18 at 08:16
  • It is solved by the creator only. – Ishan Malik Jun 29 '18 at 20:27
  • 1
    @creator, Do you mean that this issue has been resolved? If so, would you please share the real solution as an answer? – Jack Zhai Jul 02 '18 at 01:12
  • I was getting this error while trying to execute `xcopy` command in post-build event. The problem was that I wasn't using `/y` argument which results in overwriting of files in target directory even if they exist already. – RBT Mar 01 '21 at 07:53
  • Related post - [Why would a post-build step (xcopy) occasionally exit with code 2 in a TeamCity build?](https://stackoverflow.com/q/7835304/465053) – RBT Mar 01 '21 at 07:54

1 Answers1

0

Xcopy command without /y can cause this:

This post-build event exited with Code 2:

xcopy $(TargetDir)*.*  $(SolutionDir)shared\ /s /i 

This worked as hoped:

xcopy $(TargetDir)*.*  $(SolutionDir)shared\ /s /i /y
Missy
  • 1,286
  • 23
  • 52