In a continuous integration environment, deploying ASP.NET MVC applications are done by a click of a button, triggered by a check-in, and then many moving parts of the integration service will take care of distributing the artifacts to the relevant servers. But here we are discussing about how to get your ASP.NET code to be tested on a local IIS server environment. So let’s start with dependancies, and what needs to be included with the deployment.
High level ASP.NET MVC website dependencies are:
- The .NET Framework
- External services – eg: database, web services etc
What to include with deployment:
- /bin/folder – compiled code
- Special files – eg: Web.Config, Global.asax
- ASP.NET MVC diverges when it comes to views – include everything under Views folder
What not to include:
- Source code files (already included as compiled binaries)
- What system-level applications and APIs does the application require (eg: OS version, IIS version, .NET Framework version) – does any software need to be installed on the server?
- What system level folders or files does teh application require?
- Does the application require databases? – is it properly configured (ie. users created etc)? – have there been any updates to the database scheme since the last release?
- What other servers or services does the application interact with? (firewall rules etc)
- Do I have all of the appropriate licenses purchase and available?
Deploying to IIS
- Hosting ASP.NET MVC is similar to ASP.NET
- Ensure that the target web server has .NET 4.0 or later
Run the following script against the database to add a login as a member of a fixed server role. (or use ALTER SERVER ROLE instead as this will be deprecated soon)
If getting an access denies error, try adding the server name for database.
Right click on the project and select publish to publish the web site.
Run the following command on Visual Studio Command Prompt.
Change the connection string to meet these shared settings.
And voilà, it’s out there to be tested!