Skip to content

Instantly share code, notes, and snippets.

@roy-t
Last active February 19, 2023 10:43
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save roy-t/2f089414078bf7218350e8c847951255 to your computer and use it in GitHub Desktop.
Save roy-t/2f089414078bf7218350e8c847951255 to your computer and use it in GitHub Desktop.
Install XNA 4.0 under Microsoft Visual Studio 2017

This guide will provide you with a workaround for using XNA in Visual Studio 2017. This will solve problems with the target files and Microsoft.Build.Framework.dll such as: Error loading pipeline assembly "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.Framework.dll"

  1. Download a modified version of the XNA vsix: https://mxa.codeplex.com/
  2. Unzip XNA Game Studio 4.0.vsix and replace the <Installation /> tag in extension.vsixmanifest with this:
 <Installation InstalledByMsi="false">
    <InstallationTarget Version="[12.0,16.0)" Id="Microsoft.VisualStudio.VSWinDesktopExpress" />
    <InstallationTarget Version="[12.0,16.0)" Id="Microsoft.VisualStudio.Pro" />
    <InstallationTarget Version="[12.0,16.0)" Id="Microsoft.VisualStudio.Premium" />
    <InstallationTarget Version="[12.0,16.0)" Id="Microsoft.VisualStudio.Ultimate" />
    <InstallationTarget Version="[14.0,16.0)" Id="Microsoft.VisualStudio.Community" />
    <InstallationTarget Version="[14.0,16.0)" Id="Microsoft.VisualStudio.Enterprise" />
  </Installation>
  1. Place everything in a zip file again and change the extension to vsix. Now run the the vsix file. It should give a warning message but other than that install for VS2017 without problems.

  2. Copy everything from C:\Program Files (x86)\MSBuild\Microsoft\XNA Game Studio to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\XNA Game Studio

  3. Open the Visual Studio 2017 developer command prompt by searching for Developer command prompt for VS 2017 as administrator and execute the following code: (this will add the new version of Microsoft.Build.Framework to the Global Assembly Cache).

cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
gacutil /i Microsoft.Build.Framework.dll

Note that the bug is tracked here: dotnet/msbuild#1831

After this you should be able to work with XNA in Visual Studio 2017 without problems. Remember that you can upgrade the .Net version XNA uses by manually editing the csproj files in notepad :).

@Wings-12
Copy link

Unzip XNA Game Studio 4.0.vsix and replace the tag in extension.vsixmanifest with this:

↑ I don't know how to replace the tag in extension.vsixmanifest with that.
Please help me. I'm a beginner about programming.

@davidhesselbom
Copy link

davidhesselbom commented May 11, 2018

I skipped step 5, but everything still appears to work (I can create new XNA projects as well as build and run them). Why is step 5 necessary?

EDIT: Turns out that while I can create new projects and build them, I cannot build existing (old) projects (created with VS 2013):

Error loading pipeline assembly "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Microsoft.Build.Framework.dll".

The same thing happened to OP here. I guess this is because I skipped step 5.

But, this also leads me to believe that there's something in the .sln or maybe the .csproj files that causes this error, and that these files can be modified somehow to work with VS 2017 without step 5.

Will update this post if I figure out how.

@C00lzer0
Copy link

C00lzer0 commented May 16, 2018

Nice guide (thx 4 that) but for me it also doesn't work :(

I got the same error after loading my old xna project as SimonDarksideJ:
"Your installation of XNA Game Studio does not support this project (XNA Platform = 'Windows Phone', XNA Framework Version = 'v4.0')"

Also creating a new project does not work (same error here too).

The interesting part is that the content pipeline importers are working:
image

Is it possible to switch back to the "old" Microsoft.Build.Framework ?

Edit:
After a lot of reading an testing i finally switched to MonoGame (3.7 development version) to get it work with VS 2017 and it runs now on my WP10 (needs only some adjustments for scaling XD).

@wldevries
Copy link

wldevries commented Dec 12, 2018

To revert to the old dll you need to unregister the assembly from the GAC.

With the following command you can list the dlls that are currently registered:
gacutil /l Microsoft.Build.Framework

The entry that I registered from my Visual Studio 2017 installation is the following entry:
Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

To uninstall it you need to pass the entry you found above to gacutil /u as a parameter and remove all the spaces:
gacutil /u Microsoft.Build.Framework,Version=15.1.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=MSIL

To fix Visual Studio after an upgrade you need to register the updated dll in the GAC
I've found that Visual Studio 2017 often stops working or weird behavior starts to occur after I upgrade it. The reason is that with each update to Visual Studio the Microsoft.Build.Framework.dll is potentially updated and VS relies on it. To fix it you need to reregister the dll in the GAC. To do this you repeat step 5 in the guide above and if you are using Visual Studio 2017 Pro like me the commands are:

cd C:\Program Files (x86)\Microsoft Visual Studio\2017\professional\MSBuild\15.0\Bin
gacutil /i Microsoft.Build.Framework.dll

The Visual Studio 2019 path has changed slightly:

cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin
gacutil /i Microsoft.Build.Framework.dll

Copy link

ghost commented Jun 22, 2019

On the download site, it only gives me the ability to "download archive." Where is the .vsix file I want to unzip and edit in there?

@roy-t
Copy link
Author

roy-t commented Jun 23, 2019

@Nalonnariek unfortunately this file was hosted at CodePlex, which has shut down. I'm not sure if the file is hosted anywhere else. I'm afraid it is really time to move to MonoGame, which is API compatible with XNA.

You can also try sending a message to @SimonDarksideJ (https://github.com/SimonDarksideJ) he has archived a lot of XNA stuff, and I think he said he would also archive this VSIX file somewhere).

@SimonDarksideJ
Copy link

This is my xna archive site, with the entire xna catalogue and more.
https://github.com/SimonDarksideJ/XNAGameStudio
Can't recall if I did put the xna studio stuff on there, but I'll check, and if it's not I will

Copy link

ghost commented Jun 24, 2019

Ok, thanks to both of you for your help.

@Eversor
Copy link

Eversor commented Oct 19, 2020

I don't know why "Error loading pipeline assembly "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Microsoft.Build.Framework.dll". happens, but i found out you can solve it by creating a new c# project to "warm up" VS. It will then behave and the error should not happen again.

@jordiserres0
Copy link

Thank you so much for posting. After a re-installation of Visual Studio, this bug left me frozen, since I couldn't compile my solutions anymore.

@Eversor
Copy link

Eversor commented Nov 20, 2020

Funny i had this problem again 5 days ago and was able to solve it by dropping on my own solution :D Happy to know it helps someone else <3

@intelligentvending
Copy link

I have it running happily in VS2019 following all of these steps, with the addition of needing to install these extra items to the GAC for it to work in step 5:

gacutil /i Microsoft.Build.Framework.dll
gacutil /i Microsoft.Build.dll
gacutil /i System.Collections.Immutable.dll
gacutil /i Microsoft.Build.Utilities.Core.dll

Hope this helps someone.

@DoubleBullet
Copy link

DoubleBullet commented Mar 28, 2022

I have it running happily in VS2019 following all of these steps, with the addition of needing to install these extra items to the GAC for it to work in step 5:

gacutil /i Microsoft.Build.Framework.dll gacutil /i Microsoft.Build.dll gacutil /i System.Collections.Immutable.dll gacutil /i Microsoft.Build.Utilities.Core.dll

Hope this helps someone.

Thanks. This helped for my VS2019.

@isral
Copy link

isral commented Sep 6, 2022

In VS2022, on create new project, I get "The system cannot find the file specified. (Exception from HRESULT 0x80070002)".
I already do gacutil like @intelligentvending do.
Help me.

@Arefu
Copy link

Arefu commented Sep 6, 2022

I haven't installed in 2022, I've moved on from XNA.
Although I did try to see what goes on, I am not sure what to blame. XNA technically is dead according to MS, but that's not to stop you chipping away further.

@roy-t
Copy link
Author

roy-t commented Sep 6, 2022

I'm sorry. Microsoft stopped working on XNA in 2013. I wrote this guide back in 2017 and even then it was a super hacky way to get everything working. I haven't tried enabling this in 2022. You can try to use MonoGame or FNA, Both are drop-in replacement that should work without too many problems. Though there are some weird quirks with both of them.

@Arefu
Copy link

Arefu commented Sep 6, 2022

Oh, wow, I commented here, my bad, I didn't mean comment on this one haha, @isral commented on my one here, I had a massive derp when I wrote my reply here here thinking I was sure that I already replied once, I guess that answers that humdinger.

@SimonDarksideJ
Copy link

The MXA installs for installing XNA Game Studio are still on the XNA Game Studio Archive here
https://github.com/SimonDarksideJ/XNAGameStudio/wiki/GettingStarted
There are still only catalogued up to the 2017 version, but it's not that hard to unpack the MSIX installers and update them to newer versions (seen it working in VS2019) but the Visual Studio Team are deprecating older features that the XNA GS depends on as far as I know, so the better route is to still use the versions compatible with these installers for accessing XNA content.

The archive is still slowly updating XNA content to MonoGame, but it's slow progress with only one hand on the wheel ;D

@DanielJonesEB
Copy link

DanielJonesEB commented Sep 25, 2022

Many thanks for this guide.

My project can't resolve a few classes from the Microsoft.Xna.Framework.Audio package, particularly Cue, AudioEngine, WaveBank and similar. I've poked around and it looks like they're not in the DLL? I'm not really very experienced in C# or Visual Studio, so I'm probably missing something obvious. I'm utterly confused as to why half the contents of the package would be missing!

errors

xnadll

Any help would be most gratefully received. I'm trying to resurrect an old XNA 3.0 project. I figured that I should try getting it to compile under XNA 4.0 first, and then think about porting it to Mono/FNA. It's been a bit of an epic journey, as I'm a Mac user and have already spent the day faffing about with Bootcamp so I can install Windows :)

@DanielJonesEB
Copy link

D'oh - I was being a twazzock and not reading things properly. I mistakenly believed that, for example, Microsoft.Xna.Framework.Audio.Cue class would be in the Microsoft.Xna.Framework.Audio assembly, and not Microsoft.Xna.Framework.Xact. Probably a rookie's mistake, but it seems that package names and assembly names do not need to match :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment