Skip to content

Commit fe10951

Browse files
committed
Portable project builds!
1 parent 41ee5d3 commit fe10951

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

LibGit2Sharp.Portable/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"supports": {
3-
"net46.app": {}
43
},
54
"dependencies": {
65
"Microsoft.NETCore": "5.0.0",
76
"Microsoft.NETCore.Portable.Compatibility": "1.0.0",
7+
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-beta-23409",
88
"System.Security.Cryptography.X509Certificates": "4.0.0-beta-23409",
99
"System.Security.SecureString": "4.0.0-beta-23409",
1010
"LibGit2Sharp.NativeBinaries": "[1.0.132]",

LibGit2Sharp.Shared/Core/Platform.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace LibGit2Sharp.Core
45
{
@@ -20,6 +21,7 @@ public static OperatingSystemType OperatingSystem
2021
{
2122
get
2223
{
24+
#if NET40
2325
// See http://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform
2426
switch ((int)Environment.OSVersion.Platform)
2527
{
@@ -33,6 +35,24 @@ public static OperatingSystemType OperatingSystem
3335
default:
3436
return OperatingSystemType.Windows;
3537
}
38+
#else
39+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
40+
{
41+
return OperatingSystemType.Windows;
42+
}
43+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
44+
{
45+
return OperatingSystemType.Unix;
46+
}
47+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
48+
{
49+
return OperatingSystemType.MacOSX;
50+
}
51+
else
52+
{
53+
throw new InvalidOperationException();
54+
}
55+
#endif
3656
}
3757
}
3858
}

0 commit comments

Comments
 (0)