Referencing local build of TinyClr mscorlib

So i have forked TinyCLR.Libraries repo to make various small quality of life modifications, which will hopefully be pulled back into the main repo…

So far i have been able to easily make modifications to libraries and used them without issue. But when i make a change to mscorlib, things get weird.

I am able to build mscorlib or the entire GHIElectronics.TinyCLR.Libraries.sln without issue, but while i can reference any of the libraries successfully, i cannot seem to reference mscorlib.

First problem is when I add a reference to mscorlib, it doesn’t show up in my projects reference list.
Ironically though, my modifications are seen by the project, but random stuff from mscorlib are missing. For example Debug class has disappeared in my local build.

Of course if i go back to the nuget, Debug will reappear.
I probably dont understand all i need to know about building mscorlib, so any help to get me pass this issue would be appreciated.

I do this frequently. The experience is squirrely because of how VS finds and caches mscorlib. You do not (and should not) directly reference mscorlib. The trick here is to get rid of all the copies of mscorlib in your project that aren’t the one you want.

What you need to do:

  1. Reference your new nupkg drop point either through the VS UI using the little gear at the top of the “Manage Nuget Packages” at the solution level or with a nuget.config file at the root of your project. Make sure that your new drop point comes first before any repositories like
  2. Open Tools->Options->Nuget and press the ‘clear nuget caches’ button
  3. Stop all instances of VS
  4. Delete .vs/, **/bin, **/obj, **/packages/ in your project tree
  5. Restart VS and build your project

You may need to repeat those steps more than once

You may see instances where you get red squigglies for common things in the System namespace. This is a sign that you picked up a .net (and not TinyCLR) instance of mscorlib. Do the steps again. Always complete all the steps before doing them again because we expect things to get weird as you do the steps.

Do a “dir /s mscorlib*” and make sure that they all have the same size and it matches the one you built.

VS works against you here by trying to be ‘smart’ and pull in and cache mscorlib, particularly in the .vs/ directory. Once you get it working, it will stay working though.