diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 87b31cf..d9598b9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,5 +1,8 @@ name: Pull Request +permissions: + contents: read + on: pull_request: @@ -7,9 +10,20 @@ jobs: build: runs-on: windows-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 + name: Checkout + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0' + - run: dotnet test + + dependency-review: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 name: Checkout - - uses: actions/setup-dotnet@v1 + - uses: actions/dependency-review-action@v4 + name: Dependency Review with: - dotnet-version: '3.1.100' - - run: dotnet test \ No newline at end of file + allow-licenses: MIT, Apache-2.0, BSD-2-Clause + fail-on-scopes: development, runtime, unknown \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3758dd5..910e5ef 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bin/ obj/ .vs/ .vscode/ +out/ \ No newline at end of file diff --git a/build/build.ps1 b/build/build.ps1 new file mode 100644 index 0000000..5b08604 --- /dev/null +++ b/build/build.ps1 @@ -0,0 +1,70 @@ +# PowerShell < 7 does not handle ZIP files correctly. +if ($PSVersionTable.PSVersion.Major -lt 7) { + throw "This script requires PowerShell 7 or higher." +} + +$rootDir = $MyInvocation.MyCommand.Path + +if (!$rootDir) { + $rootDir = $psISE.CurrentFile.Fullpath +} + +if ($rootDir) { + foreach($i in 1..2) { + $rootDir = Split-Path $rootDir -Parent + } +} +else { + throw 'Could not determine root directory of project.' +} + +if (![bool](Get-Command -ErrorAction Stop -Type Application dotnet)) { + throw 'dotnet SDK could not be found.' +} + +$winKitDir = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots' 'KitsRoot10' + +if (!$winKitDir -or !(Test-Path -Path $winKitDir)) { + throw 'Windows SDK path is not found.' +} + +$sdkVersion = Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots' | Sort-Object Name -Descending | Select-Object -ExpandProperty PSChildName -First 1 +$sdkPath = Join-Path -Path $winKitDir -ChildPath 'bin' +$sdkPath = Join-Path -Path $sdkPath -ChildPath $sdkVersion + +$architecture = [System.Environment]::GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") +$archDirName = switch ($architecture) { + 'ARM64' { 'arm64' } + 'x86' { 'x86' } + 'AMD64' { 'x64' } + Default { throw 'Unknown architecture' } +} + +$sdkBinPath = Join-Path -Path $sdkPath -ChildPath $archDirName +$objDir = Join-Path -Path $rootDir -ChildPath 'obj' +$outDir = Join-Path -Path $rootDir -ChildPath 'out' + +pushd $rootDir + +Remove-Item -Path $objDir -Recurse -Force -ErrorAction SilentlyContinue +New-Item -Path $objDir -ItemType Directory + +Remove-Item -Path $outDir -Recurse -Force -ErrorAction SilentlyContinue +New-Item -Path $outDir -ItemType Directory + +dotnet pack -p:OutputFileNamesWithoutVersion=true -p:ContinuousIntegrationBuild=true -c Release -o $objDir src\AuthenticodeExaminer\AuthenticodeExaminer.csproj + +Expand-Archive -Path $objDir\AuthenticodeExaminer.nupkg -DestinationPath $objDir\AuthenticodeExaminer.nupkg.dir + +Remove-Item -Path $objDir\AuthenticodeExaminer.nupkg + +& "$sdkBinPath\signtool.exe" sign /d "AuthenticodeExaminer" /sha1 73f0844a95e35441a676cd6be1e79a3cd51d00b4 /fd SHA384 /td SHA384 /tr "http://timestamp.digicert.com" /du "https://github.com/vcsjones/AuthenticodeExaminer" "$objDir\AuthenticodeExaminer.nupkg.dir\lib\netstandard2.0\AuthenticodeExaminer.dll" +& "$sdkBinPath\signtool.exe" sign /d "AuthenticodeExaminer" /sha1 73f0844a95e35441a676cd6be1e79a3cd51d00b4 /fd SHA384 /td SHA384 /tr "http://timestamp.digicert.com" /du "https://github.com/vcsjones/AuthenticodeExaminer" "$objDir\AuthenticodeExaminer.nupkg.dir\lib\net462\AuthenticodeExaminer.dll" + +Compress-Archive -Path "$objDir\AuthenticodeExaminer.nupkg.dir\*" -DestinationPath "$objDir\AuthenticodeExaminer.nupkg" + +dotnet nuget sign --certificate-fingerprint 68821304869e065c24e0684eb43bf974e124642f3437f2ff494a93bb371d029a --hash-algorithm SHA384 --timestamper "http://timestamp.digicert.com" --overwrite "$objDir\AuthenticodeExaminer.nupkg" + +Copy-Item -Path "$objDir\AuthenticodeExaminer.nupkg" -Destination "$outDir\AuthenticodeExaminer.nupkg" + +popd \ No newline at end of file diff --git a/sample/sample.csproj b/sample/sample.csproj index 306decc..05acbac 100644 --- a/sample/sample.csproj +++ b/sample/sample.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net8.0 enable diff --git a/src/AuthenticodeExaminer/AuthenticodeExaminer.csproj b/src/AuthenticodeExaminer/AuthenticodeExaminer.csproj index 8bf3b02..567463c 100644 --- a/src/AuthenticodeExaminer/AuthenticodeExaminer.csproj +++ b/src/AuthenticodeExaminer/AuthenticodeExaminer.csproj @@ -1,11 +1,11 @@  - netstandard2.0;net46;net461 + netstandard2.0;net462 true Kevin Jones authenticode;codesign https://github.com/vcsjones/AuthenticodeExaminer - 0.3.0 + 0.4.0 true true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb @@ -16,14 +16,14 @@ - - + + - + diff --git a/test/AuthenticodeExaminer.Tests/AuthenticodeExaminer.Tests.csproj b/test/AuthenticodeExaminer.Tests/AuthenticodeExaminer.Tests.csproj index 98659f2..8f6ee82 100644 --- a/test/AuthenticodeExaminer.Tests/AuthenticodeExaminer.Tests.csproj +++ b/test/AuthenticodeExaminer.Tests/AuthenticodeExaminer.Tests.csproj @@ -1,14 +1,18 @@ - netcoreapp3.1;net46 + net8.0;net472 false + Exe - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +