Custom target execute always


  • I have a custom target in my project file .csproj, which executed after the build, like below:

      <Target Name="AfterBuild">
        <Message Text="My target executed always" Importance="high"></Message>

    It works fine. But if there are no changes in the project, Visual Studio will consider my project is up-to-date, will not execute the custom target also. This is not what I expected. What I want is that execute this target always at the end of the build process, even if I don't have any modification project. 

    Thanks in advance.

    Tuesday, November 21, 2017 4:48 PM


  • Hi Justyna.lyu2,

    Thanks for posting here.

    If I understand you correctly, you can try to broken the up-to-date for VS. To accomplish this, unload your project, define this property in your project file:


    With this property seems that Visual Studio is bypassing normal up-to-date checks of MSBuild. Then you custom target will execute every time.

    Hope this helps.

    MSDN Community Support Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Marked as answer by Justyna.lyu2 Wednesday, November 22, 2017 1:39 PM
    Wednesday, November 22, 2017 1:45 AM