views:

115

answers:

3

What is the best way to add into the build/compile script of an Asp.net project to initiate a IIS to restart the website on DLL rebuild instead of the first request to the site.

Current Process

  1. Compile Project
  2. Wait
  3. Hit APSX Page
  4. IIS starts reload
  5. Wait
  6. Page loads

Ideal process:

  1. Compile Project & Reload IIS
  2. Wait
  3. Hit APSX Page
  4. Page loads

The first way I though of was add a request to just hit one of the pages in the "Post-Build events". Just wondering best practices. This would be similar to "Start" which opens a page immediately on build.

Update: The reason I would like to accomplish this is for just for efficiency. I would the to encapsulate the compile time and the restart time into one batch to save on time on step 4 below

  1. VS: ctrl+shift+b
  2. Wait for visual que "Build succeeded".
  3. Broswer: F5.
  4. Wait for IIS reload. (as well as Hit kbd>F5 in unanswered questions in SO)
  5. Test page
+2  A: 

A naive way would be to write a shell vb script or PowerShell script to use XmlHttpRequest to request a page from the site, and include that as a post-build task.

Is there any particular reason you feel the need to do this? If you're experiencing performance issues at the first JIT then you may need to consider breaking up your application into smaller projects/DLLs (assuming that size is the issue), or start looking at bottlenecks that occur when your app starts.

Another question: why the IIS reset? That won't cause the DLL to be recompiled until the first page request. Unlike classic ASP, it isn't necessary to restart IIS for DLL changes to be allowed/take effect.

David Lively
This is a very good point.
Daniel Dyson
Ended up using Powershell and Net.WebClient. Added the script to the Post-build events
Glennular
+1  A: 

Add ‘iisreset /stop’ into the Pre-Build event and ‘iisreset /restart’ at the end of the Post-Build event.

As David mentioned, you should try to find out what the underlying issue is here. If you are experiencing performance issues when first loading a website, this is quite normal. The initial compilation often takes some time to occur. Resetting IIS is only going to make it take longer. If there is another issue, please post your reason for doing this here, and we can see if we can help you.

Daniel Dyson
I don't need a full IIS restart of all websites, just the one website being recompiled.
Glennular
Got ya. Your question was not very well worded originally so it wasn't entierly clear that you didn't want an iisreset. You still haven't explained what the underlying problem is here.
Daniel Dyson
+1  A: 

The "wait" you are hoping to remove from the process is most likely the aspx markup pages compiling. When you build in VS by default it will compile all your code, but it will not compile your markup aspx pages. You can get round this by adding a Web Deployment Project to your solution, which allows you to precompile the markup pages. This way the initial load time after deployment should not be very much different to any other load time.

Ben Robinson