Added checks.dat build script (#343)
Co-authored-by: Alex <clodanSPT@hotmail.com>
This commit is contained in:
@@ -41,10 +41,15 @@
|
||||
<None Update="sptLogger.Development.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Remove="postBuildScript.ps1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath="" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuildScript" AfterTargets="AfterRebuild" Condition="'$(Configuration)' == 'Release'">
|
||||
<Exec Command="powershell -ExecutionPolicy Bypass -File $(ProjectDir)\postBuildScript.ps1 $(OutDir)Assets $(OutDir)Assets/checks.dat"/>
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
param (
|
||||
[string]$filepath,
|
||||
[string]$output
|
||||
)
|
||||
|
||||
function Load-RecursiveAsync {
|
||||
param (
|
||||
[string]$filepath
|
||||
)
|
||||
|
||||
$result = @{}
|
||||
|
||||
$filesList = Get-ChildItem -Path $filepath
|
||||
|
||||
foreach ($file in $filesList) {
|
||||
$curPath = $file.FullName
|
||||
if ($file.PSIsContainer) {
|
||||
$result[$file.BaseName] = Load-RecursiveAsync "$filepath\$($file.Name)"
|
||||
} elseif ($file.Extension -eq ".json") {
|
||||
$result[$file.BaseName] = Generate-HashForData (Get-Content -Raw -Path "$filepath\$($file.Name)")
|
||||
}
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
function Generate-HashForData {
|
||||
param (
|
||||
[string]$data
|
||||
)
|
||||
|
||||
$sha1 = [System.Security.Cryptography.SHA1]::Create()
|
||||
$hashBytes = $sha1.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($data))
|
||||
$hashHex = -join ($hashBytes | ForEach-Object { $_.ToString("x2") }) # Convert bytes to hex
|
||||
|
||||
return $hashHex
|
||||
}
|
||||
|
||||
function Encode-Base64 {
|
||||
param (
|
||||
[Parameter(ValueFromPipeline=$true)]
|
||||
[string]$inputString
|
||||
)
|
||||
|
||||
process {
|
||||
if ($inputString -and $inputString -ne "") {
|
||||
$bytes = [System.Text.Encoding]::UTF8.GetBytes($inputString)
|
||||
$base64String = [Convert]::ToBase64String($bytes)
|
||||
return $base64String
|
||||
} else {
|
||||
Write-Output "Error: No valid input received!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$results = Load-RecursiveAsync $filepath
|
||||
$results | ConvertTo-Json -Depth 10 -Compress | Encode-Base64 | Out-File $output
|
||||
Reference in New Issue
Block a user