1414using ICSharpCode . CodeConverter . Util ;
1515using ICSharpCode . CodeConverter . VB ;
1616using McMaster . Extensions . CommandLineUtils ;
17- using Microsoft . Build . Locator ;
1817using Microsoft . CodeAnalysis ;
1918using Microsoft . CodeAnalysis . Host . Mef ;
2019using Microsoft . CodeAnalysis . MSBuild ;
@@ -30,7 +29,6 @@ public sealed class MSBuildWorkspaceConverter : IDisposable
3029 private readonly AsyncLazy < MSBuildWorkspace > _workspace ; //Cached to avoid NullRef from OptionsService when initialized concurrently (e.g. in our tests)
3130 private AsyncLazy < Solution > ? _cachedSolution ; //Cached for performance of tests
3231 private readonly bool _isNetCore ;
33- private Version ? _versionUsed ;
3432
3533 public MSBuildWorkspaceConverter ( string solutionFilePath , bool isNetCore , JoinableTaskFactory joinableTaskFactory , bool bestEffortConversion = false , Dictionary < string , string > ? buildProps = null )
3634 {
@@ -95,8 +93,7 @@ private async Task<Solution> GetSolutionAsync(string projectOrSolutionFile, IPro
9593 return solution ;
9694
9795 ValidationException CreateException ( string mainMessage , string fullDetail ) {
98- var versionUsedString = _versionUsed != null ? $ "Used MSBuild { _versionUsed } .{ Environment . NewLine } " : "" ;
99- return new ValidationException ( $ "{ mainMessage } :{ Environment . NewLine } { versionUsedString } { fullDetail } { Environment . NewLine } { mainMessage } ") ;
96+ return new ValidationException ( $ "{ mainMessage } :{ Environment . NewLine } { fullDetail } { Environment . NewLine } { mainMessage } ") ;
10097 }
10198 }
10299
@@ -120,15 +117,6 @@ private static async Task RestorePackagesForSolutionAsync(string solutionFile)
120117
121118 private async Task < MSBuildWorkspace > CreateWorkspaceAsync ( Dictionary < string , string > buildProps )
122119 {
123- if ( MSBuildLocator . CanRegister ) {
124- var instances = MSBuildLocator . QueryVisualStudioInstances ( ) . ToArray ( ) ;
125- var instance = instances . OrderByDescending ( x => x . Version ) . FirstOrDefault ( )
126- ?? throw new ValidationException ( "No Visual Studio instance available" ) ;
127- MSBuildLocator . RegisterInstance ( instance ) ;
128- _versionUsed = instance . Version ;
129- AppDomain . CurrentDomain . UseVersionAgnosticAssemblyResolution ( ) ;
130- }
131-
132120 var hostServices = await ThreadSafeWorkspaceHelper . CreateHostServicesAsync ( MSBuildMefHostServices . DefaultAssemblies ) ;
133121 return MSBuildWorkspace . Create ( buildProps , hostServices ) ;
134122 }
0 commit comments