Search code examples
vb.netvisual-studio-2012msbuildprojects-and-solutions

Why doesn't Visual Studio Build output the Message in the Target element having a custom name?


My project has a different behaviour locally and on production. I have concluded that some Tasks in my .vbproj don't get executed locally neither in DEBUG or RELEASE mode. For example, I have a Message in a element, and it doesn't appear in the OUTPUT window after build.

Is my conclusion wrong? Am I missing something here?

doesn't display message in console:

<Target Name="test12345">
 <Message Text="This is a test message" Importance="high" />
</Target>

displays message in console:

<Target Name="AfterBuild">
 <Message Text="This is a test message" Importance="high" />
</Target>

Solution

  • The AfterBuild name makes it automatically run after a project is built (to be specific, AfterBuild is already defined but meant to be overwritten in custom projects).

    When you define a target with a custom name, you need to hook it into the build as well, e.g. by using AfterTargets:

    <Target Name="test12345" AfterTargets="Build">
     <Message Text="This is a test message" Importance="high" />
    </Target>