@@ -34,10 +34,23 @@ Write-Host ("Powershell script location is " + $PSScriptRoot)
34
34
35
35
$ReactiveDomainDll = $PSScriptRoot + " \..\bld\Release\net472\ReactiveDomain.Core.dll"
36
36
$RDVersion = (Get-Item $ReactiveDomainDll ).VersionInfo.FileVersion
37
+
37
38
$ReactiveDomainNuspec = $PSScriptRoot + " \..\src\ReactiveDomain.nuspec"
39
+ $RDFoundationProject = $PSScriptRoot + " \..\src\ReactiveDomain.Foundation\ReactiveDomain.Foundation.csproj"
40
+ $RDMessagingProject = $PSScriptRoot + " \..\src\ReactiveDomain.Messaging\ReactiveDomain.Messaging.csproj"
41
+ $RDPersistenceProject = $PSScriptRoot + " \..\src\ReactiveDomain.Persistence\ReactiveDomain.Persistence.csproj"
42
+ $RDPrivateLedgerProject = $PSScriptRoot + " \..\src\ReactiveDomain.PrivateLedger\ReactiveDomain.PrivateLedger.csproj"
43
+ $RDTransportProject = $PSScriptRoot + " \..\src\ReactiveDomain.Transport\ReactiveDomain.Transport.csproj"
44
+
38
45
$ReactiveDomainTestingNuspec = $PSScriptRoot + " \..\src\ReactiveDomain.Testing.nuspec"
46
+ $ReactiveDomainTestingProject = $PSScriptRoot + " \..\src\ReactiveDomain.Testing\ReactiveDomain.Testing.csproj"
47
+
39
48
$ReactiveDomainUINuspec = $PSScriptRoot + " \..\src\ReactiveDomain.UI.nuspec"
49
+ $RDUIProject = $PSScriptRoot + " \..\src\ReactiveDomain.UI\ReactiveDomain.UI.csproj"
50
+
40
51
$ReactiveDomainUITestingNuspec = $PSScriptRoot + " \..\src\ReactiveDomain.UI.Testing.nuspec"
52
+ $RDUITestingProject = $PSScriptRoot + " \..\src\ReactiveDomain.UI.Testing\ReactiveDomain.UI.Testing.csproj"
53
+
41
54
$nuget = $PSScriptRoot + " \..\src\.nuget\nuget.exe"
42
55
43
56
Write-Host (" Reactive Domain version is " + $RDVersion )
@@ -48,37 +61,193 @@ Write-Host ("ReactiveDomain.UI nuspec file is " + $ReactiveDomainUINuspec)
48
61
Write-Host (" ReactiveDomain.UI.Testing nuspec file is " + $ReactiveDomainUITestingNuspec )
49
62
Write-Host (" Branch is file is " + $branch )
50
63
51
- function UpdateDependencyVersions ([string ]$Nuspec )
64
+ class PackagRef
65
+ {
66
+ [string ]$Version
67
+ [string ]$ComparisonOperator
68
+ [string ]$Framework
69
+ }
70
+
71
+ # GetPackageRefFromProject
72
+ #
73
+ # Helper function to get a specific PackageRef from a .csproj file
74
+ # Parses and returns a PackagRef object (defined above) that contains:
75
+ # Version - (version of the package)
76
+ # ConditionOperator - (the equality operator for a framework, == or !=)
77
+ # Framework - The framework this Packageref applies to: (net452, net472, netstandard2.0)
78
+ #
79
+ function GetPackageRefFromProject ([string ]$Id , [string ]$CsProj , [string ]$Framework )
52
80
{
81
+ [xml ]$xml = Get-Content - Path $CsProj - Encoding UTF8
82
+
83
+ $Xpath = " //Project/ItemGroup/PackageReference[@Include='" + $Id + " ']"
84
+ $targetPackage = $xml | Select-XML - XPath $Xpath
85
+ $currentCondition = " "
86
+ $compOperator = " "
87
+ $currentFramework = " "
88
+ $currentVersion = " "
89
+
90
+ # There may be duplicates of the same package when there are different versions
91
+ # for different frameworks (i.e. ReactiveUI). Therefore if our search
92
+ # returns more than one node, then we take the one that matches
93
+ # the Framework in its Condition
94
+
95
+ if ($targetPackage.Node.Count -gt 1 )
96
+ {
97
+ foreach ($tn in $targetPackage.Node )
98
+ {
99
+ if ($tn.Condition -match $Framework )
100
+ {
101
+ $currentCondition = $tn.Condition
102
+ $currentVersion = $tn.Version
103
+ }
104
+ }
105
+ }
106
+ else
107
+ {
108
+ $currentCondition = $targetPackage.Node.Condition
109
+ $currentVersion = $targetPackage.Node.Version
110
+ }
111
+
112
+ if ($currentCondition -match " ==" )
113
+ {
114
+ $compOperator = " =="
115
+ }
116
+
117
+ if ($currentCondition -match " !=" )
118
+ {
119
+ $compOperator = " !="
120
+ }
121
+
122
+ if ($currentCondition -match " net452" )
123
+ {
124
+ $currentFramework = " net452"
125
+ }
53
126
127
+ if ($currentCondition -match " net472" )
128
+ {
129
+ $currentFramework = " net472"
130
+ }
131
+
132
+ if ($currentCondition -match " netstandard2.0" )
133
+ {
134
+ $currentFramework = " netstandard2.0"
135
+ }
136
+
137
+ $myObj = New-Object - TypeName PackagRef
138
+ $myObj.Version = $currentVersion
139
+ $myObj.ComparisonOperator = $compOperator
140
+ $myObj.Framework = $currentFramework
141
+
142
+ return $myObj
143
+ }
144
+
145
+ # UpdateDependencyVersions
146
+ #
147
+ # Helper function that updates all non-ReactiveDomain dependencies
148
+ # in a nuspec file. Loops through all dependencies listed in a
149
+ # nuspec file and gets the versions from its
150
+ # entry in the corresponding .csproj file
151
+ #
152
+ function UpdateDependencyVersions ([string ]$Nuspec , [string ]$CsProj )
153
+ {
54
154
Write-Host " Updating dependency versions of: " $Nuspec
55
155
56
- [xml ]$xml = Get-Content - Path $Nuspec
156
+ [xml ]$xml = Get-Content - Path $Nuspec - Encoding UTF8
57
157
$dependencyNodes = $xml.package.metadata.dependencies.group.dependency
58
158
59
- foreach ($node in $dependencyNodes )
159
+
160
+ $f452 = $xml | Select-XML - XPath " //package/metadata/dependencies/group[@targetFramework='.NETFramework4.5.2']"
161
+ $framework452Nodes = $f452.Node.ChildNodes
162
+
163
+ $f472 = $xml | Select-XML - XPath " //package/metadata/dependencies/group[@targetFramework='.NETFramework4.7.2']"
164
+ $framework472Nodes = $f472.Node.ChildNodes
165
+
166
+ $netstandard2 = $xml | Select-XML - XPath " //package/metadata/dependencies/group[@targetFramework='.NETStandard2.0']"
167
+ $netstandard2Nodes = $netstandard2.Node.ChildNodes
168
+
169
+ foreach ($refnode in $framework452Nodes )
60
170
{
61
- if ($node .id.Contains ( " ReactiveDomain" ) )
171
+ if ( $refnode .id -match " ReactiveDomain" )
62
172
{
63
- $node.version = $RDVersion
173
+ $refnode.version = $RDVersion
174
+ continue
64
175
}
176
+
177
+ $pRef = GetPackageRefFromProject $refnode.id $CsProj " net452"
178
+ if ((($pRef.ComparisonOperator -eq " " -or $pRef.Framework -eq " " ) -or
179
+ ($pRef.ComparisonOperator -eq " ==" -and $pRef.Framework -eq " net452" ) -or
180
+ ($pRef.ComparisonOperator -eq " !=" -and $pRef.Framework -ne " net452" )) -and
181
+ ($pRef.version -ne " " ))
182
+ {
183
+ $refnode.version = $pRef.Version
184
+ }
65
185
}
66
- $xml.Save ($Nuspec )
67
186
68
- Write-Host " Updated dependency versions of: $Nuspec "
187
+ foreach ($refnode in $framework472Nodes )
188
+ {
189
+ if ( $refnode.id -match " ReactiveDomain" )
190
+ {
191
+ $refnode.version = $RDVersion
192
+ continue
193
+ }
194
+
195
+ $pRef = GetPackageRefFromProject $refnode.id $CsProj " net472"
196
+ if ((($pRef.ComparisonOperator -eq " " -or $pRef.Framework -eq " " ) -or
197
+ ($pRef.ComparisonOperator -eq " ==" -and $pRef.Framework -eq " net472" ) -or
198
+ ($pRef.ComparisonOperator -eq " !=" -and $pRef.Framework -ne " net472" )) -and
199
+ ($pRef.version -ne " " ))
200
+ {
201
+ $refnode.version = $pRef.Version
202
+ }
203
+ }
204
+
205
+ foreach ($refnode in $netstandard2Nodes )
206
+ {
207
+ if ( $refnode.id -match " ReactiveDomain" )
208
+ {
209
+ $refnode.version = $RDVersion
210
+ continue
211
+ }
212
+
213
+ $pRef = GetPackageRefFromProject $refnode.id $CsProj " netstandard2.0"
214
+ if ((($pRef.ComparisonOperator -eq " " -or $pRef.Framework -eq " " ) -or
215
+ ($pRef.ComparisonOperator -eq " ==" -and $pRef.Framework -eq " netstandard2.0" ) -or
216
+ ($pRef.ComparisonOperator -eq " !=" -and $pRef.Framework -ne " netstandard2.0" )) -and
217
+ ($pRef.version -ne " " ))
218
+ {
219
+ $refnode.version = $pRef.Version
220
+ }
221
+ }
222
+
223
+ $xml.Save ($Nuspec )
224
+ Write-Host " Updated dependency versions of: $Nuspec "
69
225
}
70
226
227
+ # Make the nuget.exe update itself (We must be at least at nuget 5.0 for this all to work) **************
71
228
& $nuget update - self
72
229
73
- # Update the corresponding ReactiveDomain dependency versions in the nuspec files ***********************************************
230
+ # Update the dependency versions in the nuspec files ***** ***********************************************
74
231
75
- UpdateDependencyVersions($ReactiveDomainTestingNuspec )
76
- UpdateDependencyVersions($ReactiveDomainUINuspec )
77
- UpdateDependencyVersions($ReactiveDomainUITestingNuspec )
232
+ # These all go into updating the main ReactiveDomain.nuspec
233
+ UpdateDependencyVersions $ReactiveDomainNuspec $RDFoundationProject
234
+ UpdateDependencyVersions $ReactiveDomainNuspec $RDMessagingProject
235
+ UpdateDependencyVersions $ReactiveDomainNuspec $RDPersistenceProject
236
+ UpdateDependencyVersions $ReactiveDomainNuspec $RDPrivateLedgerProject
237
+ UpdateDependencyVersions $ReactiveDomainNuspec $RDTransportProject
78
238
79
- # *******************************************************************************************************************************
239
+ # These go into updating the ReactiveDomainUI.nuspec
240
+ UpdateDependencyVersions $ReactiveDomainUINuspec $RDUIProject
241
+
242
+ # These go into updating the ReactiveDomainTesting.nuspec
243
+ UpdateDependencyVersions $ReactiveDomainTestingNuspec $ReactiveDomainTestingProject
244
+
245
+ # These go into updating the ReactiveDomain.UI.Testing.nuspec
246
+ UpdateDependencyVersions $ReactiveDomainUITestingNuspec $RDUITestingProject
247
+
248
+ # *******************************************************************************************************
80
249
81
- # Pack the nuspec files to create the .nupkg files using the set versionString *************************************************
250
+ # Pack the nuspec files to create the .nupkg files using the set versionString *************************
82
251
$versionString = $RDVersion
83
252
& $nuget pack $ReactiveDomainNuspec - Version $versionString
84
253
& $nuget pack $ReactiveDomainTestingNuspec - Version $versionString
0 commit comments