3232using System . Security . Principal ;
3333using System . Windows . Forms ;
3434using BridgeVs . Locations ;
35- using BridgeVs . Logging ;
3635using Microsoft . Win32 ;
3736using OpenFileDialog = System . Windows . Forms . OpenFileDialog ;
3837
@@ -131,12 +130,8 @@ private static void SetEnvironment(string vsVersion, string vsEdition)
131130 string msBuildDir = CreateMsBuildTargetDirectory ( vsVersion , vsEdition ) ;
132131 //Copy the CustomAfter and CustomBefore to the default MSbuild v4.0 location
133132 File . Copy ( CommonFolderPaths . CustomAfterTargetFileNamePath , Path . Combine ( msBuildDir , CommonFolderPaths . CustomAfterTargetFileName ) , true ) ;
134- Log . Write ( "CustomAfterTargetFileName Targets copied to {0} " , Path . Combine ( msBuildDir , CommonFolderPaths . CustomAfterTargetFileName ) ) ;
135133
136134 File . Copy ( CommonFolderPaths . CustomBeforeTargetFileNamePath , Path . Combine ( msBuildDir , CommonFolderPaths . CustomBeforeTargetFileName ) , true ) ;
137- Log . Write ( "CustomBeforeTargetFileName Targets copied to {0} " , Path . Combine ( msBuildDir , CommonFolderPaths . CustomBeforeTargetFileName ) ) ;
138-
139- Log . Write ( "Setting IsEnvironmentConfigured to True" ) ;
140135 }
141136
142137 private static void SetInstallationFolder ( string vsVersion )
@@ -147,8 +142,10 @@ private static void SetInstallationFolder(string vsVersion)
147142 if ( key == null ) return ;
148143
149144 object value = key . GetValue ( InstallFolderPathRegistryValue ) ;
150- if ( value != null && value . Equals ( CommonFolderPaths . InstallFolder ) ) return ;
151- Log . Write ( "Setting InstallFolderPath to {0}" , CommonFolderPaths . InstallFolder ) ;
145+
146+ if ( value != null && value . Equals ( CommonFolderPaths . InstallFolder ) )
147+ return ;
148+
152149 key . SetValue ( InstallFolderPathRegistryValue , CommonFolderPaths . InstallFolder ) ;
153150 }
154151 }
@@ -176,7 +173,6 @@ private static string CreateMsBuildTargetDirectory(string vsVersion, string vsEd
176173 ? string . Format ( CommonFolderPaths . MsBuildPath2017 , vsEdition )
177174 : CommonFolderPaths . MsBuildPath , msBuildVersion ) ;
178175
179- Log . Write ( "MsBuild Directory being created {0}" , directoryToCreate ) ;
180176 if ( ! Directory . Exists ( directoryToCreate ) )
181177 {
182178 try
@@ -191,21 +187,13 @@ private static string CreateMsBuildTargetDirectory(string vsVersion, string vsEd
191187 Directory . CreateDirectory ( directoryToCreate , sec ) ;
192188 return directoryToCreate ;
193189 }
194- catch ( UnauthorizedAccessException uae )
190+ catch ( UnauthorizedAccessException )
195191 {
196- Log . Write ( uae ) ;
197192 MessageBox . Show (
198193 "It wasn't possible to complete the configuration of BridgeVs. Please restart Visual Studio as Administrator" ) ;
199194 throw ;
200195 }
201- catch ( Exception exception )
202- {
203- Log . Write ( exception ) ;
204- Log . Write ( "Error creating MSBuild Path folder in {0}" , CommonFolderPaths . MsBuildPath ) ;
205- throw ;
206- }
207196 }
208- Log . Write ( "MSBuild Path {0} already exists" , directoryToCreate ) ;
209197 return directoryToCreate ;
210198 }
211199
@@ -217,8 +205,6 @@ public static bool IsBridgeVsConfigured(string visualStudioVersion)
217205 {
218206 if ( InstalledExtensionVersion ( visualStudioVersion ) != CurrentAssemblyVersion )
219207 {
220- Log . Write ( "New LINQBridgeVs Extensions. Previous Version {0}. Current Version {1}" ,
221- InstalledExtensionVersion ( visualStudioVersion ) , CurrentAssemblyVersion ) ;
222208 return false ;
223209 }
224210
@@ -235,48 +221,35 @@ private static void SetBridgeVsAssemblyVersion(string vsVersion)
235221 }
236222 public static bool Install ( string vsVersion , string vsEdition )
237223 {
238- Log . Write ( "Configuring LINQBridgeVs Extension" ) ;
239-
240- try
224+ if ( ! IsLINQPadInstalled ( vsVersion ) ) //ask the user to insert a custom location
241225 {
242- if ( ! IsLINQPadInstalled ( vsVersion ) ) //ask the user to insert a custom location
243- {
244- return false ;
245- }
246-
247- ObsoleteXmlConfiguration . RemoveOldTargets ( ) ;
248-
249- SetBridgeVsAssemblyVersion ( vsVersion ) ;
226+ return false ;
227+ }
250228
251- CreateLinqPadQueryFolder ( ) ;
229+ ObsoleteXmlConfiguration . RemoveOldTargets ( ) ;
252230
253- CreateLinqPadPluginFolder ( ) ;
231+ SetBridgeVsAssemblyVersion ( vsVersion ) ;
232+
233+ CreateLinqPadQueryFolder ( ) ;
254234
255- CreateVisualizerFolder ( vsVersion ) ;
235+ CreateLinqPadPluginFolder ( ) ;
256236
257- CreateGrappleFolder ( ) ;
237+ CreateVisualizerFolder ( vsVersion ) ;
258238
259- //Always check if installation folder has changed
260- SetInstallationFolder ( vsVersion ) ;
239+ CreateGrappleFolder ( ) ;
261240
262- Log . Write ( "Setting the Environment" ) ;
241+ //Always check if installation folder has changed
242+ SetInstallationFolder ( vsVersion ) ;
263243
264- SetEnvironment ( vsVersion , vsEdition ) ;
244+ SetEnvironment ( vsVersion , vsEdition ) ;
265245
266- DeleteExistingVisualizers ( vsVersion ) ;
246+ DeleteExistingVisualizers ( vsVersion ) ;
267247
268- DeployDependencies ( vsVersion ) ;
248+ DeployDependencies ( vsVersion ) ;
269249
270- CommonRegistryConfigurations . SetErrorTracking ( vsVersion , true ) ;
250+ CommonRegistryConfigurations . SetErrorTracking ( vsVersion , true ) ;
271251
272- return true ;
273- }
274- catch ( Exception e )
275- {
276- const string context = "Error Configuring LINQBridgeVs" ;
277- Log . Write ( e , context ) ;
278- return false ;
279- }
252+ return true ;
280253 }
281254
282255 public static void DeployDependencies ( string vsVersion )
@@ -286,7 +259,7 @@ public static void DeployDependencies(string vsVersion)
286259 throw new Exception ( "Dll location is null" ) ;
287260
288261 string debuggerVisualizerTargetFolder = DebuggerVisualizerTargetFolder ( vsVersion ) ;
289- string linqPadPluginFolder = CommonFolderPaths . LinqPadPluginFolder ;
262+ string linqPadPluginFolder = CommonFolderPaths . DefaultLinqPadPluginFolder ;
290263 foreach ( string dependency in Dependencies )
291264 {
292265 string sourceFile = Path . Combine ( currentLocation , dependency ) ;
@@ -338,22 +311,22 @@ private static string DebuggerVisualizerTargetFolder(string vsVersion)
338311
339312 private static void CreateLinqPadQueryFolder ( )
340313 {
341- string dstScriptPath = CommonFolderPaths . LinqPadQueryFolder ;
314+ //check first where LINQPad is installed
315+ string dstScriptPath = CommonFolderPaths . DefaultLinqPadQueryFolder ;
342316
343- if ( Directory . Exists ( dstScriptPath ) ) return ;
317+ if ( Directory . Exists ( dstScriptPath ) )
318+ return ;
344319
345320 DirectorySecurity sec = new DirectorySecurity ( ) ;
346321 // Using this instead of the "Everyone" string means we work on non-English systems.
347322 SecurityIdentifier everyone = new SecurityIdentifier ( WellKnownSidType . WorldSid , null ) ;
348323 sec . AddAccessRule ( new FileSystemAccessRule ( everyone , FileSystemRights . Modify | FileSystemRights . Synchronize , InheritanceFlags . ContainerInherit | InheritanceFlags . ObjectInherit , PropagationFlags . None , AccessControlType . Allow ) ) ;
349324 Directory . CreateDirectory ( dstScriptPath , sec ) ;
350-
351- Log . Write ( $ "Directory Created: { dstScriptPath } ") ;
352325 }
353326
354327 private static void CreateLinqPadPluginFolder ( )
355328 {
356- string dstScriptPath = CommonFolderPaths . LinqPadPluginFolder ;
329+ string dstScriptPath = CommonFolderPaths . DefaultLinqPadPluginFolder ;
357330
358331 if ( Directory . Exists ( dstScriptPath ) ) return ;
359332
@@ -362,8 +335,6 @@ private static void CreateLinqPadPluginFolder()
362335 SecurityIdentifier everyone = new SecurityIdentifier ( WellKnownSidType . WorldSid , null ) ;
363336 sec . AddAccessRule ( new FileSystemAccessRule ( everyone , FileSystemRights . Modify | FileSystemRights . Synchronize , InheritanceFlags . ContainerInherit | InheritanceFlags . ObjectInherit , PropagationFlags . None , AccessControlType . Allow ) ) ;
364337 Directory . CreateDirectory ( dstScriptPath , sec ) ;
365-
366- Log . Write ( $ "Directory Created: { dstScriptPath } ") ;
367338 }
368339
369340 private static void CreateVisualizerFolder ( string vsVersion )
@@ -376,21 +347,14 @@ private static void CreateVisualizerFolder(string vsVersion)
376347 SecurityIdentifier everyone = new SecurityIdentifier ( WellKnownSidType . WorldSid , null ) ;
377348 sec . AddAccessRule ( new FileSystemAccessRule ( everyone , FileSystemRights . Modify | FileSystemRights . Synchronize , InheritanceFlags . ContainerInherit | InheritanceFlags . ObjectInherit , PropagationFlags . None , AccessControlType . Allow ) ) ;
378349 Directory . CreateDirectory ( debuggerVisualizerTargetFolder , sec ) ;
379-
380- Log . Write ( $ "Directory Created: { debuggerVisualizerTargetFolder } ") ;
381-
382350 }
383351
384352 private static void CreateGrappleFolder ( )
385353 {
386- Log . Write ( "Creating folder for Delivery {0}" , Path . GetFullPath ( CommonFolderPaths . GrappleFolder ) ) ;
387-
388354 if ( Directory . Exists ( CommonFolderPaths . GrappleFolder ) ) return ;
389355
390356 //no need for security access
391357 Directory . CreateDirectory ( CommonFolderPaths . GrappleFolder ) ;
392-
393- Log . Write ( "Folder Successfully Created" ) ;
394358 }
395359 #endregion
396360 }
0 commit comments