return only major version for FreeBSD so it is consistent with rid. Fix net45 build
authorTomas Weinfurt <toweinfurt@microsoft.com>
Wed, 20 Sep 2017 22:23:31 +0000 (15:23 -0700)
committerTomas Weinfurt <toweinfurt@microsoft.com>
Wed, 20 Sep 2017 22:23:31 +0000 (15:23 -0700)
Commit migrated from https://github.com/dotnet/core-setup/commit/b8a2d3c3c81bc9a3087c425080d1270bd7c5b16a

src/installer/corehost/common/pal.unix.cpp
src/installer/managed/Microsoft.DotNet.PlatformAbstractions/Microsoft.DotNet.PlatformAbstractions.csproj
src/installer/managed/Microsoft.DotNet.PlatformAbstractions/Native/PlatformApis.cs
src/installer/managed/Microsoft.DotNet.PlatformAbstractions/RuntimeEnvironment.cs

index 6d44177..e8ca815 100644 (file)
@@ -257,7 +257,8 @@ pal::string_t pal::get_current_os_rid_platform()
     if (ret == 0)
     {
         char *pos = strchr(str,'.');
-        if (pos) {
+        if (pos)
+        {
             *pos = '\0';
         }
         ridOS.append(_X("freebsd."));
index f4c66a3..354d20b 100644 (file)
     <PackageReference Include="System.Reflection.TypeExtensions" Version="4.1.0" />
     <PackageReference Include="System.Runtime.Extensions" Version="4.1.0" />
     <PackageReference Include="System.Runtime.InteropServices" Version="4.1.0" />
+  </ItemGroup>
+  <ItemGroup>
     <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.0.0" />
   </ItemGroup>
 
+
 </Project>
index ce4bf7e..4a6bf4d 100644 (file)
@@ -74,10 +74,14 @@ namespace Microsoft.DotNet.PlatformAbstractions.Native
 
         private static string GetFreeBSDVersion()
         {
-            String verson = RuntimeInformation.OSDescription;
+            // This is same as sysctl kern.version
+            // FreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC
+            // What we want is major release as minor releases should be compatible.
+            String version = RuntimeInformation.OSDescription;
             try
             {
-                return RuntimeInformation.OSDescription.Split()[1];
+                // second token up to first dot
+                return RuntimeInformation.OSDescription.Split()[1].Split('.')[0];
             }
             catch
             {
@@ -209,6 +213,10 @@ namespace Microsoft.DotNet.PlatformAbstractions.Native
                     {
                         return Platform.Linux;
                     }
+                    if (string.Equals(uname, "FreeBSD", StringComparison.OrdinalIgnoreCase))
+                    {
+                        return Platform.FreeBSD;
+                    }
                 }
                 catch
                 {
index c9ae561..5cd6288 100644 (file)
@@ -61,7 +61,7 @@ namespace Microsoft.DotNet.PlatformAbstractions
                 case Platform.Darwin:
                     return $".{OperatingSystemVersion}";
                 case Platform.FreeBSD:
-                    return $".{OperatingSystemVersion.Split('.')[0]}";
+                    return $".{OperatingSystemVersion}";
                 default:
                     return string.Empty; // Unknown Platform? Unknown Version!
             }