Deploying asp.net MVC application - asp.net-mvc

I've an ASP.NET MVC-2 Website, which is running perfect at my development machine(IIS-7, Win7).
When I copied my full website to remote server(Windows Hosting with .net 4.0), it displays Error-404.
Can you pls assist me to deploy it in remote host machine.

Your question is a bit broad, but for a start might I suggest not manually copying the files over to the new environment (acceptance, production, QA...etc.) as a "deployment mechanism".
Ideally you want to setup a continuous build system which allows you to automatically build your project(s), apply the correct configuration, package and deploy it.
Troy Hunt wrote an excellent 5-part series in which he explains how to create such a setup using TeamCity, Subversion, MSBuild, Web.Config Transformations and Web Deploy.
You can check out the series 'You're deploying it wrong! TeamCity, Subversion & Web Deploy' here:
Part 1: Config transforms
Part 2: MSBuild and deployable packages
Part 3: Publishing with Web Deploy
Part 4: Continuous builds with TeamCity
Part 5: Web Deploy with TeamCity
Of course the same setup is achievable using other software packages (e.g.: Team Foundation Server instead of TeamCity...etc.).
After you've deployed your site using Web Deploy (to a primary server), you can also use the Web Farm Framework to synchronize all of the servers in the farm. You want to avoid manual actions during deployment. Sure you can get all the steps (copying files, adjusting configuration files, synchronizing servers...etc.) correct, but in the long run mistakes are unavoidable.

Related

Team Foundation Server 2017 Build and Release

I'm trying to setup TFS 2017 in my company.
Everything is fine until I came to release tab.
I'm little bit confused.
How on earth I need to deploy everything to my local server. I read a lot of articles regarding this but still confused how to use artifacts.
Right now I have setted up source control and created build definition and stuck on release.
Anybody manage to setup release in TFS 2015 or 2017? Any help would be great!
I found this article that explains how to build and deploy web project on premise. Hope this will help somebody.
Need to use this arguments in Visual Studio Build task
/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish
/p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True
/p:publishUrl=$(build.artifactstagingdirectory)\for-deploy\website
It will create in Artifacts folder with website that can be simply copied to remote machine in Release definition.
You should view artifacts as single deploy able packages, so if your application has a front end website and a database you can package them up the website as one artifact and the database as another during the build. When it comes to a release, your release could deploy the website to one server and the database to another or even the same server, the choice is yours. I tend to have development environments hosted on a single server but pre-production and production are load balanced, the only change from development to production is the name of the server to deploy the change to.

Build and Deploy a Web Application with TFS 2015 Build

We have just installed TFS 2015 (Update 1) on-premise and are trying to create a Continuous Integration/Build system using the new TFS Build system. The build works fine, and gives me a green light, but when I look at the default build it has only built the binaries from the bin directory, and there seems to be no easy way to deploy the app on-premise to a local server.
There are two deploy options for a filesystem copy, and a powershell script, and it would certainly be easy enough to use them to copy files to a new server, but since the build only built the binaries, I don't see a tool to gather up the Web artifacts (cshtml, images, scripts, css, etc..) for this.
After an exhaustive google search, I've only found one article which talks about this at:
http://www.deliveron.com/blog/building-websites-team-foundation-build-2015/
However, this uses WebDeploy and creates a rather messy deploy package.
How can I deploy the site (standard MVC web application, in fact my tests are using the default boilerplate site created by the create project wizard) complete with artifacts to a local server in the easiest possible way? I don't want to have to install WebDeploy on the servers, and would rather use PowerShell or something to deploy the final artifacts.
The build is just the standard Visual Studio build template, with 4 steps (Build, Test, Index & Publish, Publish Build Artifacts).
We use "Visual Studio Build" step and as Arguments for MSBuild we use following line:
/p:DeployOnBuild=True /p:PublishProfile=$(DeploymentConfiguration)
On Variables tab page DeploymentConfiguration has to be configured. It must be the Name of the publish Profile (filename of the pubxml file). If the file Name is Build.pubxml the publish profile is Build.
for example:
/p:DeployOnBuild=True /p:PublishProfile=Build
I wanted to add that Ben Day has an excellent write-up that helped us package quickly and then release to multiple environments through Release Manager.
His msbuild arguments look like this:
/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=$(build.artifactstagingdirectory)\for-deploy\website
The difference between this and the accepted answer is that this parameter set stages everything in an artifacts folder, and then saves it as part of the build. We can then deploy exactly the same code repeatedly.
We capture the web.env.config files alongside the for-deploy folder and then use xdt transforms in the release process to ensure everything gets updated for whichever environment we're deploying to. It works well for all our web projects.
We use WebDeploy/MSDeploy for 40+ applications and love it. We do install WebDeploy on all our servers so we can deploy more easily but you could also use the Web Deploy On Demand feature which doesn't require WebDeploy be pre-installed.

Customize TFS Auto Builds and Deploys

We use TFS 2012 as our Source Control Repository and we also use it to deploy our Web Applications (primarily ASP .NET MVC applications with Entity Framework Code First Databases) using TFS Build and Deploy from Team Explorer within Visual Studio.
Our's is a fairly small and new setup, so up until now, we developers have been deploying code to the production servers. But from an Audit point of view, it has been decided that code installation will be handed to a separate group. At the moment, before we deploy code using TFS Automated Deploy we do a couple of steps which are manual steps
- Log on the production server, backup the individual application within IIS using IIS --> Export to export it to a zip file.
- Stop application pool for the IIS application where new code is being installed
- Install new code from Visual Studio --> Queue new Build
- Get back on the server to restart the application pool and do tests to see if the application is working as expected.
I wondering, if anyone can guide me, if there is any way to change the Automated Build and Deploy template / process / workflow to do these manual steps before it does these steps before and after it deploys the code? Basically, the new team doing the code install to the Production Server and they will still click and install code automatically but the buid templace / process / workflow will do these steps as a part of the Build / Deploy process.
thanks
if you can code it, Powershell, bat etc. then you can add it to the template.
Identify where in the workflow you need to add your new steps. you can then add an invoke process activity to call out to your scripts, that will do the currently manual steps.
I would have thought most of the IIS steps can be automated using powershell and iis appcmd
Also it may well be worth looking at Release Management 2013 as your deployment pipeline, it will give a more Auditable stream and allow for sign off to approve deployments. http://www.visualstudio.com/en-us/products/release-management-for-microsoft-visual-studio-vs.aspx

Deploying a website to Production From Team Build Server

I have a team foundation server with build server, when I run a build it deploys to a website on that box. However I also want to do the same on Production which is a server on an external network and not part of the same domain.
I thought about looking at TFS Deployer but that just seemed to work within a network, I'm going to test it out as soon as I get a chance but I thought the best idea was to ask here when working with something so critical.
Is it a really bad idea to have a way of easily deploying to production?
Does anyone here deploy to production using whatever method? How do you do it?
Essentially the accepted answer will go to the person who can tell me the best method for achieving a deployment but pointing me in the right direction is sure to get an up vote as long as it's not too obvious.
Depending on the infrastructure you have available to you you can use wix to create msi's and use SMS configuration manager to deploy them to a target collection. This is the direction that we are moving to but have not reached yet. We also integrated wix into our build process to create the MSI artifacts. The reason we wanted to go down this path was because we are using CruiseControl.net as our continuous integration server and we have a nant script that we use to perform both the build process and the deployment process. They are both separate targets in the nant file, but what we wanted was a consistent model of deployment to all environments including production.
What are are doing currently is we are manually moving zips (which are artifacts of our current build process) to production. When the zips are unpackaged in the production environment we have to remove all the web.config, app.config etc from the zips and if we have new entries in the configs they are made manually.
Found msdeploy http://blogs.iis.net/msdeploy/archive/2008/01/22/welcome-to-the-web-deployment-team-blog.aspx

Command-line to "deploy" ASP.NET MVC project

I am using Visual Studio Team Suites to develop a ASP.NET MVC project. I can deploy the web app to my dev machine using the "deploy" item from IS. Is there a command-line tool to do this task? What I am trying to do is to setup a continuous integration server (using TeamCity Pro), so that whenever I checkin new code, I will get a new build, deploy to a remote IIS server, and then run tests on the testing server.
Thanks,
-Yi
It looks like Microsoft have such a deployment tool. Never used it myself.
Scott Hanselman has blogged about it here
MSDeploy, Microsoft's upcoming command-line deployment tool (which will be integrated into VS2010) is currently available in Beta2.
Info:
http://learn.iis.net/page.aspx/346/web-deployment-tool/
Download (x86):
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1602
Download (x64):
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1603
Also, if you have disk access to the servers you want to deploy to from the CI server and don't need to install/remove things from the GAC or tweak the IIS metabase, plain old robocopy is a great option.

Resources