Skip to content

Commit

Permalink
add parameter to replace versionnumber (#3240)
Browse files Browse the repository at this point in the history
Fixes #3229

---------

Co-authored-by: freddydk <[email protected]>
  • Loading branch information
freddydk and freddydk committed Nov 21, 2023
1 parent 8cddf2d commit 97be452
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions AppHandling/Replace-DependenciesInAppFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
An Array of hashtable, containing id, name and publisher of an app, which should be added to internals Visible to
.Parameter showMyCode
With this parameter you can change or check ShowMyCode in the app file. Check will throw an error if ShowMyCode is False.
.Parameter replacePackageId
Add this switch to replace the package id of the app file with a new GUID
.Parameter replaceVersionNumber
Add this parameter to replace the version number of the app file with this version number
.Example
Replace-DependenciesInAppFile -containerName test -Path c:\temp\myapp.app -replaceDependencies @{ "437dbf0e-84ff-417a-965d-ed2bb9650972" = @{ "id" = "88b7902e-1655-4e7b-812e-ee9f0667b01b"; "name" = "MyBaseApp"; "publisher" = "Freddy Kristiansen"; "minversion" = "1.0.0.0" }}
.Example
Expand All @@ -28,6 +32,7 @@ Function Replace-DependenciesInAppFile {
[ValidateSet('Ignore','True','False','Check')]
[string] $ShowMyCode = "Ignore",
[switch] $replacePackageId,
[string] $replaceVersionNumber,
[HashTable[]] $internalsVisibleTo = $null
)

Expand All @@ -39,7 +44,7 @@ try {
$path = $Destination
}

Invoke-ScriptInBCContainer -containerName $containerName -scriptBlock { Param($path, $Destination, $replaceDependencies, $ShowMyCode, $replacePackageId, $internalsVisibleTo)
Invoke-ScriptInBCContainer -containerName $containerName -scriptBlock { Param($path, $Destination, $replaceDependencies, $ShowMyCode, $replacePackageId, $replaceVersionNumber, $internalsVisibleTo)

add-type -path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service\system.io.packaging.dll").FullName

Expand Down Expand Up @@ -155,13 +160,19 @@ try {
}
}

if ($replaceVersionNumber) {
Write-Host "Replacing Version Number with $replaceVersionNumber"
$manifest.Package.App.Version = $replaceVersionNumber
$manifestChanges = $true
}

if ($replacePackageId) {
Write-Host "Replacing Package ID with new GUID"
$packageId = [Guid]::NewGuid()
$manifestChanges = $true
}

if ($manifestChanges) {

$partStream = $manifestPart.GetStream([System.IO.FileMode]::Create)
$manifest.Save($partStream)
$partStream.Flush()
Expand Down Expand Up @@ -208,7 +219,7 @@ try {
$fs.Close()
}
}
} -argumentList (Get-BCContainerPath -containerName $containerName -path $path -throw), (Get-BCContainerPath -containerName $containerName -path $Destination -throw), $replaceDependencies, $ShowMyCode, $replacePackageId, $internalsVisibleTo
} -argumentList (Get-BCContainerPath -containerName $containerName -path $path -throw), (Get-BCContainerPath -containerName $containerName -path $Destination -throw), $replaceDependencies, $ShowMyCode, $replacePackageId, $replaceVersionNumber, $internalsVisibleTo
}
catch {
TrackException -telemetryScope $telemetryScope -errorRecord $_
Expand Down
3 changes: 2 additions & 1 deletion ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ New-AppSourceSubmission obsoleted parameter -doNotCheckVersionNumber that was pr
Issue 3219 Run-AlValidation cannot validate against Next Major without an insider Sas token
Do not attempt to call Get-BcContainerAppInfo if we are using filesonly containers in Run-AlPipeline
Do not attempt to download unknown symbols from filesonly containers
Add paramater generateErrorLog to Compile-AppInNavContainer
Add parameter generateErrorLog to Compile-AppInNavContainer
Issue 3229 Add parameter replaceVersionNumber to Replace-DependenciesInAppFile

6.0.0
Add parameter -accept_insiderEULA on New-BcContainer, Get-BcArtifactUrl and Run-AlPipeline to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) instead of using the insider SAS token.
Expand Down

0 comments on commit 97be452

Please sign in to comment.