forked from ffmpeginteropx/FFmpegInteropX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepack-NuGet.ps1
More file actions
59 lines (45 loc) · 1.73 KB
/
Repack-NuGet.ps1
File metadata and controls
59 lines (45 loc) · 1.73 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
param
(
[Parameter(mandatory=$true)][string] $File,
[Parameter(mandatory=$false)][string] $OutputDirectory = $null,
[Parameter(mandatory=$true)][string] $TargetVersion
)
$File = [System.IO.Path]::GetFullPath("$PSScriptRoot\$File")
if (-not($OutputDirectory))
{
$OutputDirectory = [System.IO.Path]::GetDirectoryName($File)
}
else
{
$OutputDirectory = "$PSScriptRoot\$OutputDirectory"
}
Write-Host
Write-Host ==================== Repack NuGet package =====================
Write-Host
Write-Host "File: $File"
Write-Host "OutputDirectory: $OutputDirectory"
Write-Host "TargetVersion: $TargetVersion"
Write-Host
# Stop on all PowerShell command errors
$ErrorActionPreference = "Stop"
$temp = "$PSScriptRoot\Temp"
$folder = "$PSScriptRoot\Temp\Package"
if (Test-Path $temp) { Remove-Item -Force -Recurse $temp }
New-Item -ItemType Directory -Force $temp
New-Item -ItemType Directory -Force $folder
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($File, $folder)
Remove-Item -Force -Recurse $folder\package
Remove-Item -Force -Recurse $folder\_rels
Remove-Item -Force -LiteralPath $folder\[Content_Types].xml
$nuspec = Get-Item $folder\*.nuspec
$xml = [xml](Get-content($nuspec))
$files = $xml.DocumentElement.AppendChild($xml.CreateElement("files"))
$all = $files.AppendChild($xml.CreateElement("file"))
$all.Attributes.Append($xml.CreateAttribute("src"))
$all.src = "Package\**\*.*"
$xml.Save($nuspec)
Move-Item $nuspec $temp\
$nuspec = Get-Item $temp\*.nuspec
nuget pack $nuspec -Version $TargetVersion -PackagesDirectory $folder -OutputDirectory $OutputDirectory -Symbols -SymbolPackageFormat symbols.nupkg -Properties NoWarn=NU5128
Remove-Item -Force -Recurse $temp