XNA After Visual Studio 2010

Note this tutorial is out-of-date. You should be able to do what you need with the updated XNA Installation tutorial.

The latest version of Visual Studio that XNA, and XNA Game Studio officially works for is currently Visual Studio 2010 (and Visual C# Express 2010). This means they are two versions out of date at this point, because Microsoft released Visual Studio 2012 and now Visual Studio 2013.

But worry not. There is a way (albeit, unofficial) to get XNA to work in the later versions of Visual Studio as well.

The basic process involves installing VS 2010 and XNA Game Studio, then copying files over and making some important tweaks to get it working in the newer versions of Visual Studio. While it would be nice to provide an installer that would allow you to install XNA directly to VS 2012 or 2013, the licensing of the files needed don't allow anyone to do this distribution besides Microsoft. So instead, the process requires you installing XNA Game Studio from them first. At this point, the migration to newer versions of Visual Studio can be done yourself.

The process is somewhat tricky. There are some gotchas, and some fractally named directory structures that can make manually doing this quite tricky. So I've put together a script that will perform the migration for you. In this tutorial, I'll show you how to get the script and run it on your machine, as well as how to perform these steps manually, in the event that you'd rather do it that way.


The first step is to make sure that you've got all of the necessary prerequisites. This means you need a version of XNA Game Studio installed (over the top of Visual C# Express 2010 or Visual Studio 2010 Professional or higher), as well as whatever version of Visual Studio 2012 or 2013 that you want to install into.

So you need the following:

Instead of that last one, you could go with one of the 2012 versions, or Visual Studio 2013 Professional (or higher) but if you're new to this, that's where I'd recommend starting, mostly because it's free (and has everything that you'll ever need to make XNA games).

All of this will take some time to install. Each is a fairly hefty installation package by itself, and with all three combined, you should expect to spend a while installing it all. Maybe even a few hours if the Internet is slow.

The Script

Once you've got all of that installed, you're ready for my script that copies everything over. (If you want to do this manually, look at the steps below, but fair warning: it can be kind of tricky.)

1. Download the PowerShell Script

The first thing to do is to get the script. You can download it from my BitBucket page: https://bitbucket.org/rbwhitaker/xna-beyond-vs-2010/downloads

On that page, you'll also find a 1-page wiki, which explains some of the same information that I'll be describing here. And if you have any problems with the script, I'd love for you to create issues on BitBucket (or send me an email) so that I can fix it. (Likewise, it's open source, and if you want to fork my script, make some changes, and then send me a pull request, I'd be happy to take a look at your changes as well.)

Please note: This script is provided AS-IS. It isn't guaranteed to work, nor is it guaranteed to not break other things. You use it at your own risk. But having said that, I've taken great care to make sure that it works well for a variety of systems, and I cannot conceive of any possible way that it could actually break something on your computer.

2. Opening PowerShell with Admin Rights

The script has the extension .ps1. This means it is a PowerShell script.

PowerShell is a command line program that is leaps and bounds better than the standard CMD prompt. It can do everything a normal .cmd or .bat file can do, plus a whole lot more. Plus, it has strong ties to the .NET world, so it's easy to do C#-like things in it, which is a nice added bonus. It's created by Microsoft, and is free.

If you're using Windows Vista, Windows 7, or Windows 8, PowerShell should already be on your computer. In the event that it's not, you can install it.

You must start PowerShell with administrator privileges. The script copies some files that are in system file locations (the Program Files directory) and edits them. If you don't run with admin rights, the script will fail.

For most people, the easiest way to start this up is to do this:

1. Click on the Start button.
2. In the Search box at the bottom, type in "PowerShell". This should bring up a small collection of related programs with "PowerShell" in the name. (If no results come back, there's a good bet that you don't have PowerShell installed, so you should back up to the previous section and get it.)
3. Right-click on the one that says simply, "Windows PowerShell" and choose "Run as administrator".

This will bring up the PowerShell window, which should look like this:


3. Navigate to the Script

At this point, you'll either want to use cd commands to move to the location of the script. If you're not very familiar with the command line (you should get familiar with it, but until then) it may be easiest to simply jump to the place where you saved the file in the first step with something like this:

cd "C:\Users\[username]\Desktop\"

4. Change the Execution Policy

You can try running the script now, but what you will probably discover is that it doesn't quite work. What you would see is a message that looks like this:

File [Script Location] cannot be loaded because the execution of scripts is disabled on the system Please see "get-help about_signing" for more details.

How cute! A scripting application that doesn't let you run scripts!

OK, so there's a reason for this. PowerShell is intended to be a better scripting environment than the traditional command prompt, and one way that it is supposed to be better is that it is more secure. What you're seeing is an artifact of that.

Try running the following command:


Unless you've done stuff with PowerShell before, this will inevitably be "Restricted", which is a small problem.

We need to change the execution policy to allow us to run this script. We do that like this:

Set-ExecutionPolicy Unrestricted

This allows all scripts to be executable, including signed and unsigned scripts. It's a persistent change, and not just for this session of PowerShell. When this is done, it wouldn't hurt to go back and revert this back to Restricted.

5. Run the Script

You should then be able to run the script using the following:

& '.\XNA Beyond VS 2010 Installation Script.ps1'

(It is best to run start a sub-process with the '&' at the beginning, but not required.)

At this point, the script will start running and install XNA in Visual Studio 2012 and 2013, Pro and Express, depending on which versions you've got installed already.

This will take a few minutes to run, so while you're waiting for it to complete, you may want to consider going down further and reading the process that it would take to install this manually, so you get an idea of what the script does and why.

6. Use XNA in Visual Studio 2012 and 2013!

Eventually, the script will end and you'll have XNA installed in Visual Studio 2012 and/or 2013! Go have fun and make awesome games!

The Manual Process

There are a lot of gotchas, tricks, and stumbling blocks that you could encounter when you install XNA in Visual Studio 2012 or 2013 manually. That's the biggest reason why I recommend using my script. But if you really want to do it yourself, here's the basic process.

If you're running the script, there are no need to do these steps yourself. The script will do them for you.

This manual process requires all of the same prerequisites as the script, so make sure you've already got everything else done on the prerequisite list before starting these steps.

1. Copy the XNA Extension files from Visual Studio 2010 to Visual Studio 2013

The first step is to copy the files that XNA Game Studio installs over from where XNA puts them to the corresponding location in the target version of Visual Studio.

This source folder should be: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\XNA Game Studio 4.0

The destination depends on which version you're installing to:

C:\Program Files (x86)\Microsoft Visual Studio [VERSION]\Common7\IDE\Extensions\Microsoft for a paid version (Professional, Premium or Ultimate) and

C:\Program Files (x86)\Microsoft Visual Studio [VERSION]\Common7\IDE\WDExpressExtensions\Microsoft for Windows Desktop Express versions.

In both of the above, [VERSION] should be replaced with 11.0 for the 2012 editions and 12.0 for the 2013 versions.

2. Change the Version in the Extension Configuration File

With the XNA extension directory copied over, the next step is to update the XML configuration file for the extension, so that it matches the version of Visual Studio that it is intended to work for.

Open up the directory that just got created in the copy in the previous step and find the file named extension.vsixmanifest. You will want to open this file in a text editor that has administrator privileges or you won't be able to save after you make the changes.

Look for the line that says <VisualStudio Version="10.0"> and change it to say <VisualStudio Version="12.0"> (or 11.0 if you're installing to a 2012 edition, instead of a 2013 edition). If this is for an express edition, you'll also need to add the following line below that: <Edition>WDExpress</Edition.

At this point, save the file. That should be all of the changes that are required here.

3. Clear out the Extension Cache

Visual Studio creates an extension cache so that it can quickly load extensions. It makes the assumption that this cache is always up-to-date, because whenever it makes changes to the installed extensions, it refreshes this cache on its own. Of course, what we did went out of the bounds of what Visual Studio expects, and the cache is now out of sync with the extensions that are included. So we'll need to refresh the cache ourselves.

The first part of that is to delete the old cache, which is now out-of-date.

The cache is located here for paid-for versions: "C:\Users\[USER NAME]\AppData\Local\Microsoft\VisualStudio\[VERSION]\Extensions" and here for express versions "C:\Users\[USER NAME]\AppData\Local\Microsoft\WDExpress\[VERSION]\Extensions".

The AppData folder is a hidden folder by default, so you'll need to tell Windows to show hidden folders if you haven't ever done that before.

You want to delete that entire Extensions directory.

4. Rebuild the Extension Cache

The last step is to rebuild the extension cache. To do this, open up a command promt (cmd.exe). Browse to the location of the appropriate Visual Studio .EXE file. This should be under C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE for Visual Studio 2013 (swap out 12.0 with 11.0 for Visual Studio 2012).

You then want to run the executable's setup function. For paid-for versions of Visual Studio, the executable is called devenv.exe. For express editions, it is WDExpress.exe. To run the executable with the setup function, you add the /setup flag at the end. So for paid-for versions, this would be:

devenv.exe /Setup

For an express edition:

WDExpress.exe /Setup

And at this point, you sit here and wait for several minutes. I'm not sure why it takes so long to regenerate the cache. It's probably doing more than that, but it is doing at least that much.

Eventually, it will complete, and you'll have XNA in Visual Studio 2012 or 2013!

You would then repeat this process for any of the other versions that you have installed that you want XNA available in.

Uninstall Visual C# Express 2010?

Now that things are copied over, you might be wondering if you can get rid of the old Visual Studio 2010 version. The answer is, I don't know. In theory, it seems like it should work. But I haven't tried it, and there's a distinct possibility that there's some registry key or something that would also get removed that would break things.

I've left mine alone, because I don't have any complaints about keeping an old version of Visual Studio around. But if you're bold enough to try uninstalling the old stuff, I'd love to hear what results you get.

Troubleshooting.png Having problems with this tutorial? Try the troubleshooting page!