Skip to content

Commit

Permalink
Update to net8.0 and rename to LockChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
domsleee committed May 18, 2024
1 parent 6b3e993 commit 2b6eb35
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 166 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: main build

on:
pull_request:
push:
branches:
- main

jobs:
build:
strategy:
matrix:
platform: [windows-latest, ubuntu-latest]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"

- name: Dotnet Installation Info
run: dotnet --info

- name: Build
run: dotnet build

- name: Test
run: dotnet test --no-build --verbosity normal
87 changes: 0 additions & 87 deletions .github/workflows/dotnet-desktop.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/dotnet-ubuntu.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/dotnet-windows.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: release
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
release:
name: ${{ matrix.target }}
permissions:
contents: write
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"

- name: Directory structure
run: |
ls
- name: Dotnet Installation Info
run: dotnet --info

- name: Build
run: dotnet build -c release

- name: Create release
if: ${{ github.ref == 'refs/heads/main' }}
uses: softprops/action-gh-release@v1
with:
draft: true
name: "${{ steps.get_version.outputs.version }}"
files: ForceOps/bin/Release/net8.0/win-x64/publish/ForceOps.exe
tag_name: "${{ steps.get_version.outputs.version }}"

- name: Publish NuGet
if: ${{ github.ref == 'refs/heads/main' }}
run: |
dotnet nuget push -k ${{ secrets.NUGET_AUTH_TOKEN }} -s https://api.nuget.org/v3/index.json LockCheck/bin/Release/*.nupkg --skip-duplicate
2 changes: 1 addition & 1 deletion LockCheck.Tests/LockCheck.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
14 changes: 9 additions & 5 deletions LockCheck/LockCheck.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<AssemblyName>LockChecker</AssemblyName>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<PropertyGroup>
<Authors>Christian Klutz</Authors>
<Authors>Christian Klutz, Dominic Slee</Authors>
<Company />
<Copyright>Copyright © Christian Klutz 2020</Copyright>
<Description>Provides APIs to find processes that are locking files</Description>
<RepositoryUrl>https://github.com/cklutz/LockCheck</RepositoryUrl>
<RepositoryUrl>https://github.com/domsleee/LockCheck</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>file locks</PackageTags>
<PackageProjectUrl>https://github.com/cklutz/LockCheck</PackageProjectUrl>
<PackageProjectUrl>https://github.com/domsleee/LockCheck</PackageProjectUrl>
<!-- All options: https://github.com/dotnet/designs/blob/master/accepted/diagnostics/debugging-with-symbols-and-sources.md -->
<DebugType>Embedded</DebugType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -25,10 +27,12 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="System.Security.Principal.Windows" Version="4.7.0" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<None Include="..\README.md" Link="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# LockCheck
# LockChecker
Uses platform APIs to find processes locking one or multiple files.

[![Nuget](https://img.shields.io/nuget/v/LockCheck)](https://www.nuget.org/packages/LockCheck/)
It's a fork of [LockCheck](https://github.com/cklutz/LockCheck), which is being used by [ForceOps](https://github.com/domsleee/ForceOps)

## Builds
[![Nuget](https://img.shields.io/nuget/v/LockChecker)](https://www.nuget.org/packages/LockChecker/)

[![Desktop](https://github.com/cklutz/LockCheck/workflows/Desktop/badge.svg)](https://github.com/cklutz/LockCheck/actions?query=workflow%3ADesktop)
## Platforms

[![Windows](https://github.com/cklutz/LockCheck/workflows/Windows/badge.svg)](https://github.com/cklutz/LockCheck/actions?query=workflow%3AWindows)

[![Ubuntu](https://github.com/cklutz/LockCheck/workflows/Ubuntu/badge.svg)](https://github.com/cklutz/LockCheck/actions?query=workflow%3AUbuntu)


### Platforms

## Windows
### Windows

On the Windows platform there are two possible engines to provide the lock information:
* Windows RestartManager API (default)
Expand All @@ -32,7 +25,7 @@ Also note, that the RestartManager can only have a maximum of 64 restart manager
sessions per user session - this might not be a real world issue, as the API is
usually only used by installers and setup applications, but again, YMMV.

## Linux
### Linux

On Linux, the `/proc/locks` file is used as basis for finding processes holding a lock
on a file. Linux supports multiple lock types (see this [article](https://gavv.github.io/articles/file-locks/)
Expand All @@ -46,9 +39,9 @@ it has not been used in a real world scenario. The Linux version has been develo

If you have any improvements / PRs please let me know.

### Usage
## Usage

## Getting lock information on demand
### Getting lock information on demand

To get the lockers of a file, if any, use the `LockManager.GetLockingProcessInfos()` function.

Expand All @@ -59,7 +52,7 @@ foreach (var processInfo in LockManager.GetLockingProcessInfods("c:\\temp\\foo.x
}
```

## Enriching Exceptions with Lock Information ##
### Enriching Exceptions with Lock Information

The method ExceptionUtils.RethrowWithLockingInformation() can be used to enrich exceptions
with lock information, if available.
Expand All @@ -68,7 +61,7 @@ Here is a phony example. The inner Open call causes an IOException, because the
Open call already opened the file exclusively (albeit in the same process, but that
doesn't matter for the cause of the example):

```
```csharp
static void Test()
{
using (var file = File.Open("c:\\temp\\foo.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
Expand Down Expand Up @@ -129,7 +122,7 @@ And this is it, with that information included:
ExceptionUtils.cs(80,0): at LockCheck.ExceptionUtils.RethrowWithLockingInformation(Exception ex, String[] fileNames)
ExceptionUtils.cs(24,0): at LockCheck.ExceptionUtils.Test()

### Examples
## Examples

Two example identical example applications are included: one for .NET Framework 4.7.2+ and one for .NET Core 3.1+.

Expand Down
2 changes: 1 addition & 1 deletion Test.NetCore/Test.NetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 2b6eb35

Please sign in to comment.