1

This is a followup of a question I asked before. In a nutshell I run a 64 bit version of cmd from visual studio (which is 32 bit application). I do this because I need to run a command oscdimg.exe which is only accessible from 64 bit version of cmd.

  <Target Name="AfterBuild">  
    <Exec Command="%windir%\sysnative\cmd.exe /c &quot;$(ProjectDir)test.bat UPLOAD&quot;" WorkingDirectory="$(ProjectDir)" />
  </Target>

Now while this works fine, I receive following error.

error MSB3073: The command "%windir%\sysnative\cmd.exe /c "C:\XXXX\XXX\XXX\test.bat UPLOAD"" exited with code -1.

While this error is not disrupting my work, meaning the batch performs its tasks successfully, it still is nice to fix this error message, as others in my team questions this error message.

I am making an assumption that this error is triggered because although the visual studio is 32 bit application, the build or exec calls for windows operating system application which may be 64 bit application. And 64 bit application cannot see the sysnative virtual folder.

Is there any way to resolve this error?

EDIT: Added argument to the command to simulate the real use and to show the reason I add &quot;.

Shintaro Takechi
  • 1,215
  • 1
  • 17
  • 39
  • `edited with code -1` usually means that command you typed has a syntax error. So please try ``. – Mr Qian Feb 11 '20 at 14:45
  • @PerryQian-MSFT Hi Perry, thank you very much for your reply. Unfortunately, due to the need of using space in real scenario for arguments, if I remove the quote that would also error out. – Shintaro Takechi Feb 11 '20 at 16:37
  • Please set `MSBuild project build output verbosity` to `Normal`, can it put any other error message about it? In my side, l just use your command line in a c# console project and it works well which indicates there may be some errors in your `test.bat` file. First, please reopen VS as administrator and then rebuild your project in case you cannot access the system disk. Second, open `C:\Windows\SysWOW64\cmd.exe` and enter your `test.bat` directly to test whether it works. – Mr Qian Feb 12 '20 at 12:08
  • 1. I ran with verbose but only thing I see is EXEC(0,0) incompatibility of filenames with Windows NT 3.5 2. `%windir%\sysnative\cmd.exe /c "$(ProjectDir)test.bat UPLOAD"` ran from `C:\Windows\SysWOW64\cmd.exe` had no issue. – Shintaro Takechi Feb 12 '20 at 16:28
  • Having said above, I believe you are right about the issue on .bat. One of the recent surprise for me is that robocopy returns 1 when it finishes the copy successfully, which VS picks up and interpret it as error. Since oscdimg is my last command in the batch file, I am assuming that oscdimg returns non-zero value after it succeeds? I could not find supporting document regarding oscdimg. – Shintaro Takechi Feb 12 '20 at 16:30

1 Answers1

1

One of the recent surprise for me is that robocopy returns 1 when it finishes the copy successfully, the author @Valamas shows in italic

Confusion will set in when no files are copied = no error in VS. Then when there are changes, files do get copied, VS errors but everything the developer wanted was done.

VS picks up and interprets this return value as an error when robocopy is the last command in the batch file.

In the case of robocopy, VS returns 1 and not -1 so it is slightly different from my current situation. However, since my batch file is functioning as intended, I felt safe enough to return 0 once the batch is completed without error.

exit 0

And I no longer see the MSB3073.

For this post's issue, since oscdimg is my last command in the batch file, I am assuming that oscdimg returns non-zero value after it succeeds.

I could not find supporting document regarding oscdimg.

Shintaro Takechi
  • 1,215
  • 1
  • 17
  • 39