Install XNA 4.0 GS in VS 2019 Community

UPDATE

Be careful with this solution as it may cause trouble when updating VS Studio 2019! Read second post in this thread for details and a solution which worked for me!

UPDATE END

This might be helpful, if you have legacy XNA 4.0 projects and you want to be able to build them with Visual Studio 2019 Community.

I found this a guide on how to do it here:
http://flatredball.com/visual-studio-2019-xna-setup/

After following this guide I needed to do additionally the following steps to be able to build XNA 4.0 projects which were suggested as a workaround by roy-t in the thread here:

  1. Open a command prompt
  2. cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\
  3. Run VsDevCmd.bat
  4. Within VsDevCmd.bat cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\
  5. Run gacutil /i Microsoft.Build.Framework.dll

After that I am able to create new XNA 4.0 solutions and also to open and build existing ones.

Just wanted to share the solution :slight_smile:

1 Like

I could not open or create any project at all after a VS 2019 update! I can’t recommend this anymore because it caused trouble on my machine after the last Visual Studio 2019 update as also pointed out in the comments under one of the above links.
Even a so called “last resort” by Microsoft to fix installation errors in VS 2019 I read about somewhere in the Microsoft community blogs didn’t help fixing the issue.

Just wanted to leave some Info how I got this fixed. So basically the issue was, that with Step 5 the Microsoft.Build.Framework.dll gets installed to the Global Assembly Cache which apparently does not get cleared when Visual Studio gets uninstalled or even the “last resort” “cleanupinstallation.exe” tool from Microsoft is being used. So the solution was to just undo the installation / removing the dll from the GAC / Global Assembly Cache! To do this I used the gacutil.exe tool from Microsoft:

I tried to run the tool from inside Visual Studio 2019 by starting it through the menu first but it lacks administrator rights and so it did not work this way. (But in case you want to know how to start it from inside Visual Studio 2019, the menu point can be found at the main menu at “Tools --> Command Line --> Developer Command Prompt”.)

As mentioned we need admin privileges in this case to be able to uninstall from the Global Assembly Cache I started the Tool by opening the “Windows Start Menu” and typing “Developer Command Prompt for Visual Studio 2019”. You can right click and click on “Run as administrator” or there should be an option to “Run as administrator” directly visible if the tool is found after you typed the first letters of its name.

If this does not work you can maybe find the “gacutil.exe” tool at (copied this from the shortcut “Target”):
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
or
create a shortcut may work for you if the tool is installed at the same location like in my case:

Target: %comspec% /k “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat”
Start in: “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community”
Comment: Open Visual Studio 2019 Tools Command Prompt

After I managed to open the gacutil.exe tool as administrator. Now we should be able list all installed assemblies / dlls with:
gacutil.exe -l

This gave me to much output and so I ran the next command to only output the dll / assembly which got installed earlier in my case:
gacutil.exe -l Microsoft.Build.Framework

It found 4 entries and since I didn’t really care to break something any longer at this point I just tried to run the uninstall command for these items:
gacutil -u Microsoft.Build.Framework

3 of the 4 gave a message that the “assembly is required by one or more applications”. So the command should be safe and should not break anything.

The one that messed everything up got uninstalled successfully! If in your case it does not work maybe check if uninstalling everything XNA 4.0 related first does allow you to uninstall it afterwards?! Just an idea.

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.2
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************

C:\Windows\System32>gacutil.exe -l Microsoft.Build.Framework
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
  Microsoft.Build.Framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
  Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
  Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

Number of items = 4

C:\Windows\System32>gacutil.exe -u Microsoft.Build.Framework
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.


Assembly: Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
Unable to uninstall: assembly is required by one or more applications
Pending references:
              SCHEME: <OPAQUE>  ID: <{71F8EFBF-09AF-418D-91F1-52707CDFA274}>  DESCRIPTION : <.NET Framework Redist Setup>

Assembly: Microsoft.Build.Framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
Unable to uninstall: assembly is required by one or more applications
Pending references:
              SCHEME: <OPAQUE>  ID: <{71F8EFBF-09AF-418D-91F1-52707CDFA274}>  DESCRIPTION : <.NET Framework Redist Setup>

Assembly: Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
Uninstalled: Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

Assembly: Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
Unable to uninstall: assembly is required by one or more applications
Pending references:
              SCHEME: <OPAQUE>  ID: <{71F8EFBF-09AF-418D-91F1-52707CDFA274}>  DESCRIPTION : <.NET Framework Redist Setup>
Number of assemblies uninstalled = 1
Number of failures = 0

C:\Windows\System32>
1 Like