Skip to content

Commit

Permalink
Added option new Cleanup command which delete old version files and f…
Browse files Browse the repository at this point in the history
…older using CLI --clean parameter.

Upgraded Newtonsoft.Json version
  • Loading branch information
deepak-rathi committed Jul 26, 2022
1 parent 65afd72 commit b3151c8
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Setup/Product.Core.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- The manufacturer, for setup package publisher and folder info -->
<?define Manufacturer = "Deepak Rathi" ?>
<!-- The version number of this setup package-->
<?define Version = "1.4.1" ?>
<?define Version = "1.4.2" ?>
<!-- UpgradeCode must be unique and not changed once the first version of the program is installed. -->
<?define UpgradeCode = "a49a94d4-f09a-4e3b-9b7e-b058cddd504e" ?>
<!-- The name of the Cabinet -->
Expand Down
4 changes: 2 additions & 2 deletions VS2017OfflineSetupUtility/Utils/FeatureUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ internal static List<Feature> 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

#region Download Util Feature
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<StartupObject>VS2017OfflineSetupUtility.App</StartupObject>
<Version>1.4.1</Version>
<Version>1.4.2</Version>
<Product>VS2017 Offline Setup Utility</Product>
<PackageLicenseExpression></PackageLicenseExpression>
<Company />
Expand Down
2 changes: 1 addition & 1 deletion VS2017OfflineSetupUtility/VS2017OfflineSetupUtility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
<Version>13.0.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
50 changes: 50 additions & 0 deletions VS2017OfflineSetupUtility/ViewModels/CleanUtilPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -68,6 +69,7 @@ public string SelectedFolderPath
if (SetProperty(ref _selectedFolderPath, value))
{
DeleteOldVersionCommand.RaiseCanExecuteChanged();
DeleteOldVersionCleanCommand.RaiseCanExecuteChanged();
}
}
}
Expand Down Expand Up @@ -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;

Expand Down
11 changes: 7 additions & 4 deletions VS2017OfflineSetupUtility/Views/CleanUtilPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBlock Text="(C) 2017-2021 Deepak Rathi. THIS APPLICATION IS PROVIDED AS IS WITH OUT ANY WARRANTY OF ANY KIND. DEVELOPER OF THIS APP IS NOT RESPONSIBLE FOR ANY PROBLEM/ISSUE/DEFECTS CAUSED DUE TO THIS APPLICATION OR ANY CONTENT IN THIS APPLICATION. THIS APP IS NOT AFFILIATED TO MICROSOFT OR ANY OTHER THIRD PARTY. NO USER DATA IS COLLECTED BY DEVELOPER OF THIS APP."
<TextBlock Text="(C) 2017-2022 Deepak Rathi. THIS APPLICATION IS PROVIDED AS IS WITH OUT ANY WARRANTY OF ANY KIND. DEVELOPER OF THIS APP IS NOT RESPONSIBLE FOR ANY PROBLEM/ISSUE/DEFECTS CAUSED DUE TO THIS APPLICATION OR ANY CONTENT IN THIS APPLICATION. THIS APP IS NOT AFFILIATED TO MICROSOFT OR ANY OTHER THIRD PARTY. NO USER DATA IS COLLECTED BY DEVELOPER OF THIS APP."
Padding="20" TextWrapping="Wrap" Foreground="Gray"
Grid.Column="0"/>
<Button Content="Delete" Grid.Column="1" Width="80" Height="30" Background="{StaticResource RedSolidColorBrush}" Margin="10" Foreground="White"
<Button Content="Delete using --clean command" Grid.Column="1" Width="180" Height="30" Background="{StaticResource RedSolidColorBrush}" Margin="10" Foreground="White"
Command="{Binding DeleteOldVersionCleanCommand}"/>
<Button Content="Delete" Grid.Column="2" Width="80" Height="30" Background="{StaticResource RedSolidColorBrush}" Margin="10" Foreground="White"
Command="{Binding DeleteOldVersionCommand}"/>
<Button Content="Go Back" Grid.Column="2" Width="80" Height="30" Background="White" Margin="10"
<Button Content="Go Back" Grid.Column="3" Width="80" Height="30" Background="White" Margin="10"
Command="{Binding GoBackCommand}"/>
</Grid>
<!--#endregion Footer-->
Expand Down Expand Up @@ -125,7 +128,7 @@
<TextBlock Text="About" Style="{StaticResource SubHeaderTextBlockStyle}" Padding="14,20,14,5"/>
<TextBlock Text="Allow deletion of old version Visual Studio 2017/2019/2022 Offline Setup files and folder, which saves your hard disk space." Style="{StaticResource BodyTextBlockStyle}" Padding="14,0"/>
<TextBlock Text="Version" Style="{StaticResource SubHeaderTextBlockStyle}" Padding="14,20,14,5"/>
<TextBlock Text="1.4.1.0" Style="{StaticResource BodyTextBlockStyle}" Padding="14,0"/>
<TextBlock Text="1.4.2.0" Style="{StaticResource BodyTextBlockStyle}" Padding="14,0"/>
</StackPanel>
<!--#endregion Right Content-->
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions VS2017OfflineSetupUtility/Views/DownloadUtilPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBlock Text="(C) 2017-2021 Deepak Rathi. THIS APPLICATION IS PROVIDED AS IS WITH OUT ANY WARRANTY OF ANY KIND. DEVELOPER OF THIS APP IS NOT RESPONSIBLE FOR ANY PROBLEM/ISSUE/DEFECTS CAUSED DUE TO THIS APPLICATION OR ANY CONTENT IN THIS APPLICATION. THIS APP IS NOT AFFILIATED TO MICROSOFT OR ANY OTHER THIRD PARTY. NO USER DATA IS COLLECTED BY DEVELOPER OF THIS APP."
<TextBlock Text="(C) 2017-2022 Deepak Rathi. THIS APPLICATION IS PROVIDED AS IS WITH OUT ANY WARRANTY OF ANY KIND. DEVELOPER OF THIS APP IS NOT RESPONSIBLE FOR ANY PROBLEM/ISSUE/DEFECTS CAUSED DUE TO THIS APPLICATION OR ANY CONTENT IN THIS APPLICATION. THIS APP IS NOT AFFILIATED TO MICROSOFT OR ANY OTHER THIRD PARTY. NO USER DATA IS COLLECTED BY DEVELOPER OF THIS APP."
Padding="20" TextWrapping="Wrap" Foreground="Gray"
Grid.Column="0"/>
<Button Content="Download" Grid.Column="1" Width="80" Height="30" Background="{StaticResource GreenSolidColorBrush}" Margin="10" Foreground="White"
Expand Down Expand Up @@ -176,7 +176,7 @@
<TextBlock Text="About" Style="{StaticResource SubHeaderTextBlockStyle}" Padding="14,20,14,5"/>
<TextBlock Text="Download Visual Studio 2017/2019/2022 Offline Setup files and folder, using command line interface. (Need internet connection)" Style="{StaticResource BodyTextBlockStyle}" Padding="14,0"/>
<TextBlock Text="Version" Style="{StaticResource SubHeaderTextBlockStyle}" Padding="14,20,14,5"/>
<TextBlock Text="1.4.1.0" Style="{StaticResource BodyTextBlockStyle}" Padding="14,0"/>
<TextBlock Text="1.4.2.0" Style="{StaticResource BodyTextBlockStyle}" Padding="14,0"/>
</StackPanel>
<!--#endregion Right Content-->
</Grid>
Expand Down

0 comments on commit b3151c8

Please sign in to comment.