Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

DNX on OSX/Linux loads the wrong System.Runtime.InteropServices.RuntimeInformation package #2594

Closed
natemcmaster opened this issue Aug 31, 2015 · 12 comments
Assignees
Milestone

Comments

@natemcmaster
Copy link

System.Runtime.InteropServices.RuntimeInformation.IsPlatform(OSPlatform.Windows) always returns true, even on OSX and Linux.

Repro
Run this on different platforms. It will always print "Windows".

{
    "dependencies": {},
    "frameworks": {
        "dnxcore50":{
            "dependencies": {
                "System.Console":"4.0.0-*",
                "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*"
            }
        }
    }
}
using System;
using System.Runtime.InteropServices;

namespace Test
{
    public class Program
    {
        public void Main(string[] args)
        {
            if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Console.WriteLine("Windows");
            }
            if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                Console.WriteLine("Darwin");
            }
            if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                Console.WriteLine("Linux");
            }
        }
    }
}

Versions

1.0.0-beta8-15545    coreclr x64  darwin       
and
1.0.0-beta8-15545    coreclr x64  linux      

System.Runtime.InteropServices.RuntimeInformation 4.0.0-beta-23231

Pulling from https://www.myget.org/F/aspnetlitedev/api/v2

This is related to #2387. Our myget feed publishes a package of System.Runtime.InteropServices.RuntimeInformation that includes the Windows version of the dll. This gets loaded at runtime, and thus misinforms the IsPlatform API about which OS is actually running.

@natemcmaster
Copy link
Author

/cc @BrennanConroy

@muratg
Copy link
Contributor

muratg commented Sep 21, 2015

@anurse @moozzyk @BrennanConroy

Any ideas on this one guys?

@moozzyk
Copy link
Contributor

moozzyk commented Sep 21, 2015

We don't own System.Runtime.InteropServices.RuntimeInformation don't we? It's probably on CoreClr. We have IRuntimeEnvironment.

@BrennanConroy
Copy link
Member

Ya, this is because the dll in the nupkg was windows specific.

@BrennanConroy
Copy link
Member

Later versions of this package have a runtime.json with osx and Linux targets defined

@muratg
Copy link
Contributor

muratg commented Sep 21, 2015

@BrennanConroy So is this fixed now?

@BrennanConroy
Copy link
Member

It might be once Coherence passes.

@muratg muratg added this to the 1.0.0-beta8 milestone Sep 21, 2015
@muratg muratg added the bug label Sep 21, 2015
@muratg
Copy link
Contributor

muratg commented Sep 21, 2015

@BrennanConroy Please test this once we have Coherence.

@analogrelay
Copy link
Contributor

This will still be broken after Coherence, it looks like the runtime.json for it refers to osx (version-less) but we fallback directly from osx.10.10 to unix. Instead we should fall through osx. @BrennanConroy or I can fix that fairly easily.

@analogrelay
Copy link
Contributor

The same should probably be done for ubuntu.14.04 -> ubuntu

@BrennanConroy
Copy link
Member

Should also update the NetCore.Platforms list too

@analogrelay
Copy link
Contributor

I'll take this and also ping the necessary folks about updating that package.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants