Errors with octo.exe pack -version and powershell

I am using power shell to run octo.exe to pack my folder. If I do not include the -version every thing works fine. If I run the write-host output from the commend line it works fine. However if I run the powershell script I get this error.

PS C:\Windows\system32> D:\PowerShellForTeamCity\DebugBuildzip.ps1
D:\octopus\octo.exe pack -id=JCRL3G_Pete -version=2016.0726.0104.86 -format=Zip -overwrite -outfolder=D:\TeamCity\buildAgent\work\dabe18ca22c2f5c1\Zip -basepat
h=D:\TeamCity\buildAgent\work\dabe18ca22c2f5c1\StageDir\PackageTmp
Octopus Deploy Command Line Tool, version 3.3.18+Branch.master.Sha.d32cf0e4440e5e245f014977288a915c3f267bfd

System.ArgumentException: ‘2016’ is not a valid version string.
Parameter name: version
at NuGet.SemanticVersion.Parse(String version)
at Octopus.Cli.Commands.PackCommand.<.ctor>b__15_9(String v)
at Octopus.Cli.Commands.OptionSet.<>c__DisplayClass15_0.b__0(OptionValueCollection v)
at Octopus.Cli.Commands.OptionSet.ActionOption.OnParseComplete(OptionContext c)
at Octopus.Cli.Commands.Option.Invoke(OptionContext c)
at Octopus.Cli.Commands.OptionSet.ParseValue(String option, OptionContext c)
at Octopus.Cli.Commands.OptionSet.Parse(String argument, OptionContext c)
at Octopus.Cli.Commands.OptionSet.<>c__DisplayClass26_0.b__0(String argument)
at System.Linq.Enumerable.WhereArrayIterator1.MoveNext() at System.Collections.Generic.List1…ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at Octopus.Cli.Commands.OptionSet.Parse(IEnumerable1 arguments) at Octopus.Cli.Commands.Options.Parse(IEnumerable1 arguments)
at Octopus.Cli.Commands.PackCommand.Execute(String[] commandLineArguments)
at Octopus.Cli.Program.Main(String[] args)
Exit code: -3

#============================================================================

Build the zip for the application

#============================================================================
function BuildOctopusZip{

param(
    [parameter(Mandatory=$true)] [string]$CheckoutDir,
    [parameter(Mandatory=$true)] [string]$TFSSourceDir,
    [parameter(Mandatory=$true)] [string]$BuildNbr
)

$DosCommand = "D:\octopus\octo.exe pack -id=" + $TFSSourceDir
$DosCommand += " -version=" + $BuildNbr 
$DosCommand += " -format=Zip "
$DosCommand += " -overwrite "
$DosCommand += " -outfolder=" + $CheckoutDir + "\Zip "
$DosCommand += " -basepath=" + $CheckoutDir + "\StageDir\PackageTmp"
write-host $DosCommand

Invoke-Expression $DosCommand	

}
BuildOctopusZip “D:\TeamCity\buildAgent\work\dabe18ca22c2f5c1” “JCRL3G_Pete” “2016.0726.0104.86”

Hi,

Thanks for reaching out. Because the version number has dots in it, Powershell is breaking it up into smaller chunks and finally only paying attention to the initial “1”. If you change:

$DosCommand += " -version=" + $BuildNbr

for

$DosCommand += " -version=" + "'$BuildNbr'"

It should work.

Hops that helps!
Dalmiro

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.