Skip to content

Commit

Permalink
Clean up unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
eerhardt committed Apr 16, 2020
1 parent cf1bcc2 commit e07c170
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 301 deletions.
87 changes: 0 additions & 87 deletions src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,92 +25,6 @@ internal static class RuntimeEnvironment
public static string OperatingSystemVersion { get; } = GetOSVersion();
public static string OperatingSystem { get; } = GetOSName();

// toolset-tasks.csproj needs to build for full .NET Framework, and needs to get the current
// RuntimeIdentifier of the machine. Because of this, it needs to implement
// it's own GetRuntimeIdentifier(). All other places should use RuntimeInformation.RuntimeIdentifier.
#if TOOLSET_TASKS
private static readonly string OverrideEnvironmentVariableName = "DOTNET_RUNTIME_ID";

public static string GetRuntimeIdentifier()
{
return
Environment.GetEnvironmentVariable(OverrideEnvironmentVariableName) ??
(GetRIDOS() + GetRIDVersion() + GetRIDArch());
}

private static string GetRIDArch()
{
return $"-{RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant()}";
}

private static string GetRIDVersion()
{
// Windows RIDs do not separate OS name and version by "." due to legacy
// Others do, that's why we have the "." prefix on them below
switch (OperatingSystemPlatform)
{
case Platform.Windows:
return GetWindowsProductVersion();
case Platform.Linux:
if (string.IsNullOrEmpty(OperatingSystemVersion))
{
return string.Empty;
}

return $".{OperatingSystemVersion}";
case Platform.Darwin:
return $".{OperatingSystemVersion}";
case Platform.FreeBSD:
return $".{OperatingSystemVersion}";
default:
return string.Empty; // Unknown Platform? Unknown Version!
}
}

private static string GetWindowsProductVersion()
{
var ver = Version.Parse(OperatingSystemVersion);
if (ver.Major == 6)
{
if (ver.Minor == 1)
{
return "7";
}
else if (ver.Minor == 2)
{
return "8";
}
else if (ver.Minor == 3)
{
return "81";
}
}
else if (ver.Major >= 10)
{
// Return the major version for use in RID computation without applying any cap.
return ver.Major.ToString();
}
return string.Empty; // Unknown version
}

private static string GetRIDOS()
{
switch (OperatingSystemPlatform)
{
case Platform.Windows:
return "win";
case Platform.Linux:
return OperatingSystem.ToLowerInvariant();
case Platform.Darwin:
return "osx";
case Platform.FreeBSD:
return "freebsd";
default:
return "unknown";
}
}
#endif // TOOLSET_TASKS

private class DistroInfo
{
public string Id;
Expand Down Expand Up @@ -372,6 +286,5 @@ internal static string RtlGetVersion()
}
}
}

}
}
11 changes: 4 additions & 7 deletions src/Layout/redist/targets/GetRuntimeInformation.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
<Target Name="GetCurrentRuntimeInformation"
DependsOnTargets="GetCoreSdkGitCommitInfo"
BeforeTargets="Build">
<GetCurrentRuntimeInformation>
<Output TaskParameter="Rid" PropertyName="HostRid" />
<Output TaskParameter="OSName" PropertyName="HostOSName" />
</GetCurrentRuntimeInformation>

<PropertyGroup>
<IsLinux Condition = " '$(HostOSName)' != 'win' AND '$(HostOSName)' != 'osx' ">True</IsLinux>
<OSName Condition=" '$(OSName)' == '' AND '$(IsLinux)' != 'True' ">$(HostOSName)</OSName>
<OSName Condition=" '$(OSName)' == '' AND '$(IsLinux)' == 'True' ">linux</OSName>
<OSName Condition=" '$(OSName)' == '' AND $([MSBuild]::IsOSPlatform('WINDOWS')) ">win</OSName>
<OSName Condition=" '$(OSName)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) ">osx</OSName>
<OSName Condition=" '$(OSName)' == '' ">linux</OSName>

<Architecture Condition=" '$(Architecture)' == '' ">x64</Architecture>
<Rid Condition=" '$(Rid)' == '' ">$(OSName)-$(Architecture)</Rid>
</PropertyGroup>

</Target>
</Project>
158 changes: 0 additions & 158 deletions src/Layout/toolset-tasks/CurrentPlatform.cs

This file was deleted.

43 changes: 0 additions & 43 deletions src/Layout/toolset-tasks/GetCurrentRuntimeInformation.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/Layout/toolset-tasks/toolset-tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
<PropertyGroup>
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">$(SdkTargetFramework)</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>$(DefineConstants);TOOLSET_TASKS</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\Cli\Microsoft.DotNet.Cli.Utils\RuntimeEnvironment.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="15.7.179" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" />
Expand Down

0 comments on commit e07c170

Please sign in to comment.