|
1 | 1 |
|
2 |
| -# thanks => http://stackoverflow.com/questions/1183183/path-of-currently-executing-powershell-script |
| 2 | +# thanks => https://stackoverflow.com/questions/1183183/path-of-currently-executing-powershell-script |
3 | 3 | function Get-ScriptDirectory
|
4 | 4 | {
|
5 | 5 | $Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
6 | 6 | Split-Path $Invocation.MyCommand.Path
|
7 | 7 | }
|
8 | 8 |
|
| 9 | +# thanks => https://stackoverflow.com/questions/1153126/how-to-create-a-zip-archive-with-powershell/ |
| 10 | +function ZipFiles( $zipfilename, $sourcedir ) |
| 11 | +{ |
| 12 | + Add-Type -Assembly System.IO.Compression.FileSystem |
| 13 | + $compressionLevel = ([System.IO.Compression.CompressionLevel]::Optimal) |
| 14 | + [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir, $zipfilename, $compressionLevel, $false) |
| 15 | +} |
| 16 | + |
| 17 | + |
9 | 18 | Push-Location
|
10 | 19 | $scriptPath = Get-ScriptDirectory
|
11 | 20 | CD $scriptPath
|
12 | 21 |
|
13 | 22 | Remove-Item -Recurse -Force Binaries | Out-Null
|
14 |
| -New-Item -ItemType Directory -Force Binaries | Out-Null |
15 |
| - |
16 |
| -Copy-Item ..\Code\TSqlFlex\bin\Release\RedGate.SIPFrameworkShared.dll .\Binaries |
17 |
| -Copy-Item ..\Code\TSqlFlex\bin\Release\TSqlFlex.Core.dll .\Binaries |
18 |
| -Copy-Item ..\Code\TSqlFlex\bin\Release\TSqlFlex.dll .\Binaries |
19 |
| -Copy-Item ..\InstallationInstructions.md .\Binaries\InstallationInstructions.txt |
20 |
| -Copy-Item ..\License.md .\Binaries\License.txt |
21 |
| -Copy-Item ..\README.md .\Binaries\README.txt |
| 23 | +New-Item -ItemType Directory -Force Binaries\All | Out-Null |
| 24 | + |
| 25 | +Copy-Item ..\Code\TSqlFlex\bin\Release\RedGate.SIPFrameworkShared.dll .\Binaries\All |
| 26 | +Copy-Item ..\Code\TSqlFlex\bin\Release\TSqlFlex.Core.dll .\Binaries\All |
| 27 | +Copy-Item ..\Code\TSqlFlex\bin\Release\TSqlFlex.dll .\Binaries\All |
| 28 | +Copy-Item ..\InstallationInstructions.md .\Binaries\All\InstallationInstructions.txt |
| 29 | +Copy-Item ..\License.md .\Binaries\All\License.txt |
| 30 | +Copy-Item ..\README.md .\Binaries\All\README.txt |
| 31 | + |
| 32 | +$outputZip = Join-Path $scriptPath (-Join("Binaries\TSqlFlex.zip")); |
| 33 | +$inputFolder = Join-Path $scriptPath "Binaries\All"; |
| 34 | + |
| 35 | +ZipFiles $outputZip $inputFolder; |
| 36 | + |
| 37 | + |
| 38 | +$TSqlFlexDllVersionInfo = (Get-Item (Join-Path $scriptPath "Binaries\All\TSqlFlex.Core.dll")).VersionInfo; |
| 39 | +$TSqlFlexDllVersion = -join($TSqlFlexDllVersionInfo.FileMajorPart, ".", $TSqlFlexDllVersionInfo.FileMinorPart, |
| 40 | + ".",$TSqlFlexDllVersionInfo.FilePrivatePart); |
| 41 | +$TSqlFlexDllVersion |
| 42 | + |
| 43 | +#read the AssemblySemverPrereleaseTag from the assembly in a new PowerShell instance. |
| 44 | +# then rename the zip file accordingly |
| 45 | +Invoke-Expression (-Join('cmd /c start powershell -Command { |
| 46 | + $assembly = [Reflection.Assembly]::ReflectionOnlyLoadFrom((Join-Path "', $scriptPath, '" "Binaries\All\TSqlFlex.Core.dll")); |
| 47 | + $atts = [reflection.customattributedata]::GetCustomAttributes($assembly); |
| 48 | + $ver = $atts | Where-Object {$_.AttributeType.ToString() -eq "AssemblySemverPrereleaseTag"} | % {$_.ConstructorArguments[0].ToString()} |
| 49 | + $ver = $ver.Replace("`"","") |
| 50 | + if ($ver.length -gt 0) { |
| 51 | + $ver = -Join("-", $ver); |
| 52 | + } |
| 53 | + $fromFileName = (Join-Path "', $scriptPath, '" "Binaries\TSqlFlex.zip"); |
| 54 | + $toFileName = (Join-Path "', $scriptPath, '" (-Join("Binaries\TSqlFlex-", "', $TSqlFlexDllVersion, '", $ver, ".zip"))); |
| 55 | + Rename-Item $fromFileName $toFileName; |
| 56 | +}')); |
| 57 | + |
22 | 58 |
|
23 | 59 | & "C:\Program Files (x86)\Notepad++\notepad++.exe" "..\Chocolatey\TSQLFlex.nuspec"
|
24 | 60 | & "C:\Program Files (x86)\Notepad++\notepad++.exe" "..\Chocolatey\tools\chocolateyInstall.ps1"
|
|
0 commit comments