-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Add] powershell script to create Version file
- Loading branch information
samatstarion
committed
Aug 16, 2024
1 parent
e848df0
commit 9c275c5
Showing
7 changed files
with
92 additions
and
228 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
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,70 @@ | ||
param ( | ||
[string]$buildTarget, | ||
[string]$publishDir | ||
) | ||
|
||
# Ensure the build target is provided | ||
if (-not $buildTarget) { | ||
Write-Host "No build target provided. Exiting." | ||
exit 1 | ||
} | ||
|
||
# Set the path based on the build target | ||
$binPath = if ($publishDir) { $publishDir } else { Join-Path -Path "bin" -ChildPath $buildTarget } | ||
|
||
# Path to the output file in the target build directory | ||
$outputFile = Join-Path -Path $binPath -ChildPath "VERSION" | ||
|
||
# Echo the path of the VERSION file | ||
Write-Host "The VERSION file will be created at: $outputFile" | ||
|
||
# Clear the content of the output file or create it if it doesn't exist | ||
if (Test-Path $outputFile) { | ||
Clear-Content $outputFile | ||
} else { | ||
New-Item -Path $outputFile -ItemType File | Out-Null | ||
} | ||
|
||
# Normalize the bin path by ensuring it ends with a backslash | ||
$binPath = [System.IO.Path]::GetFullPath($binPath) + [System.IO.Path]::DirectorySeparatorChar | ||
|
||
# Get the list of DLLs in the output directory and all subdirectories | ||
$dlls = Get-ChildItem -Path $binPath -Filter *.dll -Recurse | ||
|
||
# Initialize lists for categorized DLLs | ||
$cdp4CometDlls = @() | ||
$otherDlls = @() | ||
|
||
foreach ($dll in $dlls) { | ||
# Get the version information | ||
$versionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dll.FullName) | ||
|
||
# Get the relative path of the DLL starting from the output directory | ||
$relativeDllPath = $dll.FullName.Substring($binPath.Length) | ||
|
||
# Prepare the output line | ||
$outputLine = "$relativeDllPath $($versionInfo.FileVersion)" | ||
|
||
# Categorize DLLs | ||
if ($dll.Name -match "(?i)cdp4|comet") { | ||
$cdp4CometDlls += $outputLine | ||
} else { | ||
$otherDlls += $outputLine | ||
} | ||
} | ||
|
||
# Sort the other DLLs alphabetically | ||
$otherDlls = $otherDlls | Sort-Object | ||
|
||
# Write the categorized DLLs to the VERSION file | ||
Add-Content -Path $outputFile -Value "CDP4-COMET:" | ||
Add-Content -Path $outputFile -Value "----------------" | ||
$cdp4CometDlls | ForEach-Object { Add-Content -Path $outputFile -Value $_ } | ||
|
||
Add-Content -Path $outputFile -Value "" | ||
Add-Content -Path $outputFile -Value "Dependencies:" | ||
Add-Content -Path $outputFile -Value "----------------" | ||
$otherDlls | ForEach-Object { Add-Content -Path $outputFile -Value $_ } | ||
|
||
# Confirm the creation of the VERSION file | ||
Write-Host "Version information written to $outputFile in $binPath" |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.