@@ -146,6 +146,45 @@ function Publish-UpgradedServiceFabricApplication
146146 throw $errMsg
147147 }
148148
149+ $ApplicationManifestPath = " $AppPkgPathToUse \ApplicationManifest.xml"
150+
151+ $names = Get-NamesFromApplicationManifest - ApplicationManifestPath $ApplicationManifestPath
152+ if (! $names )
153+ {
154+ return
155+ }
156+
157+ # If ApplicationName is not specified on command line get application name from Application parameter file.
158+ if (! $ApplicationName )
159+ {
160+ $ApplicationName = Get-ApplicationNameFromApplicationParameterFile $ApplicationParameterFilePath
161+ }
162+
163+ if (! $ApplicationName )
164+ {
165+ Write-Error (Get-VstsLocString - Key EmptyApplicationName)
166+ }
167+
168+ $oldApplication = Get-ServiceFabricApplication - ApplicationName $ApplicationName
169+ # # Check existence of the application
170+ if (! $oldApplication )
171+ {
172+ $errMsg = (Get-VstsLocString - Key SFSDK_AppDoesNotExist - ArgumentList $ApplicationName )
173+ throw $errMsg
174+ }
175+
176+ if ($oldApplication.ApplicationTypeName -ne $names.ApplicationTypeName )
177+ {
178+ $errMsg = (Get-VstsLocString - Key SFSDK_AppTypeMismatch - ArgumentList $ApplicationName )
179+ throw $errMsg
180+ }
181+
182+ if ($SkipUpgradeSameTypeAndVersion -And $oldApplication.ApplicationTypeVersion -eq $names.ApplicationTypeVersion )
183+ {
184+ Write-Warning (Get-VstsLocString - Key SFSDK_SkipUpgradeWarning - ArgumentList @ ($names.ApplicationTypeName , $names.ApplicationTypeVersion ))
185+ return
186+ }
187+
149188 # Get image store connection string
150189 $clusterManifestText = Get-ServiceFabricClusterManifest
151190 $imageStoreConnectionString = Get-ImageStoreConnectionStringFromClusterManifest ([xml ] $clusterManifestText )
@@ -160,8 +199,6 @@ function Publish-UpgradedServiceFabricApplication
160199 }
161200 }
162201
163- $ApplicationManifestPath = " $AppPkgPathToUse \ApplicationManifest.xml"
164-
165202 try
166203 {
167204 [void ](Test-ServiceFabricClusterConnection )
@@ -172,49 +209,9 @@ function Publish-UpgradedServiceFabricApplication
172209 throw
173210 }
174211
175- # If ApplicationName is not specified on command line get application name from Application parameter file.
176- if (! $ApplicationName )
177- {
178- $ApplicationName = Get-ApplicationNameFromApplicationParameterFile $ApplicationParameterFilePath
179- }
180-
181- if (! $ApplicationName )
182- {
183- Write-Error (Get-VstsLocString - Key EmptyApplicationName)
184- }
185-
186- $names = Get-NamesFromApplicationManifest - ApplicationManifestPath $ApplicationManifestPath
187- if (! $names )
188- {
189- return
190- }
191-
192212 $ApplicationTypeAlreadyRegistered = $false
193213 if ($Action.Equals (' RegisterAndUpgrade' ) -or $Action.Equals (' Register' ))
194214 {
195- # # Check existence of the application
196- $oldApplication = Get-ServiceFabricApplication - ApplicationName $ApplicationName
197-
198- if (! $oldApplication )
199- {
200- $errMsg = (Get-VstsLocString - Key SFSDK_AppDoesNotExist - ArgumentList $ApplicationName )
201- throw $errMsg
202- }
203- else
204- {
205- if ($oldApplication.ApplicationTypeName -ne $names.ApplicationTypeName )
206- {
207- $errMsg = (Get-VstsLocString - Key SFSDK_AppTypeMismatch - ArgumentList $ApplicationName )
208- throw $errMsg
209- }
210-
211- if ($SkipUpgradeSameTypeAndVersion -And $oldApplication.ApplicationTypeVersion -eq $names.ApplicationTypeVersion )
212- {
213- Write-Warning (Get-VstsLocString - Key SFSDK_SkipUpgradeWarning - ArgumentList @ ($names.ApplicationTypeName , $names.ApplicationTypeVersion ))
214- return
215- }
216- }
217-
218215 # # Check upgrade status
219216 $upgradeStatus = Get-ServiceFabricApplicationUpgrade - ApplicationName $ApplicationName
220217 if ($upgradeStatus.UpgradeState -ne " RollingBackCompleted" -and $upgradeStatus.UpgradeState -ne " RollingForwardCompleted" )
0 commit comments