Skip to content

Commit

Permalink
Merge pull request #4511 from Microsoft/users/biprasad/HandleNoOldApp…
Browse files Browse the repository at this point in the history
…Manifest

Handle non existence of app manifest in older build
  • Loading branch information
bishal-pdMSFT authored Jun 14, 2017
2 parents a032179 + 29ab41a commit 68c2cb4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"loc.messages.PreviousBuildNumberLabel": "Previous build number: '{0}'",
"loc.messages.PreviousBuildLocationLabel": "Previous build location: '{0}'",
"loc.messages.NoPreviousSuccessfulBuild": "Could not find previous build to compare against.",
"loc.messages.NoManifestInPreviousBuild": "Previous build does not contains application manifest. Force updating all manifest versions.",
"loc.messages.UpdatedApplicationTypeVersion": "Updated application type '{0}' to version '{1}'.",
"loc.messages.UpdatedServiceVerison": "Updated service '{0}' to version '{1}'.",
"loc.messages.UpdatedPackageVerison": "Updated package '{0}\\{1}' to version '{2}'.",
Expand Down
3 changes: 3 additions & 0 deletions Tasks/ServiceFabricUpdateAppVersions/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ describe('ServiceFabricUpdateAppVersions Suite', function () {
it('(Update-ApplicationVersions) app version prefix changed', (done) => {
psr.run(path.join(__dirname, 'Update-ApplicationVersions.VersionPrefixChanged.ps1'), done);
})
it('(Update-ApplicationVersions) old app manifest not found', (done) => {
psr.run(path.join(__dirname, 'Update-ApplicationVersions.OldManifestNotFound.ps1'), done);
})
it('(Update-ServiceVersions) no changes', (done) => {
psr.run(path.join(__dirname, 'Update-ServiceVersions.NoChanges.ps1'), done);
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[CmdletBinding()]
param()

. "$PSScriptRoot\Test-ApplicationVersions.ps1" PreviousPackageNoManifest
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ try {

$oldAppPackagePath = Join-Path $oldDropLocation $newAppPackagePath.SubString((Get-VstsTaskVariable -Name Build.SourcesDirectory -Require).Length + 1)
$oldAppManifestPath = Join-Path $oldAppPackagePath $appManifestName
$oldAppManifestXml = [XML](Get-Content $oldAppManifestPath)

# Set the version to the version from the previous build (including its suffix). This will be overwritten if we find any changes, otherwise it will match the previous build by design.
# Set it before we search for changes so that we can compare the xml without the old version suffix causing a false positive.
$newAppManifestXml.ApplicationManifest.ApplicationTypeVersion = $oldAppManifestXml.ApplicationManifest.ApplicationTypeVersion
if (Test-Path $oldAppManifestPath)
{
$oldAppManifestXml = [XML](Get-Content $oldAppManifestPath)

# Set the version to the version from the previous build (including its suffix). This will be overwritten if we find any changes, otherwise it will match the previous build by design.
# Set it before we search for changes so that we can compare the xml without the old version suffix causing a false positive.
$newAppManifestXml.ApplicationManifest.ApplicationTypeVersion = $oldAppManifestXml.ApplicationManifest.ApplicationTypeVersion
}
else
{
Write-Warning (Get-VstsLocString -Key NoManifestInPreviousBuild)
$updateAllVersions = $true
}
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion Tasks/ServiceFabricUpdateAppVersions/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 1,
"Minor": 1,
"Patch": 9
"Patch": 10
},
"minimumAgentVersion": "1.95.0",
"instanceNameFormat": "Update Service Fabric App Versions",
Expand Down Expand Up @@ -120,6 +120,7 @@
"PreviousBuildNumberLabel": "Previous build number: '{0}'",
"PreviousBuildLocationLabel": "Previous build location: '{0}'",
"NoPreviousSuccessfulBuild": "Could not find previous build to compare against.",
"NoManifestInPreviousBuild": "Previous build does not contains application manifest. Force updating all manifest versions.",
"UpdatedApplicationTypeVersion": "Updated application type '{0}' to version '{1}'.",
"UpdatedServiceVerison": "Updated service '{0}' to version '{1}'.",
"UpdatedPackageVerison": "Updated package '{0}\\{1}' to version '{2}'.",
Expand Down
3 changes: 2 additions & 1 deletion Tasks/ServiceFabricUpdateAppVersions/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 1,
"Minor": 1,
"Patch": 9
"Patch": 10
},
"minimumAgentVersion": "1.95.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -120,6 +120,7 @@
"PreviousBuildNumberLabel": "ms-resource:loc.messages.PreviousBuildNumberLabel",
"PreviousBuildLocationLabel": "ms-resource:loc.messages.PreviousBuildLocationLabel",
"NoPreviousSuccessfulBuild": "ms-resource:loc.messages.NoPreviousSuccessfulBuild",
"NoManifestInPreviousBuild": "ms-resource:loc.messages.NoManifestInPreviousBuild",
"UpdatedApplicationTypeVersion": "ms-resource:loc.messages.UpdatedApplicationTypeVersion",
"UpdatedServiceVerison": "ms-resource:loc.messages.UpdatedServiceVerison",
"UpdatedPackageVerison": "ms-resource:loc.messages.UpdatedPackageVerison",
Expand Down

0 comments on commit 68c2cb4

Please sign in to comment.