@@ -84,24 +84,24 @@ public void ActivityLogWarning(string message)
8484 /// </remarks>
8585 /// <param name="repoPath">The path to the repository to open</param>
8686 /// <returns>True if a transient solution was successfully created in target directory (which should trigger opening of repository).</returns>
87- public bool TryOpenRepository ( string repoPath )
87+ public bool TryOpenRepository ( string repoPath , bool logErrors = true )
8888 {
8989 var os = serviceProvider . TryGetService < IOperatingSystem > ( ) ;
9090 if ( os == null )
9191 {
92- log . Error ( "TryOpenRepository couldn't find IOperatingSystem service" ) ;
92+ if ( logErrors ) log . Error ( "TryOpenRepository couldn't find IOperatingSystem service" ) ;
9393 return false ;
9494 }
9595
9696 var dte = serviceProvider . TryGetService < DTE > ( ) ;
9797 if ( dte == null )
9898 {
99- log . Error ( "TryOpenRepository couldn't find DTE service" ) ;
99+ if ( logErrors ) log . Error ( "TryOpenRepository couldn't find DTE service" ) ;
100100 return false ;
101101 }
102102
103103 var repoDir = os . Directory . GetDirectory ( repoPath ) ;
104- if ( ! repoDir . Exists )
104+ if ( ! repoDir . Exists )
105105 {
106106 return false ;
107107 }
@@ -116,16 +116,16 @@ public bool TryOpenRepository(string repoPath)
116116 }
117117 catch ( Exception e )
118118 {
119- log . Error ( e , "Error opening repository" ) ;
119+ if ( logErrors ) log . Error ( e , "Error opening repository" ) ;
120120 }
121121 finally
122122 {
123- TryCleanupSolutionUserFiles ( os , repoPath , TempSolutionName ) ;
123+ TryCleanupSolutionUserFiles ( os , repoPath , TempSolutionName , logErrors ) ;
124124 }
125125 return solutionCreated ;
126126 }
127127
128- void TryCleanupSolutionUserFiles ( IOperatingSystem os , string repoPath , string slnName )
128+ void TryCleanupSolutionUserFiles ( IOperatingSystem os , string repoPath , string slnName , bool logErrors )
129129 {
130130 var vsTempPath = Path . Combine ( repoPath , ".vs" , slnName ) ;
131131 try
@@ -139,7 +139,7 @@ void TryCleanupSolutionUserFiles(IOperatingSystem os, string repoPath, string sl
139139 }
140140 catch ( Exception e )
141141 {
142- log . Error ( e , "Couldn't clean up {TempPath}" , vsTempPath ) ;
142+ if ( logErrors ) log . Error ( e , "Couldn't clean up {TempPath}" , vsTempPath ) ;
143143 }
144144 }
145145
@@ -162,7 +162,7 @@ string GetVSVersion()
162162 if ( asm != null )
163163 return asm . GetName ( ) . Version . ToString ( ) ;
164164 }
165- catch ( Exception ex )
165+ catch ( Exception ex )
166166 {
167167 log . Error ( ex , "Error getting the Visual Studio version" ) ;
168168 }
0 commit comments