-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from KirillOsenkov/dev/kirillo/tool
Add a .NET tool project
- Loading branch information
Showing
8 changed files
with
119 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<DebugType>embedded</DebugType> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<RollForward>major</RollForward> | ||
<Version>1.0.1</Version> | ||
<PackAsTool>true</PackAsTool> | ||
<ToolCommandName>lockcheck</ToolCommandName> | ||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> | ||
<PackageId>lockchecktool</PackageId> | ||
<Authors>cklutz</Authors> | ||
<Description>A tool to list processes locking a given file.</Description> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/cklutz/LockCheck</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/cklutz/LockCheck</RepositoryUrl> | ||
<PackageTags>.NET dotnet process lock check tool lockcheck</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\LockCheck\LockCheck.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
|
||
namespace LockCheck | ||
{ | ||
internal class Program | ||
{ | ||
private static int Main(string[] args) | ||
{ | ||
try | ||
{ | ||
if (args.Length == 0) | ||
{ | ||
Console.Error.WriteLine("Usage: {0} FILE [FILE ...]", | ||
typeof(Program).Assembly.GetName().Name); | ||
} | ||
|
||
var infos = LockManager.GetLockingProcessInfos(args); | ||
if (!infos.Any()) | ||
{ | ||
Console.WriteLine("No locking processes found."); | ||
return 0; | ||
} | ||
|
||
bool first = true; | ||
foreach (var p in infos) | ||
{ | ||
if (!first) | ||
{ | ||
Console.WriteLine("----------------------------------------------------"); | ||
} | ||
|
||
Console.WriteLine("Process ID : {0}", p.ProcessId); | ||
Console.WriteLine("Application Name : {0}", p.ApplicationName); | ||
Console.WriteLine("Path : {0}", p.ExecutableFullPath); | ||
Console.WriteLine("Process Start Time: {0}", p.StartTime.ToString("F")); | ||
first = false; | ||
} | ||
} | ||
catch (Win32Exception ex) | ||
{ | ||
Console.Error.WriteLine(ex.Message); | ||
return ex.ErrorCode; | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.Error.WriteLine(ex); | ||
return ex.HResult; | ||
} | ||
|
||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters