Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"@echo on" for a post build event batch file in Visual Studio 2012

Tags:

I'd occationally like to see the actual build event script for debugging purposes. I've tried leading the script with @echo on which should work according to the documentation, but I've yet to see anything other than exe or explicit "echo some text" output in the build output.

Here's my build event:

echo on
cd $(ProjectDir)_dev
PostBuildEvents.bat $(ConfigurationName) $(TargetName)

I do see this text in the output, but nothing from within the .bat file. I also tried added echo on to the top of the batch file but that did not work either.

like image 340
b_levitt Avatar asked Jun 13 '13 23:06

b_levitt


People also ask

How do I run a batch file in post build event?

If you go to the Properties page for your project, you should select the Build Events tab. You can type in the call to your batch file in the Post-build event command line text box. If you want to refer to the batch file using the paths included in the project or solution, you can click on the Edit Post-Build...

How to run batch file in Visual Studio setup project?

In the "File System" view (right-click on the project in Solution Explorer->View->File System), add the batch file you want to execute and cmd.exe (C:\Windows\System32\cmd.exe) Open the "Custom Actions" view (right-click on the project in Solution Explorer->View->Custom Actions)


2 Answers

Although the answer will come incredibly late, it may be useful for other people coming here: the only way I have found is also contained in the documentation page, and it's the following:

Modify your project settings to collect more than the default amount of information in the build log. On the Tools menu, click Options. In the Options dialog box, click the Projects and Solutions node and then click the Build and Run node. Then, in the MSBuild project build log file verbosity box, click Detailed.

enter image description here

like image 165
RedGlow Avatar answered Sep 28 '22 05:09

RedGlow


I was struggling with the same problem. The only way I was able to overcome this was to echo each line, but that was requiring to type everything twice, once for echo and once to execute. So I decided to use variables with echo.

ECHO ON
ECHO C:\myFolder\bin\heat.exe
C:\myFolder\bin\heat.exe
if errorlevel 1 exit 1

a better way with variables

ECHO ON
SET vCmdl="C:\myFolder\bin\heat.exe" 
ECHO %vCmdl%
%vCmdl%
if errorlevel 1 exit 1

In this way, I can see each line of the bat file in the Output window and any messages that they produce and if error occurs "exit 1" is received by VS and build FAILS.

like image 40
Bartuniek Avatar answered Sep 28 '22 03:09

Bartuniek