Skip to content

Commit e60f15b

Browse files
committed
Improve lock detection:
* Detect locked folders * Search through process modules * Improve GUI: use Monospaced font for file names in the expanded list
1 parent e679608 commit e60f15b

25 files changed

Lines changed: 620 additions & 171 deletions

.editorconfig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ trim_trailing_whitespace = true
66
insert_final_newline = true
77
charset = utf-8
88
indent_style = space
9-
indent_size = 4
10-
max_line_length = 150
11-
12-
[*.{xml,wxs,csproj,wixproj,config,sln,svg,manifest,json,yaml}]
139
indent_size = 2
10+
11+
[*.{cs}]
12+
indent_size = 4

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/Build/
2-
/.vs/
3-
/.idea/
1+
/build/
2+
.vs/
3+
.idea/
44
launchSettings.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A simple clone of [PowerToys File Locksmith](https://learn.microsoft.com/en-us/w
2020

2121
## System requirements
2222

23-
* Windows 7 x64 or higher (you might need to install [.Net Framework 4.6.2](https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net462-web-installer))
23+
* Windows 7 x64 or higher (you might need to install `.Net Framework 4.7.2`)
2424

2525
## How to use
2626

ShowWhatProcessLocksFile.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Files", "Files", "{A8406D94
1616
build.ps1 = build.ps1
1717
src\Directory.Build.props = src\Directory.Build.props
1818
.github\workflows\main.yaml = .github\workflows\main.yaml
19-
nuget.config = nuget.config
2019
README.md = README.md
2120
EndProjectSection
2221
EndProject

build.ps1

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Function CheckReturnCodeOfPreviousCommand($msg) {
1717
Function GetVersion() {
1818
$gitCommand = Get-Command -Name git
1919

20-
try { $tag = & $gitCommand describe --exact-match --tags HEAD } catch { }
20+
try { $tag = & $gitCommand describe --exact-match --tags HEAD 2> $null } catch { }
2121
if(-Not $?) {
2222
Info "The commit is not tagged. Use 'v0.0-dev' as a version instead"
2323
$tag = "v0.0-dev"
@@ -33,25 +33,6 @@ Function GetInstallerVersion($version) {
3333
return $version.Split("-")[0];
3434
}
3535

36-
Function FindMsBuild() {
37-
$vswhereCommand = Get-Command -Name "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
38-
39-
$msbuild = `
40-
& $vswhereCommand `
41-
-latest `
42-
-requires Microsoft.Component.MSBuild `
43-
-find MSBuild\**\Bin\MSBuild.exe `
44-
| select-object -first 1
45-
46-
if(!$msbuild)
47-
{
48-
Error "Can't find MsBuild"
49-
}
50-
51-
Info "MsBuild found: `n $msbuild"
52-
return $msbuild
53-
}
54-
5536
Function RemoveFileIfExists($fileName) {
5637
Info "Remove '$fileName'"
5738
Remove-Item $fileName -Force -Recurse -ErrorAction SilentlyContinue
@@ -64,32 +45,31 @@ $ProgressPreference = "SilentlyContinue"
6445
$root = Resolve-Path "$PSScriptRoot"
6546
$buildDir = "$root/build"
6647
$publishDir = "$buildDir/Release/Installer"
67-
$projectName = "ShowWhatProcessLocksFile"
6848
$version = GetVersion
6949
$installerVersion = GetInstallerVersion $version
70-
$msbuild = FindMsBuild
7150

7251
Info "Version: '$version'. InstallerVersion: '$installerVersion'"
7352

7453
Info "Build project"
75-
& $msbuild `
76-
/property:RestorePackagesConfig=true `
77-
/property:Configuration=Release `
78-
/property:DebugType=None `
79-
/property:Version=$version `
80-
/property:InstallerVersion=$installerVersion `
81-
/verbosity:Minimal `
82-
/target:"restore;build" `
83-
$root/$projectName.sln
54+
dotnet build `
55+
--nologo `
56+
--configuration Release `
57+
-verbosity:minimal `
58+
/property:DebugType=None `
59+
/property:Version=$version `
60+
/property:InstallerVersion=$installerVersion `
61+
"$root/ShowWhatProcessLocksFile.sln"
8462
CheckReturnCodeOfPreviousCommand "build failed"
8563

8664
Info "Run tests"
8765
dotnet test `
66+
--nologo `
8867
--no-build `
8968
--configuration Release `
90-
$root/$projectName.sln
69+
-verbosity:minimal `
70+
--logger:"console;verbosity=normal" `
71+
$root/ShowWhatProcessLocksFile.sln
9172
CheckReturnCodeOfPreviousCommand "tests failed"
9273

93-
RemoveFileIfExists "$publishDir/${projectName}.msi.zip"
9474
Info "Create zip archive from msi installer"
95-
Compress-Archive -Path "$publishDir/$projectName.msi" -DestinationPath "$publishDir/${projectName}.msi.zip"
75+
Compress-Archive -Force -Path "$publishDir/ShowWhatProcessLocksFile.msi" -DestinationPath "$publishDir/ShowWhatProcessLocksFile.msi.zip"

nuget.config

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/App/Gui/Controls/ProcessInfoView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Visibility="{Binding IsExpanded, Converter={StaticResource BooleanToCollapsedVisibilityConverter}}">
4242
<ItemsControl.ItemTemplate>
4343
<DataTemplate>
44-
<TextBlock Margin="20, 2, 2, 2" Text="{Binding}" />
44+
<TextBlock Margin="20, 2, 2, 2" Text="{Binding}" FontFamily="Consolas"/>
4545
</DataTemplate>
4646
</ItemsControl.ItemTemplate>
4747
</ItemsControl>

src/App/Gui/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
xmlns:controls="clr-namespace:ShowWhatProcessLocksFile.Gui.Controls"
99
mc:Ignorable="d"
1010
x:Name="Self"
11-
Title="{Binding Title}" Height="450" Width="800"
11+
Title="{Binding Title}" Height="600" Width="1200"
1212
d:DataContext="{d:DesignInstance Type=local:MainWindowViewModel, IsDesignTimeCreatable=False}">
1313
<Window.Resources>
1414
<utils:BooleanToCollapsedVisibilityConverter x:Key="BooleanToCollapsedVisibilityConverter" />

src/App/Gui/MainWindowViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ internal class MainWindowViewModel : ViewModelBase
1515

1616
public string FilePath { get; }
1717

18-
private ViewModelBase mainControl;
18+
private ViewModelBase? mainControl;
1919

20-
public ViewModelBase MainControl
20+
public ViewModelBase? MainControl
2121
{
2222
get => mainControl;
2323
private set

src/App/Gui/Utils/RelayCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public event EventHandler CanExecuteChanged
1111
}
1212

1313
private readonly Action methodToExecute;
14-
private readonly Func<bool> canExecuteEvaluator;
14+
private readonly Func<bool>? canExecuteEvaluator;
1515

16-
public RelayCommand(Action methodToExecute, Func<bool> canExecuteEvaluator = null)
16+
public RelayCommand(Action methodToExecute, Func<bool>? canExecuteEvaluator = null)
1717
{
1818
this.methodToExecute = methodToExecute;
1919
this.canExecuteEvaluator = canExecuteEvaluator;
@@ -44,9 +44,9 @@ public event EventHandler CanExecuteChanged
4444
}
4545

4646
private readonly Action<T> methodToExecute;
47-
private readonly Predicate<T> canExecuteEvaluator;
47+
private readonly Predicate<T>? canExecuteEvaluator;
4848

49-
public RelayCommand(Action<T> methodToExecute, Predicate<T> canExecuteEvaluator = null)
49+
public RelayCommand(Action<T> methodToExecute, Predicate<T>? canExecuteEvaluator = null)
5050
{
5151
this.methodToExecute = methodToExecute;
5252
this.canExecuteEvaluator = canExecuteEvaluator;

0 commit comments

Comments
 (0)