Skip to content

Commit

Permalink
Merge pull request #131 from Sophia-Community/Newtonsoft.Json
Browse files Browse the repository at this point in the history
Update Get-BinaryFiles.ps1
  • Loading branch information
farag2 committed Sep 11, 2022
2 parents 98f932d + 04cd38a commit 90b658b
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 116 deletions.
37 changes: 25 additions & 12 deletions .github/workflows/SophiApp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ jobs:
with:
fetch-depth: 0

- name: Preparing The App Files
- name: Preparing files
run: |
. "SophiApp\Scripts\Set-ReleaseTag.ps1" "${{ github.ref }}"
. "SophiApp\Scripts\Set-ReleaseTag.ps1" "${{ github.ref_name }}"
. "SophiApp\Scripts\Uncomment-AppMethods.ps1"
. "SophiApp\Scripts\Set-DebugMode.ps1"
. "SophiApp\Scripts\Set-WinmdPath.ps1"
- name: Downloading files
run: |
. SophiApp\Scripts\Get-Dependencies.ps1
- name: Setup NuGet
uses: nuget/setup-nuget@main
with:
Expand All @@ -44,19 +48,28 @@ jobs:
Platform: ${{ matrix.platform }}
Configuration: ${{ matrix.configuration }}

- name: Cleanup Files
- name: Files Cleanup
run: |
$ExcludedTypes = @("*.exe", "*.config")
$SourceFolder = "{0}\*" -f SophiApp\SophiApp\bin\Release
$DestinationFolder = "{0}\{1}" -f SophiApp\SophiApp\bin\Release, Bin
Get-ChildItem -Path SophiApp\SophiApp\bin\Release -Exclude $ExcludedTypes | Remove-Item -Force -Recurse -Confirm:$false
. "$env:App_Script_Path\Get-BinaryFiles.ps1"
Get-ChildItem -Path SophiApp\SophiApp\bin\Release -Exclude @("*.exe", "*.config") | Remove-Item -Force -Recurse -Confirm:$false
. SophiApp\Scripts\Copy-Dependencies.ps1
- name: Compress Files
- name: Compress Folder
run: |
$Build_Directory = Rename-Item -Path SophiApp\SophiApp\bin\Release -NewName SophiApp -PassThru | Select-Object -ExpandProperty FullName
Compress-Archive -Path $Build_Directory -DestinationPath SophiApp.zip -CompressionLevel Optimal
# Get the file hash
$Parameters = @{
Path = "SophiApp\SophiApp\bin\Release"
NewName = "SophiApp"
PassThru = $true
}
$Build_Directory = (Rename-Item @Parameters).FullName
$Parameters = @{
Path = $Build_Directory
DestinationPath = "SophiApp.zip"
CompressionLevel = "Optimal"
}
Compress-Archive @Parameters
# Get SophiApp.zip hash
Write-Host -Object "SophiApp.zip SHA256 hash: $((Get-FileHash -Path SophiApp.zip -Algorithm SHA256).Hash)"
- name: Release Build
Expand Down
Binary file removed SophiApp/Binary/System.Management.Automation.dll
Binary file not shown.
Binary file removed SophiApp/Binary/Windows.winmd
Binary file not shown.
5 changes: 5 additions & 0 deletions SophiApp/Scripts/Copy-Dependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ReleaseBinDir = "$(Split-Path -Path $PSScriptRoot -Parent)\SophiApp\bin\Release\Bin"
New-Item -Path (Split-Path -Path $ReleaseBinDir -Parent) -Name Bin -ItemType Directory -Force

# Copy downloaded dependencies to the created Bin folder
Get-ChildItem -Path "SophiApp\Binary" | Copy -Destination $ReleaseBinDir -Force
104 changes: 0 additions & 104 deletions SophiApp/Scripts/Get-BinaryFiles.ps1

This file was deleted.

92 changes: 92 additions & 0 deletions SophiApp/Scripts/Get-Dependencies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<#
.SYNOPSIS
Download binary for SophiApp build action
.NOTES
https://developer.microsoft.com/ru-ru/windows/downloads/sdk-archive/
https://www.nuget.org/packages/Microsoft.Dism
https://github.com/dahall/TaskScheduler
https://github.com/JamesNK/Newtonsoft.Json
#>

New-Item -Path SophiApp\Binary -ItemType Directory -Force

# https://www.nuget.org/packages/Microsoft.Dism
Write-Verbose -Message Microsoft.Dism -Verbose
$Parameters = @{
Uri = "https://www.nuget.org/api/v2/package/Microsoft.Dism"
OutFile = "$PSScriptRoot\microsoft.dism.zip"
UseBasicParsing = $true
}
Invoke-RestMethod @Parameters

# Extract Microsoft.Dism.dll from the archive
Add-Type -Assembly System.IO.Compression.FileSystem
$ZIP = [IO.Compression.ZipFile]::OpenRead("$PSScriptRoot\microsoft.dism.zip")
$Entries = $ZIP.Entries | Where-Object -FilterScript {$_.FullName -eq "lib/net40/Microsoft.Dism.dll"}
$Entries | ForEach-Object -Process {[IO.Compression.ZipFileExtensions]::ExtractToFile($_, "SophiApp\Binary\$($_.Name)", $true)}
$ZIP.Dispose()

# https://www.nuget.org/packages/WiX
Write-Verbose -Message Microsoft.Deployment.WindowsInstaller -Verbose
$Parameters = @{
Uri = "https://www.nuget.org/api/v2/package/WiX"
OutFile = "$PSScriptRoot\wix.zip"
UseBasicParsing = $true
}
Invoke-RestMethod @Parameters

# Extract Microsoft.Deployment.WindowsInstaller.dll from the archive
Add-Type -Assembly System.IO.Compression.FileSystem
$ZIP = [IO.Compression.ZipFile]::OpenRead("$PSScriptRoot\wix.zip")
$Entries = $ZIP.Entries | Where-Object -FilterScript {$_.FullName -eq "tools/Microsoft.Deployment.WindowsInstaller.dll"}
$Entries | ForEach-Object -Process {[IO.Compression.ZipFileExtensions]::ExtractToFile($_, "SophiApp\Binary\$($_.Name)", $true)}
$ZIP.Dispose()

# https://www.nuget.org/packages/TaskScheduler
Write-Verbose -Message TaskScheduler -Verbose
$Parameters = @{
Uri = "https://www.nuget.org/api/v2/package/TaskScheduler"
OutFile = "$PSScriptRoot\TaskScheduler.zip"
UseBasicParsing = $true
}
Invoke-RestMethod @Parameters

# Extract Microsoft.Win32.TaskScheduler.dll from the archive
Add-Type -Assembly System.IO.Compression.FileSystem
$ZIP = [IO.Compression.ZipFile]::OpenRead("$PSScriptRoot\TaskScheduler.zip")
$Entries = $ZIP.Entries | Where-Object -FilterScript {$_.FullName -eq "lib/net452/Microsoft.Win32.TaskScheduler.dll"}
$Entries | ForEach-Object -Process {[IO.Compression.ZipFileExtensions]::ExtractToFile($_, "SophiApp\Binary\$($_.Name)", $true)}
$ZIP.Dispose()

# https://www.nuget.org/packages/Newtonsoft.Json
Write-Verbose -Message Newtonsoft.Json -Verbose
$Parameters = @{
Uri = "https://www.nuget.org/api/v2/package/Newtonsoft.Json"
OutFile = "$PSScriptRoot\newtonsoft.json.zip"
UseBasicParsing = $true
}
Invoke-RestMethod @Parameters

# Extract Newtonsoft.Json.dll from the archive
Add-Type -Assembly System.IO.Compression.FileSystem
$ZIP = [IO.Compression.ZipFile]::OpenRead("$PSScriptRoot\newtonsoft.json.zip")
$Entries = $ZIP.Entries | Where-Object -FilterScript {$_.FullName -eq "lib/net45/Newtonsoft.Json.dll"}
$Entries | ForEach-Object -Process {[IO.Compression.ZipFileExtensions]::ExtractToFile($_, "SophiApp\Binary\$($_.Name)", $true)}
$ZIP.Dispose()

# Coping Windows.winmd
Write-Verbose -Message Windows.winmd -Verbose
$Parameters = @{
Path = "${env:ProgramFiles(x86)}\Windows Kits\10\UnionMetadata\10.0.19041.0\Windows.winmd"
Destination = "SophiApp\Binary"
}
Copy-Item @Parameters

# Coping System.Management.Automation.dll
Write-Verbose -Message System.Management.Automation.dll -Verbose
$Parameters = @{
Path = "${env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll"
Destination = "SophiApp\Binary"
}
Copy-Item @Parameters

0 comments on commit 90b658b

Please sign in to comment.