Clearing downloaded Source Link cache for Visual Studio for Mac

Xamarin.Forms has support for Source Link for a while now. With Visual Studio for Mac you can now dive into the Forms NuGet (or any NuGet that support Source Link of course) and debug code that you didn’t even write! Although it should never happen™, there might be times where you need to clean the Source Link cache of downloaded code. In this short post you will find out where the code is hiding on your Mac and how to clean it.

What is this Source Link you speak of?

If you don’t know what Source Link is all about, please read here or have a look at the Xamarin Show episode I got to do on it below.

Source Link - Debug Third-Party Libraries | The Xamarin Show

The way Source Link works is that the NuGet is tied to a specific commit on GitHub (or other versioning provider). When you hit an exception or step into some code from that NuGet, it downloads the right file, associated to that commit and lets you debug through it.

This means that somewhere on disk some kind of cache is accumulating.

Dude, where’s my cache?

The cache can be found in ~/Library/Caches/VisualStudio/8.0/Symbols. In that folder you will find a number of different folders. Each folder represents a different user/org on the versioning system. In the screenshot below you can see I have downloaded source files from jfversluis (hey, that’s me!), mono and Xamarin. Under each of these folders you will find different repositories.

Screenshot of the Finder showing the Source Link cache folder
Source Link cache folder

If I would go into the Xamarin folder for instance, I would find the Xamarin.Forms folder and the Essentials folder. Then under that you will find folders that are named like the hashes of the commits that are downloaded. So a full path to a file might look like this: ~/Library/Caches/VisualStudio/8.0/Symbols/xamarin/Xamarin.Forms/acb920970747bd44029e8cce61453ebc5874e104/Xamarin.Forms.Core/Entry.cs.

Now, again and honestly: this should never happen and honestly I have never found a reason to clean the cache. At least not other than testing purposes. But I figured it might just be useful to know where the cache is in case someone is searching for it.

To clean the whole cache, simply clear out the Symbols folder, or, if you want to clear something more specific, just delete a certain subfolder or even just one file. And that’s it already! Just go into your Source Link routine that you wanted to do and retry. The folders and files will repopulate.

Wrapping up

Source Link is a great solution and everyone should support it! Check out my other blog post about this. This post has some more info on how to set it up or how to use it. If for any reason you need to remove the cache, now you know where the files are placed.

Happy debugging!