Search code examples
chocolatey

Install files by copying to specific folder


I have build artifacts in a folder (e.g. FolderTest) that needs to be deployed to a specific folders locations on Windows such as:

C:
  FolderA
      FileA
      FileB
      FolderB
          FileC
          FolderC
             FilesD

Is it possible to use Chocolatey to deploy, copy files to different locations and maintain a software in that similar structure so that I can do upgrades, installs, rollbacks? Or should I even not use a package manager or use a different tool.


Solution

  • The main installation script that is part of a Chocolatey Package, i.e. the chocolateyInstall.ps1 file, is a PowerShell Script. i.e. you can do anything that you want within that script, and that script will be executed when the package is installed. There is also the chocolateyUninstall.ps1 file, that can be used for removing the files that have been installed.

    One other script that you can make use of is the chocolateyBeforeModify.ps1 file, which is used before uninstallation/upgrade. This would allow you to take any actions, for example stopping services before the uninstallation or the upgrade of the package.

    So, bottom line, there is nothing to stop you putting the hierarchy that you mention in place, it would just mean that you would need to do the work in the installation scripts, to place the files into the correct locations on disk.