Skip to content

Comparison with popular implementations - MSBuild and File Locksmith (Powertoys) #25

@domsleee

Description

@domsleee

Currently, ForceOps is using LockCheck, which is similar but it isn't the same code that is used in production by other programs.

ForceOps uses:

Restart manager does not support directories according to 1, 2.
There are two similar implementations I could find in open source that are being used by many people.

MSBuild

It uses an adapted version of LockCheck, here. MSBuildSdks also uses it here.
It uses RestartManager, so it only supports files, and not directories.

Example output:

❯ dotnet build
MSBuild version 17.6.1+8ffc3fe3d for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\7.0.302\Microsoft.Common.CurrentVersion.targets(5150,5): warning MSB3026: Coul
d not copy "C:\Users\user\myprogram\obj\Debug\net6\apphost.exe" to "bin\Debug\net6\myprogram.exe".
 Beginning retry 1 in 1000ms. The process cannot access the file 'C:\Users\user\myprogram\bin\Debu
g\net6\myprogram.exe' because it is being used by another process. The file is locked by: "myprogram (1007
24)" [C:\Users\user\myprogram\myprogram.csproj]
C:\Program Files\dotnet\sdk\7.0.302\Microsoft.Common.CurrentVersion.targets(5150,5): warning MSB3026: Coul
d not copy "C:\Users\user\myprogram\obj\Debug\net6\apphost.exe" to "bin\Debug\net6\myprogram.exe".
 Beginning retry 2 in 1000ms. The process cannot access the file 'C:\Users\user\myprogram\bin\Debu
g\net6\myprogram.exe' because it is being used by another process. The file is locked by: "myprogram (1007
24)" [C:\Users\user\myprogram\myprogram.csproj]
...

File Locksmith in PowerToys

File Locksmith uses NtDll, and notably uses NtQueryObject instead of NtQueryInformationFile, which LockCheck uses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions