-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
publish.ps1
83 lines (69 loc) · 3.16 KB
/
publish.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
[CmdletBinding(PositionalBinding=$false)]
Param(
[string]$ProjectName = "MSFSTouchPortalPlugin",
[string]$DistroName = "MSFS-TouchPortal-Plugin",
[string]$BinName = $ProjectName,
[string]$Configuration = "Publish",
[string]$Platform = "x64",
[String]$VersionSuffix = "",
[switch]$FSX = $false,
[switch]$NoClean = $false,
[switch]$BuildAgent = $false
)
if ($FSX) {
$Platform = "FSX"
$DistroName = "FSX-TouchPortal-Plugin"
$BinName = "FSXTouchPortalPlugin"
}
$ErrorActionPreference = "Stop"
$CurrentDir = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Path)
$DistFolderPath = "$CurrentDir\packages-dist"
$PluginFilesPath = "$DistFolderPath\$DistroName"
$BinFilesPath = "$PluginFilesPath\dist"
$GenFilesPath = "$DistFolderPath\Generator"
if (Test-Path $PluginFilesPath) {
Write-Output "Cleaning '$ProjectName' packages-dist folder '$PluginFilesPath'..."
Remove-Item $PluginFilesPath -Force -Recurse
}
if (Test-Path $GenFilesPath) {
Remove-Item $GenFilesPath -Force -Recurse
}
Write-Output "`nPublishing '$ProjectName' component to '$BinFilesPath' ...`n"
dotnet publish "$ProjectName" --output "$BinFilesPath" --configuration $Configuration -p:Platform=$Platform
if ($LastExitCode -ne 0) { throw ("Error " + $LastExitCode) }
Write-Output "`nPublishing '$ProjectName-Generator' component...`n"
#dotnet publish "$ProjectName-Generator" --output "$BinFilesPath" --configuration $Configuration -p:Platform=$Platform
dotnet build "$ProjectName" --output "$GenFilesPath" --configuration Release -p:Platform=$Platform
dotnet build "$ProjectName-Generator" --output "$GenFilesPath" --configuration Release -p:Platform=$Platform
if ($LastExitCode -ne 0) { throw ("Error " + $LastExitCode) }
# Run Documentation
Write-Output "`nGenerating entry.tp JSON and Documentation...`n"
#dotnet run --project "$ProjectName-Generator" -c $Configuration -- -o "$PluginFilesPath" # can't use -p:Platform='
& "$GenFilesPath\$BinName-Generator.exe" -o "$PluginFilesPath"
if ($LastExitCode -ne 0) { throw ("Error " + $LastExitCode) }
Write-Output "Cleaning '$GenFilesPath' ..."
Remove-Item $GenFilesPath -Force -Recurse
# Copy Readme, CHANGELOG, image(s) to publish folder
copy "README.md" "$PluginFilesPath"
copy "CHANGELOG.md" "$PluginFilesPath"
copy "LICENSE" "$PluginFilesPath"
copy "$ProjectName\airplane_takeoff24.png" "$PluginFilesPath"
# Get version
$FileVersion = (Get-Command $BinFilesPath\$BinName.dll).FileVersionInfo.ProductVersion
# Create TPP File
$TppFile = "$DistFolderPath\$DistroName-$FileVersion$VersionSuffix.tpp"
if (Test-Path $TppFile) {
Remove-Item $TppFile -Force
}
Write-Output "`nGenerating archive '$TppFile'..."
& "C:\Program Files\7-Zip\7z.exe" a "$TppFile" "$PluginFilesPath*" -tzip `-xr!*.tpp `-xr!*.zip
if ($LastExitCode -ne 0) { throw ("Error " + $LastExitCode) }
if (-not $NoClean) {
Write-Output "`nCleaning '$ProjectName-Generator' component....`n"
dotnet clean "$ProjectName-Generator" --configuration $Configuration -p:Platform=$Platform /p:ValidateExecutableReferencesMatchSelfContained=false
Write-Output "`nCleaning '$ProjectName' component....`n"
dotnet clean "$ProjectName" --configuration $Configuration -p:Platform=$Platform
}
if ($BuildAgent) {
exit 0
}