From b3151c8275c252f071926638b212b2d7cd59b8a3 Mon Sep 17 00:00:00 2001 From: deepak-rathi <5453503+deepak-rathi@users.noreply.github.com> Date: Tue, 26 Jul 2022 20:03:42 +0530 Subject: [PATCH] Added option new Cleanup command which delete old version files and folder using CLI --clean parameter. Upgraded Newtonsoft.Json version --- Setup/Product.Core.wxs | 2 +- .../Utils/FeatureUtil.cs | 4 +- .../VS2017OfflineSetupUtility.Core.csproj | 2 +- .../VS2017OfflineSetupUtility.csproj | 2 +- .../ViewModels/CleanUtilPageViewModel.cs | 50 +++++++++++++++++++ .../Views/CleanUtilPage.xaml | 11 ++-- .../Views/DownloadUtilPage.xaml | 4 +- 7 files changed, 64 insertions(+), 11 deletions(-) diff --git a/Setup/Product.Core.wxs b/Setup/Product.Core.wxs index 7fc667a..6879237 100644 --- a/Setup/Product.Core.wxs +++ b/Setup/Product.Core.wxs @@ -21,7 +21,7 @@ - + diff --git a/VS2017OfflineSetupUtility/Utils/FeatureUtil.cs b/VS2017OfflineSetupUtility/Utils/FeatureUtil.cs index 006ae2b..d7aef9e 100644 --- a/VS2017OfflineSetupUtility/Utils/FeatureUtil.cs +++ b/VS2017OfflineSetupUtility/Utils/FeatureUtil.cs @@ -30,7 +30,7 @@ internal static List GetFeatures() var cleanUtilIcon = new CleanUtilIcon() { IsCheckedColor = (SolidColorBrush)App.Current.Resources["BlueSolidColorBrush"]}; cleanUtilIcon.SetBinding(CleanUtilIcon.IsCheckedProperty, new System.Windows.Data.Binding("IsSelected") { UpdateSourceTrigger = System.Windows.Data.UpdateSourceTrigger.PropertyChanged}); - var cleanUtilFeature = new Feature() { Icon = cleanUtilIcon, Name = "VS2017/2019/2022 Offline Clean Util", About= "Allow deletion of old version Visual Studio 2017/2019/2022 Offline Setup files and folder, which saves your hard disk space.", Version="1.4.1.0", NavigateToView = new Views.CleanUtilPage() , IsSelected = true}; + var cleanUtilFeature = new Feature() { Icon = cleanUtilIcon, Name = "VS2017/2019/2022 Offline Clean Util", About= "Allow deletion of old version Visual Studio 2017/2019/2022 Offline Setup files and folder, which saves your hard disk space.", Version="1.4.2.0", NavigateToView = new Views.CleanUtilPage() , IsSelected = true}; #endregion @@ -38,7 +38,7 @@ internal static List GetFeatures() var downloadUtilIcon = new DownloadUtilIcon() { IsCheckedColor = (SolidColorBrush)App.Current.Resources["BlueSolidColorBrush"]}; downloadUtilIcon.SetBinding(DownloadUtilIcon.IsCheckedProperty, new System.Windows.Data.Binding("IsSelected") { UpdateSourceTrigger = System.Windows.Data.UpdateSourceTrigger.PropertyChanged }); - var downloadUtilFeature = new Feature() { Icon = downloadUtilIcon, Name = "VS2017/2019/2022 Offline Download", About = "Download Visual Studio 2017/2019/2022 Offline Setup files and folder, using command line interface. (Need internet connection)", Version = "1.4.1.0" , NavigateToView = new Views.DownloadUtilPage()}; + var downloadUtilFeature = new Feature() { Icon = downloadUtilIcon, Name = "VS2017/2019/2022 Offline Download", About = "Download Visual Studio 2017/2019/2022 Offline Setup files and folder, using command line interface. (Need internet connection)", Version = "1.4.2.0" , NavigateToView = new Views.DownloadUtilPage()}; #endregion diff --git a/VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.Core.csproj b/VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.Core.csproj index fcc2637..3e0baff 100644 --- a/VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.Core.csproj +++ b/VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.Core.csproj @@ -6,7 +6,7 @@ true true VS2017OfflineSetupUtility.App - 1.4.1 + 1.4.2 VS2017 Offline Setup Utility diff --git a/VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.csproj b/VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.csproj index 85abdd0..0e632d5 100644 --- a/VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.csproj +++ b/VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.csproj @@ -158,7 +158,7 @@ - 12.0.3 + 13.0.1 diff --git a/VS2017OfflineSetupUtility/ViewModels/CleanUtilPageViewModel.cs b/VS2017OfflineSetupUtility/ViewModels/CleanUtilPageViewModel.cs index 13c5579..be72d64 100644 --- a/VS2017OfflineSetupUtility/ViewModels/CleanUtilPageViewModel.cs +++ b/VS2017OfflineSetupUtility/ViewModels/CleanUtilPageViewModel.cs @@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License */ using System; using System.Collections.ObjectModel; +using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -68,6 +69,7 @@ public string SelectedFolderPath if (SetProperty(ref _selectedFolderPath, value)) { DeleteOldVersionCommand.RaiseCanExecuteChanged(); + DeleteOldVersionCleanCommand.RaiseCanExecuteChanged(); } } } @@ -221,6 +223,54 @@ await Task.Run(() => #endregion + #region DeleteOldVersionCleanCommand + private DelegateCommand _deleteOldVersionCleanCommand; + + public DelegateCommand DeleteOldVersionCleanCommand + { + get + { + return _deleteOldVersionCleanCommand ?? (_deleteOldVersionCleanCommand = new DelegateCommand(async () => + { + try + { + if (string.IsNullOrWhiteSpace(SelectedFolderPath)) + return; + + ModuleCollection.Clear(); + OldVersionModule.Clear(); + + DirectoryInfo dirInfo = new DirectoryInfo(SelectedFolderPath); + if (dirInfo != null && !dirInfo.Exists) + { + SelectedFolderPath = ""; + return; + } + //Delete old version folder and files using --clean + try + { + File.WriteAllText(dirInfo.FullName + @"\CleanupCommand.bat", string.Format("vs_setup.exe --layout {0} --clean {1}\\Catalog.json", dirInfo.FullName, dirInfo.FullName)); + Process.Start(new ProcessStartInfo() + { + FileName = dirInfo.FullName + @"\CleanupCommand.bat", + WorkingDirectory = dirInfo.FullName + }); + } + catch (Exception exception) + { + MessageBox.Show("Error occured:" + exception.GetType().ToString(), "", MessageBoxButton.OK, MessageBoxImage.Error); + } + } + catch (Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception.Message); + } + }, () => !string.IsNullOrWhiteSpace(SelectedFolderPath))); + } + } + + #endregion + #region GoBack Command private DelegateCommand _goBackCommand; diff --git a/VS2017OfflineSetupUtility/Views/CleanUtilPage.xaml b/VS2017OfflineSetupUtility/Views/CleanUtilPage.xaml index 3f8b094..dceadb9 100644 --- a/VS2017OfflineSetupUtility/Views/CleanUtilPage.xaml +++ b/VS2017OfflineSetupUtility/Views/CleanUtilPage.xaml @@ -53,14 +53,17 @@ + - -