# Project with multiple steps installed to one location

I’ve searched the board for this question but surprisingly haven’t come up with the answer I’m looking for. I have a project with a multiple steps (i.e. packages) that I would like to install in the same directory. Right now the the packages are being installed as follows:

Client code: <environment><client><version>\content…
Core code: <environment><core><version>\content…

What am I missing?

Ideally, in the future we’ll have a single install of the core code and all client code references the single install of core code but we’re not there yet. The core and client code need to be installed in the same location.

Hi Troy,

Thanks for the question. One option is to use the special variable OctopusPackageDirectoryPath, which you can find out more about on this page:

http://octopusdeploy.com/documentation/features/variables

This will allow the contents of both packages to be copied to a single location.

However, this location won’t include the version number, so the files will be copied over the top of each other each deployment.

Another option would be to have Core installed to a single place (using OctopusPackageDirectoryPath), and then have a PowerShell script in the client code which manually copies the files from that location to the folder of the current Client package.

Assuming “Core” contains a set of DLL’s, it’s more common for people to simply bundle those DLL’s into the “Client” package, so that they are in the right location when Client is extracted. If you haven’t seen it already, there’s some more information on how Octopus expects NuGet packages to be structured here:

Hope this helps,

Paul

Thanks Paul. One further question. Can I use a predefined variable (i.e. OctopusPackageVersion) as part of the OctopusPackageDirectoryPath variable?

OctopusPackageDirectoryPath = \website<package>\OctopusPackageVersion

Troy

Hi Troy,

Not currently, but it is part of the project backlog for an upcoming release:

https://trello.com/card/variable-substitutions/4e907de70880ba000079b75c/12

However, you could use both variables in a custom PowerShell script to copy the files to where they need to go.

Paul

Paul,

I’ve decided to use PowerShell to copy the core files to the client location as an interim solution until I can modify the NuGet package. Having a problem though. I have the following text in deploy.ps1.

copyCoreToClient

function copyCoreToClient
{
Write-Host “Copying core”;
}

I’m getting the following error:

The term ‘copyCoreToClient’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Do I need to use an include file? I’ve set the execution policy to unrestricted.

Troy

Hi Troy,

You’ll need to call the function after defining it first, switching the order should work:

function copyCoreToClient
{
write-host "Copying core..."
Copy-Item c:\path\to\core .\ -recurse
}

copyCoreToClient


Hope that helps,

Paul

Paul,

My bad. I’m used to using PowerShell ISE. Anyway, you suggestion worked perfectly.

Another question. I’m using PowerShell to copy the Core code to the Client installation directory. Core and Client are two separate packages (i.e. steps). Deploy.ps1 is in the Client package. How can I get the path where Core was installed so I can copy the files to Client?

Thanks,
Troy

One option is to set OctopusPackageDirectoryPath on the Core project so that it is copied into a fixed folder path (e.g., C:\Core). Then you can reference that fixed path from the Deploy.ps1 in Client.

The other would be to ‘guess’ based on assumptions about where Octopus installs packages - e.g., something like this might work:

$corePath = (gci ..\..\Core | ? {$_.PSIsContainer } | sort CreationTime)[-1]
copy-item ($corePath.FullName) .\ -recurse  That said, this is all feeling a little complicated. Is it possible for you to include the assemblies of Core into the Client NuGet package? An application package really should contain all of the files needed to make the application run. After all I presume versions of Client make assumptions about the version of Core that is used? Paul I agree with your assertion our process was getting complicated. My team met and we’ve simplified the process tremendously. Core will now be installed to a single location on the server and the client code will reference the core code. On that note. Should the$OctopusPackageDirectoryPath variable null/empty in PreDeploy.ps1 unless explicitly set? For example, the following returns “\Dev\GeneralHospital\2012.3.57.4311\content”. It should be “w:\websites\Dev\GeneralHospital\2012.3.57.4311\content”.

$clientPath = "$OctopusPackageDirectoryPath\$OctopusEnvironmentName\$OctopusPackageName\$OctopusPackageVersion\content" Hi Troy, OctopusPackageDirectoryPath will only be populated when set manually. However, you can get the current path using: $clientPath = (resolve-path .\content)


Hope that helps,

Paul

We are using octopus for several deployments in several environments. We have a unique code that has to be deployed in every environment. is there a way in octopus to deploy few files to one directory and few to other in the same server?

Hi @chinnu,

Thanks for reaching out! The only way to do this would be through a post deploy script on the package step that uses copy-item to move the files to the right directories.

Best regards,
Dalmiro