clean build artifacts
This commit is contained in:
@@ -135,6 +135,24 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
ParityResults?.Add(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task DeleteBinAndObjFoldersInFolder(CancellationToken token)
|
||||
{
|
||||
ErrorMessages?.Clear();
|
||||
ParityResults.Clear();
|
||||
ResultsLabel = string.Empty;
|
||||
try
|
||||
{
|
||||
CleanFolder.DeleteFolderWithOnlyBinAndObjSubFolders(SolutionFolderPath);
|
||||
ResultsLabel = "Successfully deleted bin and obj folders";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ResultsLabel = "Failed to delete bin and obj folders";
|
||||
ParityResults?.Add(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task LoadSolutionFile(CancellationToken token)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Name="CsprojFilePath" Text="{Binding CsprojFilePath}" />
|
||||
<Button Grid.Column="2" Width="60" HorizontalContentAlignment="Center" Command="{Binding ClearCsprojFileCommand}">Clear</Button>
|
||||
</Grid>
|
||||
<Grid Margin="0 5 0 0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ShowGridLines="False" RowDefinitions="*,*" ColumnDefinitions="*,*,*">
|
||||
<Grid Margin="0 5 0 0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ShowGridLines="False" RowDefinitions="*,*,*" ColumnDefinitions="*,*,*">
|
||||
<Button Grid.Row="0" Grid.Column="0" MinHeight="130" Padding="10" Margin="5"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||
@@ -86,6 +86,15 @@
|
||||
Check For Missing Treat Warnings as Errors
|
||||
</TextBlock>
|
||||
</Button>
|
||||
<Button Grid.Row="2" Grid.Column="0" MinHeight="130" Padding="10" Margin="5"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
|
||||
IsEnabled="{Binding SolutionFilePath, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
|
||||
Command="{Binding DeleteBinAndObjFoldersInFolderCommand}">
|
||||
<TextBlock TextWrapping="Wrap">
|
||||
Clear bin and obj folders
|
||||
</TextBlock>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Label HorizontalAlignment="Center" Name="ResultsLabel" Content="{Binding ResultsLabel}"></Label>
|
||||
</StackPanel>
|
||||
|
||||
17
DotNetSolutionTools.Core/CleanFolder.cs
Normal file
17
DotNetSolutionTools.Core/CleanFolder.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
namespace DotNetSolutionTools.Core;
|
||||
|
||||
public static class CleanFolder
|
||||
{
|
||||
public static void DeleteFolderWithOnlyBinAndObjSubFolders(string folderPath)
|
||||
{
|
||||
var binAndObjFolders = Directory.GetDirectories(folderPath, "*", SearchOption.AllDirectories)
|
||||
.Where(x => x.EndsWith(Path.DirectorySeparatorChar + "bin") || x.EndsWith(Path.DirectorySeparatorChar + "obj"))
|
||||
.ToList();
|
||||
|
||||
foreach (var folder in binAndObjFolders)
|
||||
{
|
||||
Directory.Delete(folder, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user