-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInstall-Packages.ps1
More file actions
36 lines (30 loc) · 1.62 KB
/
Install-Packages.ps1
File metadata and controls
36 lines (30 loc) · 1.62 KB
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
function GetLatestVersionFilePath($FileName, $Framework) {
$pattern = if ($framework) { ".*packages.*$Framework.*$FileName" } else { ".*packages.*$FileName" }
$allDllPaths = Get-ChildItem -Path "./packages" -Recurse -File
$allDllPaths | Where-Object {
$_.FullName -match $pattern
} | Select-Object -ExpandProperty "FullName" | Sort-Object -Descending | Select-Object -First 1
}
$libraryName = "CodeSanook.SqlGenerator"
& nuget Install $libraryName -DependencyVersion Lowest -OutputDirectory "./packages"
#copy all file a to target folder
$outputFolder = "./$libraryName/bin/release"
Remove-Item $outputFolder -Recurse -Force -ErrorAction Ignore
New-Item -Path $outputFolder -ItemType Directory -Force
$assemblyPath = GetLatestVersionFilePath -FileName "$libraryName.dll"
"assembly path $assemblyPath"
$assembly = [Reflection.Assembly]::LoadFrom($assemblyPath)
$attribute = $assembly.GetCustomAttributes([System.Runtime.Versioning.TargetFrameworkAttribute])
$pattern = "version=v(?<version>[\w\.]+)"
$option = [Text.RegularExpressions.RegexOptions]::IgnoreCase
$match = [Regex]::Match($attribute.FrameworkName, $pattern, $option);
$framework = $match.Groups["version"].value -replace "\.", ""
"framework $framework"
@(
GetLatestVersionFilePath -FileName "$libraryName.dll" -Framework $framework
GetLatestVersionFilePath -FileName "System.ValueTuple.dll" -Framework $framework
) | Copy-Item -Destination $outputFolder
GetLatestVersionFilePath -FileName "Export-SqlQuery.ps1" | Copy-Item -Destination "."
GetLatestVersionFilePath -FileName "Export-SqlQueryModule.psm1" | Copy-Item -Destination "."
"Install successfully"