forked from MaterialDesignInXAML/MaterialDesignInXamlToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildNugets.ps1
More file actions
86 lines (72 loc) · 2.4 KB
/
BuildNugets.ps1
File metadata and controls
86 lines (72 loc) · 2.4 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
param(
[string]$MDIXVersion = "1.0.0",
[string]$MDIXColorsVersion = "1.0.0",
[string]$MDIXMahAppsVersion = "1.0.0"
)
$year = [System.DateTime]::Now.ToString("yyyy")
$copywrite = "Copyright $year James Willock/Mulholland Software Ltd"
$configuration = "Release"
function Update-Icon {
param (
[string]$Path
)
$Path = Resolve-Path $Path
[xml] $xml = Get-Content $Path
[string] $iconUrl = $xml.package.metadata.iconUrl;
if (![string]::IsNullOrWhiteSpace($iconUrl) -and [string]::IsNullOrWhiteSpace($xml.package.metadata.icon)) {
$nugetIconFile = "$($xml.package.metadata.id).Icon.png";
Invoke-WebRequest $iconUrl -OutFile "$nugetIconFile"
$files = $xml.SelectSingleNode("/package/files")
$iconFile = $xml.CreateElement("file")
$iconFile.SetAttribute("src", "$nugetIconFile")
$iconFile.SetAttribute("target", "images\")
$files.AppendChild($iconFile) | Out-Null
$iconElement = $xml.CreateElement("icon")
$iconElement.InnerText = "images\$nugetIconFile"
$xml.package.metadata.AppendChild($iconElement) | Out-Null
}
$xml.Save($Path)
}
function Update-Versions {
param (
[string]$Path
)
$Path = Resolve-Path $Path
[xml] $xml = Get-Content $Path
foreach($dependency in $xml.package.metadata.dependencies.group.dependency){
if ($dependency.id -eq "MaterialDesignColors") {
$dependency.version = Get-VersionString $MDIXColorsVersion
} elseif ($dependency.id -eq "MaterialDesignThemes") {
$dependency.version = Get-VersionString $MDIXVersion
}
}
$xml.Save($Path)
}
function Get-VersionString {
param (
[string]$Version
)
$callback = {
[int]$args[0].Groups[1].Value + 1
}
$re = [regex]"^(\d+).*"
$nextVersion = $re.Replace($Version, $callback)
return "[$Version,$nextVersion.0)"
}
function New-Nuget {
param (
[string]$NuSpecPath,
[string]$Version
)
$NuSpecPath = Resolve-Path $NuSpecPath
Update-Icon "$NuSpecPath"
nuget pack "$NuSpecPath" -version "$Version" -Properties "Configuration=$configuration;Copywrite=$copywrite"
}
Push-Location "$(Join-Path $PSScriptRoot "..")"
Update-Versions .\MaterialDesignColors.nuspec
Update-Versions .\MaterialDesignThemes.nuspec
Update-Versions .\MaterialDesignThemes.MahApps.nuspec
New-Nuget .\MaterialDesignColors.nuspec $MDIXColorsVersion
New-Nuget .\MaterialDesignThemes.nuspec $MDIXVersion
New-Nuget .\MaterialDesignThemes.MahApps.nuspec $MDIXMahAppsVersion
Pop-Location