Hello,
We have Octopus projects that deploy octopacked nuget packages (using deploy nuget package step). The package contains a windows service which is installed, then started in a later step.
The application that is deployed supports dynamically loading libraries. On some environments we want the libraries to be deployed (and so loaded) in others they should not be deployed.
What is the best approach to do this?
Ideally we would also like to make use of the Skip any package step that is already installed feature to keep the overall deploy time as low as possible.
Thank you,
Andrei Scutariu
Hi Andrei,
Thanks for getting in touch! The best approach is to have two package steps, one being your packaged libraries. You can specify which environment this package step should be run in by using the Run only for specific environments
option in your package step’s Conditions
section (refer to my attached screenshot showing this option). That will force this step to only deploy this package when deploying to one of your selected environments.
I hope this helps! Let me know if you have any further questions.
Best regards,
Kenny
Hi, thank for your answer. I have two new question.
-
How do you recommend deploying the binaries from the second package into the directory of the first package? (Currently we use Custom install directory on the packaged libraries step).
-
How this will behave when using “Skip any package step that is already installed feature”. The version of both packages (main and libraries) are changed differently.
[Scenario]" If the version of first package is changed and the version of the libraries doesn’t, the libraries packages is not deployed, therefore the libraries are not deployed in the first package.
What is your recommendation of using “Skip any package step that is already installed feature” in this situation.
Thank you.
Hi Andrei,
That’s no problem! Thanks for following up. Based on what you’ve described, I would recommend using an output variable to define the path. Output variables are created during your deployment process, and they can be used in subsequent steps in your deployment process. You can refer to our documentation for additional information: https://octopus.com/docs/deploying-applications/variables/system-variables#Systemvariables-Output
Specifically in your scenario, when your first package step runs, an output variable is created for the installation directory for this package. This variable is Octopus.Action[YourStepName].Output.Package.InstallationDirectoryPath
, and using it allows you to define the directory in which your 2nd package will install to be the same directory as your first package. Refer to my attached screenshot showing this variable being used as the custom install directory on my second package step.
Keep in mind that this output variable will not be available if the first package step is skipped as it is only created when that step runs. So it will require both of your package steps to be run on each deployment.
Alternatively, you can use a postdeploy PowerShell script to copy the files. A postdeploy script can be included in your package, in which Calamari will detect and invoke it. You can also define a postdeploy script in your package step using the Custom deployment scripts
feature. Refer to our documentation here for more info on this option: https://octopus.com/docs/deploying-applications/custom-scripts#Customscripts-ScriptsinPackagesscripts-in-packages
I hope this helps! Let me know if you have any further questions.
Best regards,
Kenny