Install Microsoft XNA 4.0 refresh without VS2010 for VS2013

Microsoft XNA 4.0 refresh is a very good framework for doing various things including game development, simulation, etc. Of course as with all good things, Microsoft is not going to support it anymore. And one more reason in not investing in MSFT technology. But that is besides the point that one cannot simply install XNA 4.0 without a VS 2010 installation. I had VS 2013 on my machine and wanted XNA for some simulation stuff I have been developing. And I don’t want to overload my machine with multiple versions of Visual Studio.

XNA installer will not allow you to go ahead without VS 2010 or Windows Phone Developer tools. So what do we do? We install it manually. But below is a script that can be used to semi-automate the installation. Of course I got a lot of help from http://blogs.msdn.com/b/astebner/archive/2009/06/12/9740290.aspx. The script was taken from http://78bytes.com/blog/2013/08/visual-studio-2012-xna-4-0-refresh/ and I changed a couple of lines so that it can work flawlessly on VS 2013.

Below is the script for x64. If you are running a 32 bit machine, go to 78bytes, download the batch file and update the x86 script accordingly. Put the below code in a text file, make the extension .bat and run it with Administrator privileges. Make sure that you have downloaded the XNA setup and placed it in the same directory as the batch file. Happy Game Programming!

%~dp0XNAGS40_Setup.exe /extract:%~dp0XNA
%~dp0XNA\redists.msi /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\XLiveRedist.msi" /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Redist\XNA FX Redist\xnafx40_redist.msi" /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\xnaliveproxy.msi" /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\xnags_platform_tools.msi" /passive
"%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\xnags_shared.msi" /passive
msiexec /a "%ProgramFiles(x86)%\Microsoft XNA\XNA Game Studio\v4.0\Setup\xnags_visualstudio.msi" /qb TARGETDIR="%~dp0XNA\VS Tools"
xcopy "%~dp0XNA\VS Tools\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\XNA Game Studio 4.0" "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\XNA Game Studio 4.0" /e
%~dp0XNA\arpentry.msi /passive
%~dp0FindAndReplace.exe "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\XNA Game Studio 4.0\extension.vsixmanifest" "10.0" "12.0"
"%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" /setup
rmdir %~dp0XNA /s /q

PS: I wish all of you a very Happy New Year 2014.