New Computer - Steps to set up new dev environment and transfer old settings
So I got a new computer for work (Macbook Pro 13" retina) and needed to get it up and running as my new dev machine.
In my first attempt everything worked except Visual Studio 2013 wouldn’t launch. It was stuck at a white splash screen. It could have been because I installed IIS, then Visual Studio 2013, then I did a IIS Server Import from a Server Export of my old computer. Only after that did I try to run Visual Studio.
In my second attempt, after reinstalling windows and starting over, Visual Studio worked, but IIS didn’t work properly. As you’ll see in the steps below, I used IIS web deploy backup server / restore server to copy ALL my IIS settings (app pools, certs, sites, etc) but ran into a lot of problems. I kept getting a INSUFFICIENT_ACCESS_TO_APPHOSTCONFIG error, which seemed to indicate there was a permissions problem on applicationhosts.config, but in reality there wasn’t. The problem was my encryption keys in applicationhosts.config. I only realized that after trying to manually add an App Pool. Adding the App Pool worked fine, so the config file could be written to. But when I tried to change the App Pool user to a local user, which requires a username and password, I got the insufficient access error again with a sub message about something being out of bounds. User passwords get encrypted so I realized the encryption was the problem.
In my third attempt, after uninstalling IIS using Windows Programs and Features and uninstalling everything that I installed using Web Platform Installer and reinstalling IIS, everything worked. Both IIS and Visual Studio 2013 worked. I can start to code again!
Steps that worked for me
- Install Windows
- Turn off UAC by suppressing all notifications
- Using Programs and Features, add Windows Components, Install IIS. A quick way to get to the screen is Win+X (on windows 8) then select Programs and Features or type ‘f’. I recommend installing more than you may actually need because if you web deploy import server from another computer that has a component installed but you don’t you’ll get an error. Under Web Management Tools: IIS Management Console. Under World Wide Web Services: everything.
- Install Visual Studio
- Using Web Platform Installer, install any IIS components you may need, such as Web Deploy 3.5, URL Rewrite, PHP, PHP Manager, IISNode. I went ahead and installed ones for IIS Express as well just in case I need them. Make sure IIS is selected in the Web Platform Installer options so you can see the IIS components. For some reas IIS Express was selected for me.
- Add any local users you may need as users for your IIS App Pools. If you don’t use actual users in your app pools then you can skip this step. Since some of our web apps need network resources we had to add local users that can authenticate on the network resources. I’m not sure if any built in accounts can authenticate on network resources. If you do things this way, be sure to set your website to use pass through authentication (app pool user) and your anonymous authentication to Application Pool Identity.
- Now, the fun part. To get your IIS app pool and site configurations and site content off of your old computer there are a few options. As mentioned already, I first tried using IIS Export Server then IIS Import Server but ran into complications. Even if that worked, one thing I didn’t like about that was that it includes all your site content (your actual files and folders for each web site). I would rather transfer those independently. A few of my personal sites are run from my Google Drive folder and my other work sites are all in Git so I want to transfer those myself.
- Transfer all your site content. I let Google Drive handle the sites that are on Google Drive and I used a portable external hard drive to transfer my other work sites. I have them all under a Project/Git folder. Git is so great - because it’s all file-based, including the repos themselves, once you transfer everything you can start working immediately with your repositories and configs in the exact same state.
- Install Web Deploy 3.5 using the Web Platform Installer if you haven’t already.
- We want to install Web Deploy Remote Agent Service as well. The only way I found how to do this was to use Program and Features, select Microsoft Web Deploy 3.5, then click Change. When prompted click change, then be sure to select Remote Agent Service. There’s another component in Web Platform Installer called Web Deploy for Hosting Servers - that may turn that on automatically - but I’m not sure.
- Now, from your old computer, we want to push all the application pools to your new computer. Using Web Deploy takes care of all the encryption/decryption for you. And you can transfer all the app pool settings in just one line!
- Make sure Web Deploy 3.5 is also installed on your old computer. Open up an administrator command prompt (that’s in the Win+x menu too!) and navigate to (on a 64-bit machine) C:\Program Files\IIS\Microsoft Web Deploy V3. Web deploy will only work if the bit-ness of the source and destination match - so 64-bit to 64-bit and 32-bit to 32-bit. Presumably most computers, especially dev computers, will be 64-bit.
- The command to transfer all the app pools is:
msdeploy -verb:sync -source:appPoolConfig, -dest:apPoolConfig,computerName=NameOfNewComputerHere
. The reference for the syntax is here: http://technet.microsoft.com/en-us/library/dd569070(v=ws.10).aspx - Now we want to transfer each site individually. The web deploy provider I used, appHostConfig, is supposed to transfer content as well as configuration. I didn’t know that when I used it, and I can’t verify it transferred content. The command executed so fast I would be surprised if it also transferred content.
- For each site, use this command:
msdeploy -verb:sync -source:apphostconfig="website name" -dest:apphostconfig="website name",computername=NameOfNewComputerHere
. I just looked at my site list in in IIS and after each command hit the up arrow and used the arrow keys to replace the website names. Syntax reference: http://technet.microsoft.com/en-us/library/dd569080(v=ws.10).aspx - If you use local hostnames, then copy over your
C:/Windows/System32/Drivers/etc/hosts
file - Install Git
- Copy over .gitconfig that’s in the root of your home directory - for me it was my windows home directory (Users/username).
- Webmatrix - copy over site configuration -
C:\Users\Username\Documents\IISExpress\config\PublishUI
andC:\Users\Username\Documents\IISExpress\config\web Deploy
- Webmatrix - copy over IIS Express sites - if you don’t do this then no sites will show in “My Sites” - copy all the
<site>
nodes under<sites>
inC:\Users\Username\Documents\IISExpress\config\applicationhost.config
That should do it!