Skip to content

Commit e07c170

Browse files
committed
Clean up unused code
1 parent cf1bcc2 commit e07c170

File tree

5 files changed

+4
-301
lines changed

5 files changed

+4
-301
lines changed

src/Cli/Microsoft.DotNet.Cli.Utils/RuntimeEnvironment.cs

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -25,92 +25,6 @@ internal static class RuntimeEnvironment
2525
public static string OperatingSystemVersion { get; } = GetOSVersion();
2626
public static string OperatingSystem { get; } = GetOSName();
2727

28-
// toolset-tasks.csproj needs to build for full .NET Framework, and needs to get the current
29-
// RuntimeIdentifier of the machine. Because of this, it needs to implement
30-
// it's own GetRuntimeIdentifier(). All other places should use RuntimeInformation.RuntimeIdentifier.
31-
#if TOOLSET_TASKS
32-
private static readonly string OverrideEnvironmentVariableName = "DOTNET_RUNTIME_ID";
33-
34-
public static string GetRuntimeIdentifier()
35-
{
36-
return
37-
Environment.GetEnvironmentVariable(OverrideEnvironmentVariableName) ??
38-
(GetRIDOS() + GetRIDVersion() + GetRIDArch());
39-
}
40-
41-
private static string GetRIDArch()
42-
{
43-
return $"-{RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant()}";
44-
}
45-
46-
private static string GetRIDVersion()
47-
{
48-
// Windows RIDs do not separate OS name and version by "." due to legacy
49-
// Others do, that's why we have the "." prefix on them below
50-
switch (OperatingSystemPlatform)
51-
{
52-
case Platform.Windows:
53-
return GetWindowsProductVersion();
54-
case Platform.Linux:
55-
if (string.IsNullOrEmpty(OperatingSystemVersion))
56-
{
57-
return string.Empty;
58-
}
59-
60-
return $".{OperatingSystemVersion}";
61-
case Platform.Darwin:
62-
return $".{OperatingSystemVersion}";
63-
case Platform.FreeBSD:
64-
return $".{OperatingSystemVersion}";
65-
default:
66-
return string.Empty; // Unknown Platform? Unknown Version!
67-
}
68-
}
69-
70-
private static string GetWindowsProductVersion()
71-
{
72-
var ver = Version.Parse(OperatingSystemVersion);
73-
if (ver.Major == 6)
74-
{
75-
if (ver.Minor == 1)
76-
{
77-
return "7";
78-
}
79-
else if (ver.Minor == 2)
80-
{
81-
return "8";
82-
}
83-
else if (ver.Minor == 3)
84-
{
85-
return "81";
86-
}
87-
}
88-
else if (ver.Major >= 10)
89-
{
90-
// Return the major version for use in RID computation without applying any cap.
91-
return ver.Major.ToString();
92-
}
93-
return string.Empty; // Unknown version
94-
}
95-
96-
private static string GetRIDOS()
97-
{
98-
switch (OperatingSystemPlatform)
99-
{
100-
case Platform.Windows:
101-
return "win";
102-
case Platform.Linux:
103-
return OperatingSystem.ToLowerInvariant();
104-
case Platform.Darwin:
105-
return "osx";
106-
case Platform.FreeBSD:
107-
return "freebsd";
108-
default:
109-
return "unknown";
110-
}
111-
}
112-
#endif // TOOLSET_TASKS
113-
11428
private class DistroInfo
11529
{
11630
public string Id;
@@ -372,6 +286,5 @@ internal static string RtlGetVersion()
372286
}
373287
}
374288
}
375-
376289
}
377290
}

src/Layout/redist/targets/GetRuntimeInformation.targets

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
<Target Name="GetCurrentRuntimeInformation"
33
DependsOnTargets="GetCoreSdkGitCommitInfo"
44
BeforeTargets="Build">
5-
<GetCurrentRuntimeInformation>
6-
<Output TaskParameter="Rid" PropertyName="HostRid" />
7-
<Output TaskParameter="OSName" PropertyName="HostOSName" />
8-
</GetCurrentRuntimeInformation>
95

106
<PropertyGroup>
11-
<IsLinux Condition = " '$(HostOSName)' != 'win' AND '$(HostOSName)' != 'osx' ">True</IsLinux>
12-
<OSName Condition=" '$(OSName)' == '' AND '$(IsLinux)' != 'True' ">$(HostOSName)</OSName>
13-
<OSName Condition=" '$(OSName)' == '' AND '$(IsLinux)' == 'True' ">linux</OSName>
7+
<OSName Condition=" '$(OSName)' == '' AND $([MSBuild]::IsOSPlatform('WINDOWS')) ">win</OSName>
8+
<OSName Condition=" '$(OSName)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) ">osx</OSName>
9+
<OSName Condition=" '$(OSName)' == '' ">linux</OSName>
1410

1511
<Architecture Condition=" '$(Architecture)' == '' ">x64</Architecture>
1612
<Rid Condition=" '$(Rid)' == '' ">$(OSName)-$(Architecture)</Rid>
1713
</PropertyGroup>
14+
1815
</Target>
1916
</Project>

src/Layout/toolset-tasks/CurrentPlatform.cs

Lines changed: 0 additions & 158 deletions
This file was deleted.

src/Layout/toolset-tasks/GetCurrentRuntimeInformation.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/Layout/toolset-tasks/toolset-tasks.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22
<PropertyGroup>
33
<TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
44
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">$(SdkTargetFramework)</TargetFrameworks>
5-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6-
<DefineConstants>$(DefineConstants);TOOLSET_TASKS</DefineConstants>
75
</PropertyGroup>
86

9-
<ItemGroup>
10-
<Compile Include="..\..\Cli\Microsoft.DotNet.Cli.Utils\RuntimeEnvironment.cs" />
11-
</ItemGroup>
12-
137
<ItemGroup>
148
<PackageReference Include="Microsoft.Build" Version="15.7.179" />
159
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" />

0 commit comments

Comments
 (0)