Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rawR function that checks for required .NET framework #19

Open
tobiasko opened this issue Nov 25, 2020 · 0 comments
Open

rawR function that checks for required .NET framework #19

tobiasko opened this issue Nov 25, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@tobiasko
Copy link
Collaborator

tobiasko commented Nov 25, 2020

What about a rawR function that checks for the installed .NET framework? The C# code could be based on

 
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";

using (var ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
{
    if (ndpKey != null && ndpKey.GetValue("Release") != null)
    {
        Console.WriteLine($".NET Framework Version: {CheckFor45PlusVersion((int)ndpKey.GetValue("Release"))}");
    }
    else
    {
        Console.WriteLine(".NET Framework Version 4.5 or later is not detected.");
    }
}

// Checking the version using >= enables forward compatibility.
static string CheckFor45PlusVersion(int releaseKey)
{
    if (releaseKey >= 528040)
        return "4.8 or later";
    if (releaseKey >= 461808)
        return "4.7.2";
    if (releaseKey >= 461308)
        return "4.7.1";
    if (releaseKey >= 460798)
        return "4.7";
    if (releaseKey >= 394802)
        return "4.6.2";
    if (releaseKey >= 394254)
        return "4.6.1";
    if (releaseKey >= 393295)
        return "4.6";
    if (releaseKey >= 379893)
        return "4.5.2";
    if (releaseKey >= 378675)
        return "4.5.1";
    if (releaseKey >= 378389)
        return "4.5";
    // This code should never execute. A non-null release key should mean
    // that 4.5 or later is installed.
    return "No 4.5 or later version detected";
}

as shown here by Microsoft.

We would just need to write into a tmp file instead to the console. The R function could be something like dotNetInfo() aligned with sessionInfo() output. Or we directly check if >= 4.5.1 and return a logical, but then the function should be named is.NET() and contain a parameter named release and we would set it to 4.5.1 as default. This would also be very useful for CI, since we probably can't request specific .NET version on the test infrastructure.

What do you think, @cpanse ?

@tobiasko tobiasko added the enhancement New feature or request label Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants