How to print some message when build using Visual Studio

Taotao Sun 20 Reputation points Microsoft Employee
2023-05-17T14:39:26.9733333+00:00

I have a project as following. I want to add some message to the project, so that I could print some variables.

User's image

I changed the Test.vcxproj file, and add some message to the file as following.

User's image

But when I right clicked the project and run the "Rebuild" command, I didn't see the "Hello world!" in the output window.

User's image

User's image

Could you help me to find what's wrong with it or how to add message to the build process? Thank you.

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Anna Xiu-MSFT 31,151 Reputation points Microsoft External Staff
    2023-05-18T07:03:27.4733333+00:00

    Hi @Taotao Sun

    Welcome to Microsoft Q&A! 

    You can try Viorel’s steps. 

    Or you can add the following custom build steps to .vcxproj file:

    <Target Name="CustomStep" AfterTargets="Build">
    		<Exec Command="ECHO Hello, world!" />
    </Target>
    
    

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Viorel 125.6K Reputation points
    2023-05-18T04:29:51.39+00:00

    Some messages can be emitted with @echo Hello, world! command, typed into Build Events of Project Properties. You can also use variables (macros).


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.