11using System ;
22using System . Reflection ;
33using System . Text ;
4- using OmniSharp . Utilities ;
54
65namespace OmniSharp . MSBuild
76{
@@ -11,15 +10,21 @@ internal static class MSBuildHelpers
1110
1211 private static Type s_BuildEnvironmentHelperType ;
1312 private static Type s_BuildEnvironmentType ;
14- private static Type s_VisualStudioLocationHelperType ;
1513
1614 static MSBuildHelpers ( )
1715 {
1816 s_MicrosoftBuildAssembly = Assembly . Load ( new AssemblyName ( "Microsoft.Build" ) ) ;
1917
2018 s_BuildEnvironmentHelperType = s_MicrosoftBuildAssembly . GetType ( "Microsoft.Build.Shared.BuildEnvironmentHelper" ) ;
2119 s_BuildEnvironmentType = s_MicrosoftBuildAssembly . GetType ( "Microsoft.Build.Shared.BuildEnvironment" ) ;
22- s_VisualStudioLocationHelperType = s_MicrosoftBuildAssembly . GetType ( "Microsoft.Build.Shared.VisualStudioLocationHelper" ) ;
20+
21+ if ( s_BuildEnvironmentHelperType is null )
22+ {
23+ s_MicrosoftBuildAssembly = Assembly . Load ( new AssemblyName ( "Microsoft.Build.Framework" ) ) ;
24+
25+ s_BuildEnvironmentHelperType = s_MicrosoftBuildAssembly . GetType ( "Microsoft.Build.Shared.BuildEnvironmentHelper" ) ;
26+ s_BuildEnvironmentType = s_MicrosoftBuildAssembly . GetType ( "Microsoft.Build.Shared.BuildEnvironment" ) ;
27+ }
2328 }
2429
2530 public static string GetBuildEnvironmentInfo ( )
@@ -65,27 +70,5 @@ private static object GetPropertyValue(string name, object instance, Type type,
6570 var propInfo = type . GetProperty ( name , bindingFlags ) ;
6671 return propInfo . GetMethod . Invoke ( instance , null ) ;
6772 }
68-
69- public static bool CanInitializeVisualStudioBuildEnvironment ( )
70- {
71- if ( ! PlatformHelper . IsWindows )
72- {
73- return false ;
74- }
75-
76- // Call Microsoft.Build.Shared.BuildEnvironmentHelper.Initialze(...), which attempts to compute a build environment..
77- var initializeMethod = s_BuildEnvironmentHelperType . GetMethod ( "Initialize" , BindingFlags . NonPublic | BindingFlags . Static ) ;
78- var buildEnvironment = initializeMethod . Invoke ( null , null ) ;
79-
80- if ( buildEnvironment == null )
81- {
82- return false ;
83- }
84-
85- var mode = GetPropertyValue ( "Mode" , buildEnvironment , s_BuildEnvironmentType , BindingFlags . NonPublic | BindingFlags . Instance ) ;
86-
87- // return mode?.ToString() == "VisualStudio";
88- return false ;
89- }
9073 }
9174}
0 commit comments