Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Created December 6, 2016 18:55
Show Gist options
  • Save Dalmirog-zz/4aa9eaed3e1a6a3ebe86d087068e8fcb to your computer and use it in GitHub Desktop.
Save Dalmirog-zz/4aa9eaed3e1a6a3ebe86d087068e8fcb to your computer and use it in GitHub Desktop.
Get nuget package on Tentacle with clean name and do something with it
$OctopusPackage = get-item $OctopusParameters['Octopus.Tentacle.CurrentDeployment.PackageFilePath']
#Octopus adds a GUID to the package name when it drops them on disk (i.e MyPackage.20160309.10.nupkg-e9ba4f11-9303-485f-8abc-6ea6c3776588), so you need to get your hands a bit dirty to clean it up:
#Dir where the package with the clean name will be dropped
$CopyDir = "C:\TempPackages"
If(!(Test-Path $CopyDir)){
New-Item $CopyDir -ItemType Directory -verbose
}
#building string of full path of the package you'll be uploading
$PackageToUploadPath = (Join-Path -path $CopyDir -childpath (($OctopusPackage.Name -split "nupkg")[0] + "nupkg"))
#Creating the copy with the right name
Copy-Item -Path $OctopusPAckage.FullName -Destination $PackageToUploadPath -Verbose -Force
#Here do your magic to push the package to azure using $PackageToUploadPath
#Finally delete the copy on disk with the clean name to avoid taking too much space
#Remove-Item $PackageToUploadPath -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment