running an AfterPublish command in Visual Studio 2010

תשובה running an AfterPublish command in Visual Studio 2010

  • שבת 14 אפריל 2012 16:17
     
      קוד כלול
    tried adding this code to my project file:
    <Target Name="AfterPublish">
    <Exec Command="start C:\test.txt" />
    </Target>

    This doesn't fie up at all. When I do "AfterBuild" though, it works fine. So, what I think it is, that my publish is not set to "Web Deploy". Does anyone know if there is a way to make the "AfterPublish" work without publishing using Web Deploy setting.

    Please advise. Thank you

כל התגובות

  • יום ראשון 15 אפריל 2012 07:17
     
     תשובה קוד כלול

    You cannot define AfterPublish and wish it will work, as it is not a defined target for you to override and will not be called by MSBuild/Visual Studio automatically.

    What you should do is to attach it to WebDeployPublish target using AfterTarget,

    <Target Name="AfterPublish" AfterTargets="MSDeployPublish">
    <Exec Command="start C:\test.txt" />
    </Target>
    

    Then MSBuild/Visual Studio can pick it up.

    This trick can be also used to implement other useful helpers during publish, as demonstrated in this article,

    http://sedodream.com/2012/01/08/HowToTakeYourWebAppOfflineDuringPublishing.aspx


    Lex Li (http://lextm.com)

    • סומן כתשובה על-ידי lucy-liuModerator יום שישי 20 אפריל 2012 07:02
    •