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"
- Download a modified version of the XNA vsix: https://mxa.codeplex.com/
- 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>
-
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.
-
Copy everything from
C:\Program Files (x86)\MSBuild\Microsoft\XNA Game Studio
toC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\XNA Game Studio
-
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 :).
- Roy Triesscheijn @roytries http://roy-t.nl
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:The Visual Studio 2019 path has changed slightly: