Skip to content

Commit fa7adbc

Browse files
committed
Improve prepDeploy.ps1 to read assembly info from the TSqlFlex.Core.DLL.
1 parent b3e56d7 commit fa7adbc

File tree

3 files changed

+49
-12
lines changed

3 files changed

+49
-12
lines changed

Code/TSqlFlex.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.31101.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TSqlFlex", "TSqlFlex\TSqlFlex.csproj", "{5D764D2E-1BB8-41C7-8F82-428C687A2C6A}"
77
EndProject
@@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1313
ProjectSection(SolutionItems) = preProject
1414
..\InstallationInstructions.md = ..\InstallationInstructions.md
1515
..\License.md = ..\License.md
16+
..\Deploy\prepDeploy.ps1 = ..\Deploy\prepDeploy.ps1
1617
..\README.md = ..\README.md
1718
EndProjectSection
1819
EndProject

Deploy/prepDeploy.ps1

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,60 @@
11

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
33
function Get-ScriptDirectory
44
{
55
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
66
Split-Path $Invocation.MyCommand.Path
77
}
88

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+
918
Push-Location
1019
$scriptPath = Get-ScriptDirectory
1120
CD $scriptPath
1221

1322
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+
2258

2359
& "C:\Program Files (x86)\Notepad++\notepad++.exe" "..\Chocolatey\TSQLFlex.nuspec"
2460
& "C:\Program Files (x86)\Notepad++\notepad++.exe" "..\Chocolatey\tools\chocolateyInstall.ps1"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Please either create issues on GitHub, or reach out to Steve on Twitter at [@nyc
4646
* Compiles and all tests pass.
4747
* Checked-in to master branch on GitHub.
4848
* Updated version in both AssemblyInfo.cs files.
49-
* Build in release mode and test it out.
49+
* Build in release mode, switch the registry to use release mode, and test it out.
5050
* Run .\Deploy\prepDeploy.ps1
5151
* Zip up the DLLs with the license, README, and installation instructions (rename all to .txt) and post to GitHub.
5252
* Add a screenshot via GitHub and edit the README and release FAQ.

0 commit comments

Comments
 (0)