blob: d77f2c346f2d204b052af67524c019f380d8c498 (
plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
$nugetOutputDirectory = '../Build'
$releaseNotesUri = 'https://github.com/PrismLibrary/Prism/wiki/Release-Notes-'
$coreFileVersion = '1.0.0'
$nugetFileName = 'nuget.exe'
Write-Host "Packing $env:solution_name"
function Get-FileVersion
{
[OutputType([string])]
Param ([string]$assemblyPath)
if(!$assemblyPath)
{
return ""
}
if((Test-Path $assemblyPath))
{
$fileInfo = Get-Item $assemblyPath
return $fileInfo.VersionInfo.ProductVersion
}
throw "Could not locate the assembly '$assemblyPath'"
}
function ConvertTo-NuGetExpression
{
[OutputType([string])]
Param (
[string]$nuspecPath,
[string]$wpfVersion,
[string]$uwpVersion
)
$fileVersion = $wpfVersion
if(!$fileVersion)
{
$fileVersion = $uwpVersion
}
$expression = ".\$($nugetFileName) pack $($nuspecPath) -outputdirectory $($nugetOutputDirectory) -Prop version=$($fileVersion) -Prop coreVersion=$($fileVersion) -Prop releaseNotes=$($releaseNotesUri)$fileVersion"
if($wpfVersion)
{
$expression = "$expression -Prop wpfVersion=$($wpfVersion)"
}
if($uwpVersion)
{
$expression = "$expression -Prop uwpVersion=$($uwpVersion)"
}
Write-Host "Finished Expression: $expression"
return $expression
}
function Save-NuGetPackage ($project) {
$nuspecPath = $project.NuSpec
$wpfAssemblyPath = $project.Files.Wpf
$uwpAssemblyPath = $project.Files.UWP
Write-Host "NuSpec: $nuspecPath"
Write-Host "WPF Assembly: $wpfAssemblyPath"
Write-Host "UWP Assembly: $uwpAssemblyPath"
$wpfVersion = Get-FileVersion -assemblyPath $wpfAssemblyPath
$uwpVersion = Get-FileVersion -assemblyPath $uwpAssemblyPath
Write-Host "WPF Version: $wpfVersion"
Write-Host "UWP Version: $uwpVersion"
if($wpfVersion -eq '' -and $uwpVersion -eq '')
{
Write-Host "Something seems to be wrong, we couldn't locate any binaries for $($project.Name)"
return
}
$expression = ConvertTo-NuGetExpression -nuspecPath $nuspecPath -wpfVersion $wpfVersion -uwpVersion $uwpVersion
Invoke-Command $expression
}
if(Test-Path ./Source)
{
$returnPath = "../.."
Set-Location ./Source/nuspecs
}
if (!(Test-Path $nugetFileName))
{
Write-Host 'Downloading Nuget.exe ...'
Invoke-WebRequest -Uri "http://nuget.org/nuget.exe" -OutFile $nugetFileName
}
$projectsJson = Get-Content -Raw -Path projects.json | ConvertFrom-Json
$coreFileVersion = Get-FileVersion -assemblyPath $projectsJson.Core
if($IsWindows -or $PSEdition -eq "Desktop")
{
foreach ($project in $projectsJson.Projects)
{
Write-Host "Building package for $($project.Name)"
Save-NuGetPackage -project $project
}
}
else
{
Write-Host "This script must be executed on Windows"
}
if($returnPath)
{
Set-Location $returnPath
}
|