Trouble adding package contents as artifact

Hi,

I am trying to add artifacts from my package to my deployment. I am able to add the nuget package, but I’d like to go a bit further and add sql scripts I am deploying using roundhouse.

I have tested the nuget install command and am able to install a package to c:\temp with this command.

nuget install myPackageID -source d:\octopus\package -solutiondirectory c:\temp\test

With that working, I’m trying to run this in the management console, but the output says that the packages are already installed in the working directory. I put a sleep in powershell so I can look at it and there is nothing in the working dir, aside from the standard files you’d find there. Any advice?

$project = $OctopusParameters["Octopus.Project.Name"]
write-host "Gathering artifacts for $project"

$package = gci ..\..\packages\$project | sort LastWriteTime | select -last 1 

& nuget.exe install $project -source "D:\Octopus\Packages"  -solutiondirectory .

#New-OctopusArtifact -Path $package.FullName -Name $package.Name

Start-Sleep -s 10

OUTPUT:

Feeds used:
February 22nd 2017 13:35:05Info
C:\Users\MyServiceAcct\AppData\Local\NuGet\Cache February 22nd 2017 13:35:05Info
C:\Users\MyServiceAcct.nuget\packages\ February 22nd 2017 13:35:05Info
D:\Octopus\Packages February 22nd 2017 13:35:05Info
All packages listed in D:\Octopus\Work\20170222203504-248\packages.config are already installed. February 22nd 2017 13:35:17Info
Exit code: 0

Hi thanks for getting in touch.

Just trying to clarify what you’re trying to do, when you say, management console are you talking about the package manager console inside visual studio?

If it says already installed, check the packages.config, remove it and try again? Did you manipulate the nuspec file what does that look like?

Double check the documentation for https://docs.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference#install

Regards,
Nick

Howdy Nick,

I’m referring to the script runner console in octopus that lets you test scripts.

Ultimately, I am trying to add .sql files as artifacts to a release, but am using the console to test the powershell script.

Thanks,
Sam

Hi Sam,
Thanks for those extra details.

The only thing we can think of is to check the working directory is what you expect it to be by including a dir in your test script, this seems the most likely thing to cause it not to find the .sql file you’re trying to include.

The relative path may be off, sometimes the start-up profile may change that or some other action.

Regards,
Nick

Hi all,

Sorry to reopen this after so long, but I have finally started working on this again. I made some progress, getting the package to unpack to the work directory. I then build a path to the sql scripts, but still they won’t add. It says the file doesn’t exist although I can output the contents of that directory and see it:

Artifact 001-ExampleScript.sql not found at path ‘D:\Octopus\Work\20170629214549-117\packages\DB_Collection.2017.06.29.1\Database\up’. This can happen if the file is deleted before the task completes.

At this point I’ve just hardcoded the file name, instead of looping over files in the directory.

Any advice is appreciated.

artifact-output.txt (3 KB)

script.txt (819 Bytes)

Hi Sam,

No problem, happy to help. Are you still trying to do this via the Script Console? If so, why was that your choice instead of a project, was it to debug the issue still or something else?

Did you go and check if the file was still there, because it says: This can happen if the file is deleted before the task completes?

Could you also extract that package locally, is it creating any additional folders that would not have the file at Database\up but at something else like: Database\up\somethingelse\?

Regards,
Nick