Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b0e29e0a3 | ||
|
|
ba5120b9de |
@@ -0,0 +1,45 @@
|
||||
# Windows Collect Dependencies
|
||||
|
||||
A small Gitea Action for collecting the non-system DLL dependencies required by a Windows executable.
|
||||
|
||||
The action uses `dumpbin` to recursively find dependencies and copies the required DLLs into an artifact directory while skipping Windows system libraries.
|
||||
|
||||
## Usage
|
||||
|
||||
```yaml
|
||||
- name: Collect dependencies
|
||||
uses: https://git.omgitsalexl.me/omgitsalexl/windows-collect-dependencies@v1.0.3
|
||||
with:
|
||||
executable: path/to/MyApp.exe
|
||||
output: artifacts
|
||||
```
|
||||
|
||||
### Inputs
|
||||
|
||||
| Input | Required | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `executable` | Yes | | Path to the executable to inspect |
|
||||
| `output` | No | `artifacts` | Directory where dependencies are copied |
|
||||
|
||||
The executable itself is not copied. Add it to the output directory separately if you want to package it with the collected DLLs.
|
||||
|
||||
## Requirements
|
||||
|
||||
The Windows runner must have Visual Studio or Visual Studio Build Tools installed with the **MSVC C++ tools**.
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
- name: Copy executable
|
||||
shell: powershell
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force -Path artifacts
|
||||
Copy-Item "build\MyApp.exe" "artifacts\MyApp.exe"
|
||||
|
||||
- name: Collect dependencies
|
||||
uses: https://git.omgitsalexl.me/omgitsalexl/windows-collect-dependencies@v1.0.3
|
||||
with:
|
||||
executable: build/MyApp.exe
|
||||
```
|
||||
|
||||
The resulting `artifacts` directory can then be uploaded or packaged by the rest of your workflow.
|
||||
+25
@@ -56,6 +56,13 @@ $windowsDirectories = @(
|
||||
(Join-Path $env:WINDIR "SysWOW64")
|
||||
)
|
||||
|
||||
$windowsKitsDirectories = @(
|
||||
"${env:ProgramFiles(x86)}\Windows Kits",
|
||||
"$env:ProgramFiles\Windows Kits"
|
||||
) | Where-Object {
|
||||
$_ -and (Test-Path $_)
|
||||
}
|
||||
|
||||
$processed = @{}
|
||||
|
||||
function Test-IsWindowsSystemDll {
|
||||
@@ -63,6 +70,10 @@ function Test-IsWindowsSystemDll {
|
||||
[string]$Name
|
||||
)
|
||||
|
||||
if ($Name -like "api-ms-win-*.dll") {
|
||||
return $true
|
||||
}
|
||||
|
||||
foreach ($directory in $windowsDirectories) {
|
||||
$path = Join-Path $directory $Name
|
||||
|
||||
@@ -71,6 +82,20 @@ function Test-IsWindowsSystemDll {
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($directory in $windowsKitsDirectories) {
|
||||
$match = Get-ChildItem `
|
||||
-Path $directory `
|
||||
-Filter $Name `
|
||||
-File `
|
||||
-Recurse `
|
||||
-ErrorAction SilentlyContinue |
|
||||
Select-Object -First 1
|
||||
|
||||
if ($match) {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
return $false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user