Running powershell scripts along with compilation in VS2008 while deploying

Last post 07-28-2008 10:54 AM by shados. 2 replies.

Sort Posts:

  • Running powershell scripts along with compilation in VS2008 while deploying

    07-28-2008, 4:24 AM
    • Member
      131 point Member
    • ash143gupta
    • Member since 04-27-2007, 7:42 AM
    • Posts 71

     Hi all i want to run a powershell script to compress all my png's and jpegs. I have the script but i dont know how to run it while the website is being compiled.

    Could anyone please tell me which file shall i make and where should i place that file so that the content in it ie the powershell script may run along with compilig and reduce the size of my png's.

    I think this script file should be inside the root folder of my website but its only a guess.

    Please Help its urgent

    Mark as Answer if the reply helps you
    Visit me at my blog
    Small Workarounds
    Filed under:
  • Re: Running powershell scripts along with compilation in VS2008 while deploying

    07-28-2008, 10:47 AM
    • Member
      131 point Member
    • ash143gupta
    • Member since 04-27-2007, 7:42 AM
    • Posts 71

     This is the powershell script which i want to run along with the compilation of my website.

    gci -include *.png -recurse | foreach
     { $fileName = $_.FullName; cmd /c "C:\optipng.exe -o7 `"$fileName`"" }

    Mark as Answer if the reply helps you
    Visit me at my blog
    Small Workarounds
  • Re: Running powershell scripts along with compilation in VS2008 while deploying

    07-28-2008, 10:54 AM
    Answer
    • Star
      12,126 point Star
    • shados
    • Member since 07-07-2006, 7:24 PM
    • Posts 2,202

    You can run any batch file-like commands in the post build event of a Web -Application-.

    If you use a Web -Site- project, there isn't one. You can however add a Web Deployment project to your solution, then look at the last post of this thread to execute a batch file command that will then run your powershell script (That I don't know how to do, but I'm sure if you use powershell that you know how to run one from the command prompt)

    http://forums.asp.net/p/1263944/2376919.aspx

Page 1 of 1 (3 items)