Access extracted directory as a variable?

Hi,

I have a “WebDirectory” property in my appSettings config, its supposed to map to c:\inetpub…\ (where web.config is located etc).

I can’t see a way to automatically update this property using Variable transforms/replacement in the Variables section of Octopus.

I see http://help.octopusdeploy.com/discussions/questions/10-get-tentacle-application-path-in-variable was mentioned as being a v1 feature; is this feature available?

Cheers,
Andrew

Hi Andrew,

Currently this isn’t available, but you can get it from PowerShell via “Resolve-Path .”. For example, this script could be named Deploy.ps1:

$currentDirectory = (resolve-path .)
$configFile = (join-path $currentDirectory "web.config")

$doc = New-Object System.Xml.XmlDocument
$doc.Load([string]$configFile)
$setting = $doc.SelectSingleNode("/configuration/appSettings/add[@key = 'WebDirectory']")
$setting.SetAttribute("value", $currentDirectory)
$doc.Save($configFile)

Hope that helps,

Paul

Those interested in this in C# can use System.IO.Directory.GetCurrentDirectory()

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.