From 25d767e8ac0d1c9a9a302c58105345ee0a0f8a25 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Wed, 13 Dec 2017 13:21:04 +0100
Subject: [PATCH] Adapt Make-Package to recent changes in folder structure.

---
 Scripts/Make-Package.ps1 | 43 +++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/Scripts/Make-Package.ps1 b/Scripts/Make-Package.ps1
index 397a3ef..a285907 100644
--- a/Scripts/Make-Package.ps1
+++ b/Scripts/Make-Package.ps1
@@ -1,32 +1,43 @@
+[CmdletBinding()]
+Param(
+    [ValidateSet("Debug", "Release")][String] $Target = "Debug"
+)
+
+
+$ResourceDir = "..\AutoTx\Resources"
+$TemplateDir = "$($ResourceDir)\Mail-Templates"
+$BinariesDir = "..\AutoTx\bin\$($Target)"
+
 try {
-    $BuildDate = Get-Content "BuildDate.txt" -EA Stop
+    $BuildDate = Get-Content "$($ResourceDir)\BuildDate.txt" -EA Stop
 }
 catch {
     Write-Host "Error reading build-date, stopping."
     Exit
 }
 
-$BaseDir = $BuildDate -replace ':','-' -replace ' ','_'
-$BaseDir = "build_" + $BaseDir
+$PkgDir = $BuildDate -replace ':','-' -replace ' ','_'
+$PkgDir = "build_" + $PkgDir
 
-Write-Host "Creating package: [$($BaseDir)]"
+Write-Host "Creating package [$($PkgDir)] using binaries from [$($BinariesDir)]"
 
-if (Test-Path $BaseDir) {
+if (Test-Path $PkgDir) {
     Write-Host "Removing existing package dir..."
-    Remove-Item -Recurse -Force $BaseDir
+    Remove-Item -Recurse -Force $PkgDir
 }
 
-$dir = New-Item -ItemType Container -Name $BaseDir
-$dir = New-Item -ItemType Container -Path $BaseDir -Name "AutoTx"
+$dir = New-Item -ItemType Container -Name $PkgDir
+$dir = New-Item -ItemType Container -Path $PkgDir -Name "AutoTx"
+$tgt = $dir.FullName
 
-Copy-Item -Recurse -Force -Path "Mail-Templates" -Destination $dir.FullName
-Copy-Item -Recurse -Force -Path "..\bin\Debug\*" -Destination $dir.FullName
+Copy-Item -Recurse "$TemplateDir" $tgt
+Copy-Item -Recurse "$($BinariesDir)\*" $tgt
 # provide an up-to-date version of the example config file:
-Copy-Item -Force -Path "configuration-example.xml" -Destination $dir.FullName
+Copy-Item "$($ResourceDir)\configuration-example.xml" $tgt
 
-Copy-Item -Force -Path "configuration-example.xml" -Destination "$($BaseDir)\configuration.xml"
-Copy-Item -Force -Path "status-example.xml" -Destination "$($BaseDir)\status.xml"
-Copy-Item -Force -Path "BuildDate.txt" -Destination "$($BaseDir)\service.log"
+Copy-Item "$($ResourceDir)\configuration-example.xml" "$($PkgDir)\configuration.xml"
+Copy-Item "$($ResourceDir)\status-example.xml" "$($PkgDir)\status.xml"
+Copy-Item "$($ResourceDir)\BuildDate.txt" "$($PkgDir)\service.log"
 
-Copy-Item -Force -Path "ScriptsConfig.ps1" -Destination $BaseDir
-Copy-Item -Force -Path "Install-Service.ps1" -Destination $BaseDir
\ No newline at end of file
+Copy-Item "ScriptsConfig.ps1" $PkgDir
+Copy-Item "Install-Service.ps1" $PkgDir
\ No newline at end of file
-- 
GitLab