0

I set a pre-build event in MSVC13 which exit with an error MSB3073: :VCEnd" exited with code -1. And I'm unable to bypass this error, i don't want the build process stop even if the bat file exit with error.

I have configured the

BuildEvents > Pre-Build Event

with a call to a bat file Command Line:

call $(ProjectDir)\pre_build.bat $(Configuration)=1

This bat file contains 2 calls to other bat files. The first one exit with an error (but i don't care as the sub-task I want it does is done) and the second is ok.

In the pre-build.bat, I tried to intercept this error and update the value to say everything is ok to MSVC but i can't succeed. I tried to echo ERRORLEVEL but it contains 0. I tried to set ERRORLEVEL to 0 but doesn't change anything at MSVC level. I tried to add an exit 0, exit /b 0 or @exit 0 at end of my bat file, but doesn't change.

I found this link (https://blogs.msdn.microsoft.com/astebner/2006/08/08/how-to-make-visual-studio-2005-ignore-return-codes-from-pre-build-events/) explaining how to tell to MSVC to ignore errors but it doesn't work as it is written for MSVC2005 and the syntax of PreBuildEvent in vcxproj has changed.

If i run my script in a console, it exit with an error but, as said previously, i don't care about this error, part of the job is done.

I also try with MSVC running as Admin, no change.

Content of my pre-build.bat:

call build.bat %* TOOLCHAIN=mdk4cc5 TC_NO_CHECK=1

and build.bat runs SCons (I haven't any knowledges on SCons)

If you have an idea on how to ignore this error in MSVC in order to contiue the build process (whatever it is clean or not), it will be very helpful as i already spent a day on this ...

Thanks a lot for your feedback and answers.

JCV
  • 41
  • 3
  • Are you using the `call` function because you specifically need a second batch process? – Jose Fernando Lopez Fernandez Apr 11 '19 at 08:20
  • Can you change the bat script? So you could ensure that it returns 0. – Simon Apr 11 '19 at 08:23
  • My first tries were without the call.I add the call as it is explicitely stated in MSVC online docs. I also tried without the call but still the same, i cannot catch the error – JCV Apr 11 '19 at 08:23
  • I wonder if switching the order of the arguments would help. For some reason I feel like if you swap the %* and the options, it should work; have you tried that? – Jose Fernando Lopez Fernandez Apr 11 '19 at 08:25
  • @@Simon, in the build.bat calling scons, i tried to add an exit 0 exit /b 0 @exit 0, but does not change. if i "echo errorcode is %ERRORLEVEL%" after the scons execution which is in error, i got this errorcode is 0. – JCV Apr 11 '19 at 08:34
  • @JoseFernandoLopezFernandez, the subscript is in error, i know and i just want ot ignore this error. The order of parameters, does not change the result. – JCV Apr 11 '19 at 08:35
  • Have you looked at [this question](https://stackoverflow.com/questions/17075279/how-do-i-fix-msb3073-error-in-my-post-build-event)? I wonder if your project(s)' build order might be the problem? In this question the problem was a project dependency that was set to compile after the main project, which resulted in the `MSB3073` error. It would then make sense why your solution's build exits immediately rather than continuing with what it can – Jose Fernando Lopez Fernandez Apr 11 '19 at 08:54
  • @JoseFernandoLopezFernandez, the order is ok as i am in a prebuild not a postbuild. The job i want my prebuilt.bat is done correctly. I expect an error from my scrupt but i want to catch it and ask MSVC to continue. In the .vcxproj, I try to update PreBuildEvent section with some ContinueOnError or IgnoreErroCode set to true but does not change and the build stop .... I'm stuck – JCV Apr 11 '19 at 10:20
  • hi all, after asking question on MSDN (https://social.msdn.microsoft.com/Forums/vstudio/en-US/48eb96ab-93e8-4fa7-af33-430ff4644b03/msvc2013-how-to-avoid-aborting-build-process-with-prebuild-script-in-error-error-msb3073?forum=msbuild), Microsoft suggests this solution that works fine: ... – JCV Apr 12 '19 at 08:31

2 Answers2

1

You command output may contain the word "Error" somewhere.

We had here some script which did echo XX send-msg 19 82 Error :A KANAL A AUSGEFALLEN Error ge

Then the build output contained:

2> ------ Erstellen gestartet: Projekt: DecoderTest, Konfiguration: Debug Any CPU ------
2>  Datei nicht gefunden
2>EXEC : XX   send-msg 19 82 error : A   KANAL A AUSGEFALLEN   Error   ge
2>  
2>  D:\Projekte\[...]\DecoderTest\\..\..\..\TableConverterTraverse.bat: Durchlauf erfolgreich.
2>C:\Program Files (x86)\Microsoft Visual Studio\[...]: error MSB3073: Der Befehl "D:\Projekte\[...]\DecoderTest\InvokeTableConverter.bat
2>C:\Program Files (x86)\Microsoft Visual Studio\[...]: error MSB3073: " wurde mit dem Code -1 beendet.
========== Erstellen: 1 erfolgreich, 1 fehlerhaft, 39 aktuell, 0 übersprungen ==========

After silencing the command output, build succeeded.

jifb
  • 142
  • 2
  • 6
0

I am not a real C++ Expert but maybe this post could help you: Disable single warning error

Someone in the Answers talked about Pragma Surprass so you could try that:

#pragma warning(suppress: 4101)

// here goes your single line of code where the warning occurs

Assasin Bot
  • 136
  • 1
  • 1
  • 11
  • 1
    Thanks for your reply but the problem is not in the source code but in the pre-build execution of MSVC. The pragma is working well in C but we have to pay attention to use it only on sections/methods and not for a full file or project – JCV Apr 11 '19 at 08:37
  • Ok I am sorry then that I couldn't really help. I just thought the Warning Surprass might help since this is only Specificated on one line like I understood it. – Assasin Bot Apr 11 '19 at 08:39