Posts Tagged ‘Installer’

Create a Web Service Installer (Part – 1)

May 24th, 2009 13 comments
I’m writing this article because I read a lot fo articles on the internet to create an installer for web applications. But none of them was comprehensive. In recent days I have to create a setup project for Web Services project and I couldn’t find any thing helpfull.

To add a Web Setup Project in your solution, just right click the solution and select Add -> ‘New Project’

It will be in ‘Other Project Types’ -> ‘Setup and Deployment’ -> ‘Web Setup Project’.

Name it whatever you want and hit ok. It will then show up in your solution explorer as a separate project.

Our next step will be to configure the web setup project to take the compiled assemblies (\bin directory contents) + content markup (.aspx, .config, etc files) from our Web Application Project and use them as inputs within our setup project. To-do this, right-click on the web setup project and choose the ‘Add -> Project Output’ from the menu.

It will appear a dialog, select ‘Primary Output’ and ‘Content Files’ from the list and press ‘Ok’.

This will add concerned files in their respective locations. The good thing about the Windows Installer is this that now you shouldn’t be worry about any changes occur in your web services application. As whenever the dll for web services application has been change, you just compile the setup project and it will add the new dll from the source directory.

Below is the view of ‘Web Application Folder’ after last step.

Now here is the view of ‘Bin’ folder, you can see that it copies all the required dlls to run the application. As in my case it copied the dlls of Sharepoint as well.

Ok, before doing the build action, we can make small configurations for the application. Right click on the ‘Web Application Folder’ in Setup project and select Properties. Now change the ‘DefaultDocument’ to one you want as default, like in my case I choose ‘GetSharePointData.asmx’. Also change the ‘VirtualDirectory’ name to ‘MySharePointServices’. You can change the name of Virtual Directory from the Installer.

When i was working on it i was creating web services for a sharepoint site, but this is a generic installer and you can use it anywhere. We can achieve the deployment work in other ways as well like using XCopy but doing deployment using Windows Installer is a much better way and you can leave deployment and configuration on normal users.

Alright now lets start to play with visual studio and .Net, consider we have already created a web service application and now we want to deploy these web services on live or staging servers.
Add a Web Setup Project to the Solution

 Now build the Setup Project, for this right click on the ‘MyApplicationInstaller’ and choose ‘Build’. It will create the Installer for your web services project. It create a MSI file. You observed that compilation of the Setup project is a bit slower. It because of the fact that it add all the content files and dlls in package, so if you have number of things in your application it will take more time to create a Installer.

One more thing to remeber that you have to build the Setup project seprately,
because by default Visual Studio does not include the Setup project in build
process. So if you are doing build action from solution. it will just build the
main application and not the Setup project.

Thats all your Installer is ready, just pick the MSI file from the ‘Debug’ folder in ‘MyApplicationInstaller’ project directory and place it on the cleint machine and just run the ‘MSI’.

Here you can select the application pool for your web application. As my
application need to run under the same application pool as of SharePoint site. I
select the required one. You can also set the Virtual Directory name here.

Now if you open the IIS Manager, you can open it by using the command ‘inetmgr’ in ‘Run’ console. You can see the new web application created by your own installer in the ‘Default Web Site’ node.
If you right click on the application and open the ‘Properties’, you will see the it set the application pool you selected in Installer and it also set the ASP .Net version for your application. As my application required ASP .Net 2.0, so it sets it to ASP .Net 2.0.

Note: I have developed the whole Installer using Visual Studio 2008. If your are using Visual Studio 2005, you have to set application pool and ASP .Net version your self. Here is a small difference between the VS 2005 and VS 2008 Installers. But don’t you worry in my next step I’m doing this using ‘Custom Actions’. So you can also get the understanding of using ‘Custom Actions’ for Windows Installer.

Part – 2

Categories: .Net Tags: , ,