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 nuget.org.
  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.

3 Likes

@mcalsyn Would you please clarify step 1 for me?
Say i dont have a “new nupkg drop point” because for all intents and purposes i am not trying to use nuget while using a local build of TinyCLR libraries.

Do i need to create something here? Create a new nupkg drop point? Exactly what is this and how would i do it?

Ive almost given up on trying to modify the libraries for the sole reason that in doing so, i cant get anything else built…

Thanks for the help

You can use other nugets as references dll while mscorlib is still nuget. Unless you want modify mscorlib. If you are not going to touch mscorlib, shouldn’t add reference this assembly directly.

Also, we see you added some new API (example Gpio), how does it work with current firmware? as I know these steps will generate new checksum and won’t work with firmware.

Breaking changes (changes to the firmware interop checksum) and non-breaking changes need to be isolated from each other using branches. It’s not reasonable to expect community participation in the code if we can’t run what is in the repo.

Everything is good from our end. Dat was saying that the changes to the API will generate a new checksum and that can’t be handled by the community.

Community can fix bugs but not change API separately from us

Or I could have missed something.

1 Like

With this info, i sorted out my issue.
Having had the mscorlib mismatch, i had removed all references in the aforementioned (GPIO driver/api) as well as my target application. I am assuming as they built without the intended mscorlib, the problem was seen when attempting to load to the hardware and thus gave the mismatch error when trying to load the application.

I now have added the reference to TinyCLR.Core regardless of the direct requirement of the programming and can now build.

Im currently sorting through some unexpected exceptions and I will report any issue or success in using the updated library with my api. so far so good.

Sorry for the undue alarm, the plausibility of building with the wrong mscorlib is a new dimension for me to look out for.

Ive since fixed some bugs in my API and tested this latest firmware working just fine. thanks

1 Like