Running a powershell script while compilation

Last post 07-29-2008 10:02 AM by ash143gupta. 3 replies.

Sort Posts:

  • Running a powershell script while compilation

    07-29-2008, 6:55 AM
    • Member
      131 point Member
    • ash143gupta
    • Member since 04-27-2007, 3:42 AM
    • Posts 71

     Hi i want to compress all my png's using software called optiping but instead of doing it manually i want it to be done automatically on every compilation of my website i have the script which is mentioned below but i dont know how to run it. should i make a batch file , i tried that also but dont know how to get it executed while compilation and building process is going on.

    If there is some other way to achieve this than please write the process and explain each step as i am new to powershell.

    Here is the script which will search all png's in my website and try to compress them

     

     

    gci -include *.png -recurse | foreach
     { $fileName = $_.FullName; cmd /c "C:\soft\png\optipng.exe -o7 `"$fileName`"" }
      
    Mark as Answer if the reply helps you
    Visit me at my blog
    Small Workarounds
    Filed under:
  • Re: Running a powershell script while compilation

    07-29-2008, 8:15 AM
    • All-Star
      20,998 point All-Star
    • Jeev
    • Member since 11-24-2005, 12:49 PM
    • Posts 3,163

     you should be able to hook up an msbuild task during the build process. If you have a batch file.. you should be able to kick it off from msbuild.You may want to check out

    http://msbuildtasks.tigris.org/ 

    and see if there is a task that is already  available

     

    Jeev
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If you get the answer to your question, please mark it as the answer.
  • Re: Running a powershell script while compilation

    07-29-2008, 9:55 AM
    • Member
      131 point Member
    • ash143gupta
    • Member since 04-27-2007, 3:42 AM
    • Posts 71

     Thank you jeev for your quick reply

    I want you to look at this post by omar al zabir

    http://msmvps.com/blogs/omar/archive/2008/04/07/reduce-website-download-time-by-heavily-compressing-png-and-jpeg.aspx

    Here he refers to many techniques of compressing but he has not specified where to place this code and in which file to place this code or how to place this code so can you please create a workaround seeing this article.

    Many Thanx......

    Mark as Answer if the reply helps you
    Visit me at my blog
    Small Workarounds
  • Re: Running a powershell script while compilation

    07-29-2008, 10:02 AM
    Answer
    • Member
      131 point Member
    • ash143gupta
    • Member since 04-27-2007, 3:42 AM
    • Posts 71

     Thank you jeev  the man omar has just posted the solution to my question and i am sharing it here but its not the exact same thing which i wanted he says that i have to run this scripts externally from the powershell shell to compress files inside my website folder and than copy them to production

     

    Here is what Omar Al Zabir said:

    Install powershell and run powershell

    Go to you website folder within powershell console

    Run the scripts

    It will compress all the pictures inside your website folder

    Now you can copy those compressed files to your production environment.

     

    Mark as Answer if the reply helps you
    Visit me at my blog
    Small Workarounds
Page 1 of 1 (4 items)