Fixing broken MSBuild SDK resolvers

This post is just a quick documentation of a fix I found the hard way.

TL;DR:
SDK Resolver folder exists but without an SDK Resolver DLL or manifest file. This may indicate a corrupt or invalid installation of MSBuild

might be fixed by

sudo rm -r /usr/lib/mono/msbuild/15.0/bin/SdkResolvers/NuGet.MSBuildSdkResolver

(or equivalent mv). YMMV.


After updating both VS Code and the .NET Core SDK on my Fedora 29 machine, VS Code couldn't start OmniSharp correctly and wouldn't load .NET Core projects properly. The error code was a a rather cryptic one:

SDK Resolver folder exists but without an SDK Resolver DLL or manifest file. This may indicate a corrupt or invalid installation of MSBuild

This was pretty surprising given its a "standard" dnf install from the official MS repos and to be honest, I still don't actually know for sure what caused this issue (but you might see my guess if you keep reading)

Regardless, the VS Code logs weren't giving me any information on my resolvers for some reason. I could see the problem was not specific to VS Code and was actually coming from MSBuild for some reason.

Thankfully the Internet delivered in the form of two GitHub issues and a Developer Community post from which I could piece together the following:

  1. that it could be fixed by reinstalling the VS Build Tools package
  2. that the problem file (on Windows) was C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\SdkResolvers\NuGet.MSBuildSdkResolver\NuGet.MSBuildSdkResolver.dll.new

Given #1 is completely irrelevant on Linux, I followed the rabbit hole of #2 and one simple locate command later I could see that there were two different MSBuild resolver locations: /usr/share/dotnet/sdk/<version>/SdkResolvers/NuGet.MSBuildSdkResolver and /usr/lib/mono/msbuild/15.0/bin/SdkResolvers/NuGet.MSBuildSdkResolver.

I don't know enough about the internals of MSBuild to tell you why but simply removing the entire /usr/lib/mono/msbuild/15.0/bin/SdkResolvers/NuGet.MSBuildSdkResolver directory and restarting OmniSharp led to a successful project load!

Comments

comments powered by Disqus