We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

gielians
Posts: 2
Joined: Fri Jul 26, 2024 2:26 pm

Never Override in PS affects more components than selected

Hi,
although this is my first post here I am using Advanced Installer within our build pipelines for more than 3 Years now, and we are quite happy with it.
In this case we use the Powershell component to fill an existing "template" project with files, components, services, etc. and build an exe installer.

Now we wanted to make some config files "Permanent" and "NeverOrverride" to create them on a fresh install and keep them as they came from the fresh install.

Here is the code block handling this.

Code: Select all

"Set files to never overwrite"
$nonoverwritefiles = $advproj.FilesComponent.Files.Where({ $_.Name -eq "appsettings.json" })
$nonoverwritefiles.Add($advproj.FilesComponent.Files.Where({ $_.Name -eq "config.json" }))
foreach ($file in $nonoverwritefiles) {
  "Set NeverOverwrite for $($file.FullPath)"
  $file.Component.NeverOverwrite = 1
  $file.Component.Permanent = 1
}
This works fine for the files we want to keep (all "appsettings.json" and "config.json" files), but it also affects all other ".json" files that are located within the folder of one of the "appsettings.json" or "config.json" files.
.json files that do not have a "appsettings.json" or "config.json" file placed beside in the same folder are not affected and deleted/ovewritten as expected.

The log only shows changes made to the correct files

Code: Select all

Set Files to never overwrite
Set NeverOverwrite for APPDIR\ContentServer\appsettings.json
Set NeverOverwrite for APPDIR\Manager\appsettings.json
Set NeverOverwrite for APPDIR\LiveSession\appsettings.json
Set NeverOverwrite for APPDIR\AssetStorage\config.json
Deleting the whole code block from the script makes all ".json" files be deleted/overwritten again (as expected).
I really don't see why the other files are affected by the changed made to components of other files.
Maybe some of you see the mistake right away, thanks for you help, Eric
gielians
Posts: 2
Joined: Fri Jul 26, 2024 2:26 pm

Re: Never Override in PS affects more components than selected

Code: Select all

"Set Files to never overwrite"
$nonoverwritefiles = $advproj.FilesComponent.Files.Where({ $_.Name -eq "appsettings.json" -or  $_.Name -eq "config.json"})
foreach ($file in $nonoverwritefiles) {
  "Set NeverOverwrite for $($file.FullPath)"
  $file.OverwriteType = "no"  
}
fixed it
the changed had to be made to the file directly not to the component of the file because the component also includes other files
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Never Override in PS affects more components than selected

Hello and welcome to our forums,

Thank you for posting a followup on this!

I am glad to hear everything is working as expected now and I'm sure this solution will be of help for further users facing a similar scenario.

If you require any further assistance, please do not hesitate to contact us and I will gladly assist.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”