-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBuild-FB2KComponent.ps1
134 lines (103 loc) · 5.34 KB
/
Build-FB2KComponent.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<#
.SYNOPSIS
Builds the foobar2000 component package.
.DESCRIPTION
This script will be executed unconditionally during the Post-build step. It copies all the necessary files to an output directory and creates the zip archive.
.EXAMPLE
C:\PS> .\Build-FB2KComponent.ps1
.OUTPUTS
*.fb2k-component
#>
[CmdletBinding()]
param
(
[parameter(Mandatory, HelpMessage='Target Name')]
[string] $TargetName,
[parameter(Mandatory, HelpMessage='Target File Name')]
[string] $TargetFileName,
[parameter(Mandatory, HelpMessage='Platform')]
[string] $Platform,
[parameter(Mandatory, HelpMessage='OutputPath')]
[string] $OutputPath
)
#Requires -Version 7.2
Set-StrictMode -Version Latest;
Set-PSDebug -Strict; # Equivalent of VBA "Option Explicit".
$ErrorActionPreference = 'Stop';
# Note: The working directory is the solution directory.
Write-Host "Building package `"$TargetName`" ($Platform)...";
if ($Platform -eq 'x64')
{
$PackagePath = "../out/$TargetName";
# Create the package directory (including the x64 subdirectory)
Write-Host "Creating directory `"$PackagePath`"...";
$null = New-Item -Path '../out/' -Name "$TargetName/x64" -ItemType 'directory' -Force;
if (Test-Path -Path "$OutputPath/$TargetFileName")
{
Write-Host "Copying $TargetFileName to `"$PackagePath/x64`"...";
Copy-Item "$OutputPath/$TargetFileName" -Destination "$PackagePath/x64" -Force -Verbose;
Copy-Item "$OutputPath/WebView2Loader.dll" -Destination "$PackagePath/x64" -Force -Verbose;
Copy-Item "Template.html" -Destination "$PackagePath/x64/Default-Template.html" -Force -Verbose;
Copy-Item "FrameTemplate.html" -Destination "$PackagePath/x64/Default-FrameTemplate.html" -Force -Verbose;
Copy-Item "PlaylistTemplate.html" -Destination "$PackagePath/x64/Default-PlaylistTemplate.html" -Force -Verbose;
}
# install the component in the foobar2000 x64 components directory.
$foobar2000Path = '../bin';
if (Test-Path -Path "$foobar2000Path/foobar2000.exe")
{
$ComponentPath = "$foobar2000Path/profile/user-components-x64";
Write-Host "Creating directory `"$ComponentPath/$TargetName`"...";
$null = New-Item -Path "$ComponentPath" -Name "$TargetName" -ItemType 'directory' -Force;
Write-Host "Installing x64 component in foobar2000 64-bit profile...";
Copy-Item "$PackagePath/x64/*.dll" -Destination "$ComponentPath/$TargetName" -Force -Verbose;
Copy-Item "$PackagePath/x64/Default-Template.html" -Destination "$ComponentPath/$TargetName" -Force -Verbose;
Copy-Item "$PackagePath/x64/Default-FrameTemplate.html" -Destination "$ComponentPath/$TargetName" -Force -Verbose;
Copy-Item "$PackagePath/x64/Default-PlaylistTemplate.html" -Destination "$ComponentPath/$TargetName" -Force -Verbose;
}
else
{
Write-Host "Skipped component installation: foobar2000 64-bit directory not found.";
}
}
elseif ($Platform -eq 'Win32')
{
$PackagePath = "../out/$TargetName";
# Create the package directory (including the x64 subdirectory)
Write-Host "Creating directory `"$PackagePath`"...";
$null = New-Item -Path '../out/' -Name "$TargetName/x64" -ItemType 'directory' -Force;
if (Test-Path -Path "$OutputPath/$TargetFileName")
{
Write-Host "Copying $TargetFileName to `"$PackagePath`"...";
Copy-Item "$OutputPath/$TargetFileName" -Destination "$PackagePath" -Force -Verbose;
Copy-Item "$OutputPath/WebView2Loader.dll" -Destination "$PackagePath" -Force -Verbose;
Copy-Item "Template.html" -Destination "$PackagePath/Default-Template.html" -Force -Verbose;
Copy-Item "FrameTemplate.html" -Destination "$PackagePath/Default-FrameTemplate.html" -Force -Verbose;
Copy-Item "PlaylistTemplate.html" -Destination "$PackagePath/Default-PlaylistTemplate.html" -Force -Verbose;
}
# install the x86 component in the foobar2000 x86 components directory.
$foobar2000Path = '../bin/x86';
if (Test-Path -Path "$foobar2000Path/foobar2000.exe")
{
$ComponentPath = "$foobar2000Path/profile/user-components";
Write-Host "Creating directory `"$ComponentPath/$TargetName`"...";
$null = New-Item -Path "$ComponentPath" -Name "$TargetName" -ItemType 'directory' -Force;
Write-Host "Installing x86 component in foobar2000 32-bit profile...";
Copy-Item "$PackagePath/*.dll" -Destination "$ComponentPath/$TargetName" -Force -Verbose;
Copy-Item "$PackagePath/Default-Template.html" -Destination "$ComponentPath/$TargetName" -Force -Verbose;
Copy-Item "$PackagePath/Default-FrameTemplate.html" -Destination "$ComponentPath/$TargetName" -Force -Verbose;
Copy-Item "$PackagePath/Default-PlaylistTemplate.html" -Destination "$ComponentPath/$TargetName" -Force -Verbose;
}
else
{
Write-Host "Skipped component installation: foobar2000 32-bit directory not found.";
}
}
else
{
Write-Host "Unknown platform: $Platform";
exit;
}
$ArchivePath = "../out/$TargetName.fb2k-component";
Write-Host "Creating component archive `"$ArchivePath`"...";
Compress-Archive -Force -Path ../out/$TargetName/* -DestinationPath $ArchivePath;
Write-Host "Done.";