title: Can't open or create projects: The type initializer for 'MonoDevelop.Projects.MSBuild.MSBuildEvaluationContext' threw an exception
body: <p>This morning, I found I was unable to create or open any projects on Visual Studio Community for macOS v8.1.1 (build 27) without getting the error...</p>
  
  <blockquote>
    <p>The project could not be created</p>
    
    <p>The type initializer for 'MonoDevelop.Projects.MSBuild.MSBuildEvaluationContext' threw an exception.</p>
  </blockquote>
  
  <p>This install of VS has been working for quite some time on this Mac. VS had found and installed some updates recently. This is not a box where I work routinely; it may have last worked successfully a week or so ago.</p>
  
  <p>Here is a screencapture when trying to create a Console app project, for instance. The error occurs when I hit the "Create" button.</p>
  
  <p><a href="https://i.stack.imgur.com/GahXV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GahXV.png" alt="Picture of The type initializer for &#39;MonoDevelop.Projects.MSBuild.MSBuildEvaluationContext&#39; threw an exception from the New Project screen"></a></p>
  
  <p>I've found a very similar error on a now defunct Bugzilla for the old <a href="https://xamarin.github.io/bugzilla-archives/57/57085/bug.html" rel="nofollow noreferrer">Xamarin Studio here</a>, which links me to <a href="https://github.com/mono/monodevelop/pull/2546" rel="nofollow noreferrer">this resolved GitHub issue</a> on MonoDevelop, which is now Visual Studio, from 2017, which is marked Closed and Merged. </p>
  
  <p>I've also found a very similar error report raised as another <a href="https://github.com/mono/monodevelop/issues/6684" rel="nofollow noreferrer">GitHub issue for MonoDevelop here</a>. No clear resolution there; just a reply that, "<em>Seems like MSBuild is not installed?</em>"</p>
  
  <p>They both suggest MSBuild isn't in the right place, but I'm not sure how I'd fix that.</p>
  
  <p>I have tried uninstalling Visual Studio (by trashing) and removing .NET using <code>sudo rm -rf /usr/local/share/dotnet</code>. This removed .NET, but on reinstall of VS and .NET, the error returns.</p>
  
  <p>Is there a better way to perform a clean install? Is there another way to resolve this issue?</p>
  
  <hr>
  
  <p><strong>Round 2</strong></p>
  
  <p>Since the issue was MonoDevelop specific, I did a <code>find</code> to find any file with <code>mono</code> in it. I found some stuff like this...</p>
  
  <p><code>/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono</code></p>
  
  <p>... in the Frameworks folder, and that looked promising. I've messed with MonoDevelop in the past (remember <a href="http://icsharpcode.net" rel="nofollow noreferrer">icsharpcode</a>?), know that it used to be its own, independent, OSS C# IDE, and blasted that <code>Mono.framework</code> folder away.</p>
  
  <p><code>sudo rm -rf /Library/Frameworks/Mono.framework/</code></p>
  
  <p>I also deleted Visual Studio and removed <code>/usr/local/share/dotnet</code> again, then reinstalled .NET and VS with the VS installer.</p>
  
  <p>When I tried to open Visual Studio, I got a different message.</p>
  
  <p><a href="https://i.stack.imgur.com/ajW1P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ajW1P.png" alt="Could not launch Visual Studio This application requires a newer version of the Mono framework"></a></p>
  
  <p>Now we're getting somewhere. I clicked the "Download Mono Framework" button in that dialog and initially tried installing the "Visual Studio" release from the page the button opened, tried reopening VS, and <em>got the same error as before</em>. Strangely, the VS release is <strong>5.18.1.3</strong>, and the error message, above, says I need <strong>5.18.1.24+</strong>. :thinking-face:</p>
  
  <p>I tried downloading the latest "Stable" release of the mono framework instead, which is version <strong>5.20.1.19</strong>.</p>
  
  <p><a href="https://i.stack.imgur.com/mlN3H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mlN3H.png" alt="What version of Mono is needed for Visual Studio macOS"></a></p>
  
  <p>Visual Studio opens and creates new projects without error, but...</p>
  
  <p><strong>EDIT:</strong> That was short lived. I now get a <code>/usr/local/share/dotnet/sdk/2.1.700/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(5,5): Error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
  System.TypeLoadException: Could not load type of field 'Microsoft.NET.Build.Tasks.DependencyContextBuilder:_filteredPackages' (12) due to: Could not resolve type with token 01000025 from typeref ...</code></p>
  
  <p>error when I try to build the stock console app.</p>
  
  <hr>
  
  <p><strong>NOTE:</strong> There is <a href="https://www.mono-project.com/docs/about-mono/supported-platforms/macos/#uninstalling-mono-on-macos" rel="nofollow noreferrer">an official process for deleting Mono</a> I missed, and is better than the quick &amp; dirty <code>rm -rf</code> I tried, above.</p>