31
31
Template to calculate the id of the dependencies
32
32
The template can contain {id}, {name} and {publisher} which will be replaced with the values from the corresponding dependency from app.json
33
33
The default is '{publisher}.{name}.{id}'
34
+ . Parameter dependencyVersionTemplate
35
+ Template to calculate the version field of the dependencies, default is {version}
36
+ The template can contain {version} which will be replaced with the verson from the corresponding dependency from app.json
37
+ The template can also contain {major},{minor},{build} and {revision} which will be replaced with the fields from the version
38
+ The template can also contain {major+1},{minor+1},{build+1} and {revision+1} which will be replaced with the fields from the version incremented by 1
39
+ . Parameter applicationDependencyId
40
+ Id of the application dependency
41
+ The default is 'Microsoft.Application'
42
+ . Parameter applicationDependency
43
+ Version/Template of the application dependency, default is the Application version from the app.json file
44
+ The template can contain {version} which will be replaced with the verson from the corresponding dependency from app.json
45
+ The template can also contain {major},{minor},{build} and {revision} which will be replaced with the fields from the version
46
+ The template can also contain {major+1},{minor+1},{build+1} and {revision+1} which will be replaced with the fields from the version incremented by 1
47
+ . Parameter platformDependencyId
48
+ Id of the platform dependency
49
+ The default is 'Microsoft.Platform'
50
+ . Parameter platformDependency
51
+ Version/Template of the platform dependency, default is the Platform version from the app.json file
52
+ The template can contain {version} which will be replaced with the verson from the corresponding dependency from app.json
53
+ The template can also contain {major},{minor},{build} and {revision} which will be replaced with the fields from the version
54
+ The template can also contain {major+1},{minor+1},{build+1} and {revision+1} which will be replaced with the fields from the version incremented by 1
34
55
. Parameter destinationFolder
35
56
Folder to create the NuGet package in. Defeault it to create a temporary folder and delete it after the NuGet package has been created
36
57
. Example
@@ -62,12 +83,16 @@ Function New-BcNuGetPackage {
62
83
[Parameter (Mandatory = $false )]
63
84
[string ] $dependencyIdTemplate = ' {publisher}.{name}.{id}' ,
64
85
[Parameter (Mandatory = $false )]
86
+ [string ] $dependencyVersionTemplate = ' {version}' ,
87
+ [Parameter (Mandatory = $false )]
65
88
[string ] $applicationDependencyId = ' Microsoft.Application' ,
66
89
[Parameter (Mandatory = $false )]
67
90
[string ] $applicationDependency = ' ' ,
68
91
[Parameter (Mandatory = $false )]
69
92
[string ] $platformDependencyId = ' Microsoft.Platform' ,
70
93
[Parameter (Mandatory = $false )]
94
+ [string ] $platformDependency = ' ' ,
95
+ [Parameter (Mandatory = $false )]
71
96
[string ] $runtimeDependencyId = ' {publisher}.{name}.runtime-{version}' ,
72
97
[switch ] $isIndirectPackage ,
73
98
[Parameter (Mandatory = $false )]
@@ -81,6 +106,10 @@ Function New-BcNuGetPackage {
81
106
$stream.Write ($bytes , 0 , $bytes.Length )
82
107
}
83
108
109
+ function GetDependencyVersionStr ([string ] $template , [System.Version ] $version ) {
110
+ return $template.Replace (' {version}' , " $version " ).Replace(' {major}' , $version.Major ).Replace(' {minor}' , $version.Minor ).Replace(' {build}' , $version.Build ).Replace(' {revision}' , $version.Revision ).Replace(' {major+1}' , ($version.Major + 1 )).Replace(' {minor+1}' , ($version.Minor + 1 )).Replace(' {build+1}' , ($version.Build + 1 )).Replace(' {revision+1}' , ($version.Revision + 1 ))
111
+ }
112
+
84
113
Write-Host " Create NuGet package"
85
114
Write-Host " AppFile:"
86
115
Write-Host $appFile
@@ -134,10 +163,21 @@ Function New-BcNuGetPackage {
134
163
if (-not $packageAuthors ) {
135
164
$packageAuthors = $appJson.publisher
136
165
}
137
- if (-not $applicationDependency ) {
138
- if ($appJson .PSObject.Properties.Name -eq ' Application ' -and $appJson .Application ) {
166
+ if ($appJson .PSObject.Properties.Name -eq ' Application ' -and $appJson .Application ) {
167
+ if (-not $applicationDependency ) {
139
168
$applicationDependency = $appJson.Application
140
169
}
170
+ else {
171
+ $applicationDependency = GetDependencyVersionStr - template $applicationDependency - version ([System.Version ]::Parse($appJson.Application ))
172
+ }
173
+ }
174
+ if ($appJson.PSObject.Properties.Name -eq ' Platform' -and $appJson.Platform ) {
175
+ if (-not $platformDependency ) {
176
+ $platformDependency = $appJson.Platform
177
+ }
178
+ else {
179
+ $platformDependency = GetDependencyVersionStr - template $platformDependency - version ([System.Version ]::Parse($appJson.Platform ))
180
+ }
141
181
}
142
182
143
183
if ($prereleaseTag ) {
@@ -182,7 +222,7 @@ Function New-BcNuGetPackage {
182
222
$id = Get-BcNuGetPackageId - packageIdTemplate $dependencyIdTemplate - publisher $_.publisher - name $_.name - id $dependencyId - version $_.version.replace (' .' , ' -' )
183
223
$XmlObjectWriter.WriteStartElement (" dependency" )
184
224
$XmlObjectWriter.WriteAttributeString (" id" , $id )
185
- $XmlObjectWriter.WriteAttributeString (" version" , $ _.version )
225
+ $XmlObjectWriter.WriteAttributeString (" version" , (GetDependencyVersionStr - template $dependencyVersionTemplate - version ([ System.Version ]::Parse( $ _.version ))) )
186
226
$XmlObjectWriter.WriteEndElement ()
187
227
}
188
228
}
@@ -192,10 +232,10 @@ Function New-BcNuGetPackage {
192
232
$XmlObjectWriter.WriteAttributeString (" version" , $applicationDependency )
193
233
$XmlObjectWriter.WriteEndElement ()
194
234
}
195
- if ($appJson .PSObject.Properties.Name -eq ' Platform ' -and $appJson .Platform ) {
235
+ if ($platformDependency ) {
196
236
$XmlObjectWriter.WriteStartElement (" dependency" )
197
237
$XmlObjectWriter.WriteAttributeString (" id" , $platformDependencyId )
198
- $XmlObjectWriter.WriteAttributeString (" version" , $appJson .Platform )
238
+ $XmlObjectWriter.WriteAttributeString (" version" , $platformDependency )
199
239
$XmlObjectWriter.WriteEndElement ()
200
240
}
201
241
if ($isIndirectPackage.IsPresent ) {
0 commit comments