diff --git a/src/Compilers/Core/MSBuildTask/ManagedToolTask.cs b/src/Compilers/Core/MSBuildTask/ManagedToolTask.cs
index 141b1bf4339eac9090675d116601e23dc9b73e2b..24cecfc222abd8cff26b1bd9e96911d8ef96a4a6 100644
--- a/src/Compilers/Core/MSBuildTask/ManagedToolTask.cs
+++ b/src/Compilers/Core/MSBuildTask/ManagedToolTask.cs
@@ -80,21 +80,28 @@ protected sealed override string GenerateFullPathToTool()
/// as the implementation of IsManagedTool calls this property. See the comment in
/// .
///
- protected sealed override string ToolName
- => $"{ToolNameWithoutExtension}.{(CoreClrShim.IsRunningOnCoreClr ? "dll" : "exe")}";
+ protected sealed override string ToolName => $"{ToolNameWithoutExtension}.{ToolExtension}";
+
+ private static string ToolExtension =>
+#if NETCOREAPP2_1
+ "dll";
+#elif NET472
+ "exe";
+#else
+#error Unrecognized framework
+#endif
private static bool IsCliHost(out string pathToDotnet)
{
- if (CoreClrShim.IsRunningOnCoreClr)
- {
- pathToDotnet = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH");
- return !string.IsNullOrEmpty(pathToDotnet);
- }
- else
- {
- pathToDotnet = null;
- return false;
- }
+#if NETCOREAPP2_1
+ pathToDotnet = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH");
+ return !string.IsNullOrEmpty(pathToDotnet);
+#elif NET472
+ pathToDotnet = null;
+ return false;
+#else
+#error Unrecognized framework
+#endif
}
private static string PrependFileToArgs(string pathToTool, string commandLineArgs)
diff --git a/src/Compilers/Shared/BuildServerConnection.cs b/src/Compilers/Shared/BuildServerConnection.cs
index b419ab196352baee2e1665d1f6b62c4d36dcd0b4..097c7b3f196ea33cf72a828ff47de972323aa627 100644
--- a/src/Compilers/Shared/BuildServerConnection.cs
+++ b/src/Compilers/Shared/BuildServerConnection.cs
@@ -374,32 +374,30 @@ internal static bool IsCompilerServerSupported(string tempPath)
internal static bool TryCreateServerCore(string clientDir, string pipeName)
{
- bool isRunningOnCoreClr = CoreClrShim.IsRunningOnCoreClr;
string expectedPath;
string processArguments;
- if (isRunningOnCoreClr)
- {
- // The server should be in the same directory as the client
- var expectedCompilerPath = Path.Combine(clientDir, ServerNameCoreClr);
- expectedPath = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet";
- processArguments = $@"""{expectedCompilerPath}"" ""-pipename:{pipeName}""";
+#if NETCOREAPP2_1
+ // The server should be in the same directory as the client
+ var expectedCompilerPath = Path.Combine(clientDir, ServerNameCoreClr);
+ expectedPath = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet";
+ processArguments = $@"""{expectedCompilerPath}"" ""-pipename:{pipeName}""";
- if (!File.Exists(expectedCompilerPath))
- {
- return false;
- }
- }
- else
+ if (!File.Exists(expectedCompilerPath))
{
- // The server should be in the same directory as the client
- expectedPath = Path.Combine(clientDir, ServerNameDesktop);
- processArguments = $@"""-pipename:{pipeName}""";
+ return false;
+ }
+#elif NET472
+ // The server should be in the same directory as the client
+ expectedPath = Path.Combine(clientDir, ServerNameDesktop);
+ processArguments = $@"""-pipename:{pipeName}""";
- if (!File.Exists(expectedPath))
- {
- return false;
- }
+ if (!File.Exists(expectedPath))
+ {
+ return false;
}
+#else
+#error Unrecognized configuration
+#endif
if (PlatformInformation.IsWindows)
{
diff --git a/src/Test/Utilities/Portable/Compilation/RuntimeUtilities.cs b/src/Test/Utilities/Portable/Compilation/RuntimeUtilities.cs
index 795d2e2710a76ec1386dbdacfad8a6ab5273255b..9f19ccc04513d6ee976320a312ce46021ad925cb 100644
--- a/src/Test/Utilities/Portable/Compilation/RuntimeUtilities.cs
+++ b/src/Test/Utilities/Portable/Compilation/RuntimeUtilities.cs
@@ -15,6 +15,18 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
///
public static partial class RuntimeUtilities
{
+ internal static bool IsDesktopRuntime =>
+#if NET472
+ true;
+#elif NETCOREAPP2_1
+ false;
+#elif NETSTANDARD2_0
+ throw new PlatformNotSupportedException();
+#else
+#error Unsupported configuration
+#endif
+ internal static bool IsCoreClrRuntime => !IsDesktopRuntime;
+
internal static BuildPaths CreateBuildPaths(string workingDirectory, string sdkDirectory = null, string tempDirectory = null)
{
tempDirectory = tempDirectory ?? Path.GetTempPath();
diff --git a/src/Test/Utilities/Portable/TargetFrameworkUtil.cs b/src/Test/Utilities/Portable/TargetFrameworkUtil.cs
index ba59baf693110fb1b3aa0e7988d04fc18127c6ad..2f782beb49b8ac81228d234d245440f3977bcff3 100644
--- a/src/Test/Utilities/Portable/TargetFrameworkUtil.cs
+++ b/src/Test/Utilities/Portable/TargetFrameworkUtil.cs
@@ -5,6 +5,7 @@
using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Test.Utilities;
using static TestReferences;
namespace Roslyn.Test.Utilities
@@ -55,7 +56,7 @@ public enum TargetFramework
public static class TargetFrameworkUtil
{
- public static MetadataReference StandardCSharpReference => CoreClrShim.IsRunningOnCoreClr ? NetStandard20.MicrosoftCSharpRef : TestBase.CSharpDesktopRef;
+ public static MetadataReference StandardCSharpReference => RuntimeUtilities.IsCoreClrRuntime ? NetStandard20.MicrosoftCSharpRef : TestBase.CSharpDesktopRef;
/*
* ⚠ Dev note ⚠: properties in TestBase are backed by Lazy. Avoid changes to the following properties
@@ -78,10 +79,10 @@ public static class TargetFrameworkUtil
public static ImmutableArray Mscorlib461ExtendedReferences => ImmutableArray.Create(Net461.mscorlibRef, Net461.SystemRef, Net461.SystemCoreRef, Net461.SystemValueTupleRef, Net461.SystemRuntimeRef);
public static ImmutableArray NetStandard20References => ImmutableArray.Create(NetStandard20.NetStandard, NetStandard20.MscorlibRef, NetStandard20.SystemRuntimeRef, NetStandard20.SystemCoreRef, NetStandard20.SystemDynamicRuntimeRef);
public static ImmutableArray WinRTReferences => ImmutableArray.Create(TestBase.WinRtRefs);
- public static ImmutableArray StandardReferences => CoreClrShim.IsRunningOnCoreClr ? NetStandard20References : Mscorlib46ExtendedReferences;
+ public static ImmutableArray StandardReferences => RuntimeUtilities.IsCoreClrRuntime ? NetStandard20References : Mscorlib46ExtendedReferences;
public static ImmutableArray StandardAndCSharpReferences => StandardReferences.Add(StandardCSharpReference);
- public static ImmutableArray StandardAndVBRuntimeReferences => CoreClrShim.IsRunningOnCoreClr ? NetStandard20References.Add(NetStandard20.MicrosoftVisualBasicRef) : Mscorlib46ExtendedReferences.Add(TestBase.MsvbRef_v4_0_30319_17929);
- public static ImmutableArray StandardCompatReferences => CoreClrShim.IsRunningOnCoreClr ? NetStandard20References : Mscorlib40References;
+ public static ImmutableArray StandardAndVBRuntimeReferences => RuntimeUtilities.IsCoreClrRuntime ? NetStandard20References.Add(NetStandard20.MicrosoftVisualBasicRef) : Mscorlib46ExtendedReferences.Add(TestBase.MsvbRef_v4_0_30319_17929);
+ public static ImmutableArray StandardCompatReferences => RuntimeUtilities.IsCoreClrRuntime ? NetStandard20References : Mscorlib40References;
public static ImmutableArray DefaultVbReferencs => ImmutableArray.Create(TestBase.MscorlibRef, TestBase.SystemRef, TestBase.SystemCoreRef, TestBase.MsvbRef);
public static ImmutableArray GetReferences(TargetFramework tf)
diff --git a/src/Test/Utilities/Portable/TestBase.cs b/src/Test/Utilities/Portable/TestBase.cs
index 1458073a53c03b131c47590f4497ebfe5216898d..943f91eb9d577c4917ba174ef545687a651ba887 100644
--- a/src/Test/Utilities/Portable/TestBase.cs
+++ b/src/Test/Utilities/Portable/TestBase.cs
@@ -76,7 +76,7 @@ private static MetadataReference GetOrCreateMetadataReference(ref MetadataRefere
LazyThreadSafetyMode.PublicationOnly);
public static MetadataReference[] LatestVbReferences => s_lazyLatestVbReferences.Value;
- public static readonly AssemblyName RuntimeCorLibName = CoreClrShim.IsRunningOnCoreClr
+ public static readonly AssemblyName RuntimeCorLibName = RuntimeUtilities.IsCoreClrRuntime
? new AssemblyName("netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")
: new AssemblyName("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");