-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy-plugins-and-start.ps1
58 lines (48 loc) · 2.05 KB
/
copy-plugins-and-start.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
Param(
[string]$pluginname
)
$BECKYFOLDER="C:\temp\BeckyPluginTest\bk27300"
$DATAFOLDER="C:\temp\BeckyPluginTest\bkdata"
$BACKUPFOLDER="C:\temp\BeckyPluginTest\backup\"
$PLUGINFOLDER="C:\Sonstige\BeckyPlugin.Net\plugins"
$BECKY_PROCESS_NAME = "B2"
$datetime = Get-Date -f "yyyy-MM-dd hh_mm_ss"
$countprocesses = get-process | Where-Object {$_.ProcessName -eq $BECKY_PROCESS_NAME} | tee -Variable beckyprocesses | measure
if ($countprocesses.Count -gt 0) {
write-host "Close all Becky Processes!"
write-host "$beckyprocesses"
pause 10000
}
function Copy-ItemExclude($source, $destination, $exclude) {
$privexclude = $exclude -replace '/','\' #Where-Object FullName is built with \ instead
Get-ChildItem $source -Recurse -Exclude $exclude `
| Where-Object {$_.FullName -NotLike $exclude} `
| Copy-Item -Destination {Join-Path $destination $_.FullName.Substring($source.length)}
}
function Copy-Plugin($pluginname) {
Write-Host "Copying: $pluginname"
if (Test-Path "$BECKYFOLDER/plugins/$pluginname") {
# There is always at least nlog.dll inside that folder => no special handling for pluginname.dll
New-Item -ItemType directory -Path "$BACKUPFOLDER/$pluginname/$datetime"
Move-Item "$BECKYFOLDER/plugins/$pluginname*" "$BACKUPFOLDER/$pluginname/$datetime"
}
New-Item -ItemType directory -Path "$BECKYFOLDER/plugins/$pluginname"
#http://stackoverflow.com/questions/731752/exclude-list-in-powershell-copy-item-does-not-appear-to-be-working
Copy-ItemExclude "$PLUGINFOLDER/$pluginname/bin/Debug" "$BECKYFOLDER/plugins/$pluginname" ("$PLUGINFOLDER/$pluginname/bin/Debug/$pluginname.*")
# Putting the assembly into plugin folder
Copy-Item "$PLUGINFOLDER/$pluginname/bin/Debug/$pluginname.*" "$BECKYFOLDER/plugins/" -Recurse
}
if (-not $pluginname -eq "") {
# Copy SELECTED plugin
pause 1000
sleep 10
Copy-Plugin $pluginname
} else {
# Copy ALL plugins
$plugins = Get-Item "$PLUGINFOLDER/*"
foreach($plugin in $plugins) {
$pluginname = $plugin.Name
Copy-Plugin $pluginname
}
}
#. $BECKYFOLDER\b2.exe