You can create a program / function that tests a function / library that is not in the main version of .NET. For instance:
using System; public class CoreChecker { public static void Main(string args[]) { try { ImportNonCoreComponent(); Console.WriteLine("NonCoreAssembly found... this is full server."); } catch (Exception e) { Console.WriteLine("NonCoreAssembly not found... this is core server."); } } public static void ImportNonCoreComponent() { using NonCoreAssembly; } }
If this does not work, you will need to transfer the usage to the scope of the class and then create the class from NonCoreAssembly to ImportNonCoreComponent (I cannot recall the exact semantics of how this works).
NOTE. The using statement must be isolated from the test function. When the JIT compiler processes it, it throws an exception. This exception will not be handled by the test function, so the try ... catch statement must be in the method that calls it.
You can use this technique to implement a custom action in MSI to crash during installation, or use it as part of your C # application to trigger the message βYou need to use a full serverβ. (which will work if they install the application and then upgrade to Core).
If the difference is behavioral, you can test this behavior in your test function.
Make sure that the test function works in different scenarios and with different versions of .NET.
reece source share