-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDeploy_Examples.ps1
69 lines (55 loc) · 2.49 KB
/
Deploy_Examples.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
function Update-Config()
{
Param ([string]$configFile)
$configData = (Get-Content $configFile | ConvertFrom-Json)
$configData.ExampleConfig.ResourceLocation = "..\Resources\"
$configData.ExampleConfig.PlugInLocation = "..\PlugIns\"
(ConvertTo-Json $configData | Set-Content $configfile)
}
$artifactDir = "$env:BUILD_ARTIFACTSTAGINGDIRECTORY\\Examples"
$artifactBin = "$artifactDir\\Bin\\"
$artifactPlugIns = "$artifactDir\\PlugIns\\"
$artifactImagesFolder = "$artifactBin\\Images\\"
$baseSrcResources = "Resources\\"
$baseSrcImages = "Examples\\Gorgon.Graphics\\Images\\Images\\*.*"
if (Test-Path $artifactDir)
{
Remove-Item $artifactDir -force -Recurse
}
mkdir $artifactDir
mkdir $artifactBin
mkdir $artifactImagesFolder
mkdir $artifactPlugIns
$gorgonExamples = (Get-ChildItem "Examples\\" -include *.dll,*.exe,appsettings.json,*.runtimeconfig.json,TextViewerContentExample_Installation.txt -Recurse | Where-Object {$_.FullName -match "\\bin\\" -and $_.FullName -notmatch "\\net48\\" -and $_.FullName -notmatch "app.config" -and $_.FullName -notmatch ".vshost.exe" -and $_.FullName -notmatch "\\debug\\" -and $_.FullName -notmatch "\\obj\\" -and $_.FullName -notmatch "_Test" -and $_.FullName -notmatch "\\publish\\" -and $_.FullName -notmatch "\\ref\\" -and $_.FullName -notmatch "\\runtimes\\" })
$plugInDlls = (Get-ChildItem "PlugIns\\Bin\\" -include *.dll -Recurse | Where-Object { $_.FullName -notmatch "\\debug\\" -and $_.FullName -notmatch "\\net48\\" })
Write-Output "$($gorgonExamples.Length) Example files to copy."
Write-Output "$($plugInDlls.Length) Plug in files to copy."
Copy-Item -Path $baseSrcResources -Exclude Krypton_DarkO2k10Theme.xml -Destination $artifactDir -Recurse -Container
Copy-Item -Path $baseSrcImages -Destination $artifactImagesFolder -Container: $false
$appsettingModified = $false
ForEach ($example in $gorgonExamples)
{
# Only update the settings file once, every app shares the same file.
if ($example.FullName.EndsWith("appsettings.json"))
{
if ($appsettingModified -eq $false)
{
Update-Config -configFile $example.FullName
$appsettingModified = $true
}
else
{
continue
}
}
# Don't waste time on files we already have.
if (Test-Path -Path "$artifactBin\\$($example.Name)")
{
continue
}
Copy-Item $example.FullName $artifactBin
}
ForEach ($plugInDll in $plugInDlls)
{
Copy-Item $plugInDll.FullName $artifactPlugIns
}