1

I am setting up the build process for a desktop application on Visual Studio Team Services (i.e. Visual Studio Online) and would like to run the squirrel installer Releasify command automatically under some build cases. So far I have created the following powershell script that I am running after the project gets built

Write-Host "Hello World from $Env:AGENT_NAME."
Write-Host "Current Path  $env:Agent_BuildDirectory"
Write-Host "Build Number  $env:Build_BuildNumber"
$squirrel = "$env:Agent_BuildDirectory\packages\squirrel.windows.*\tools\Squirrel.exe"
.$squirrel -releasify "$build_dir\MyNupkg.nupkg"

This is leading to the following error message

2015-12-29T12:57:48.5701506Z ##[error]. : The term 'C:\a\1\packages\squirrel.windows.*\tools\Squirrel.exe' is not recognized as the name of a cmdlet, 
2015-12-29T12:57:48.5701506Z ##[error]function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the 
2015-12-29T12:57:48.5701506Z ##[error]path is correct and try again.
2015-12-29T12:57:48.5701506Z ##[error]At C:\a\1\s\MyDir\Release.ps1:5 char:2
2015-12-29T12:57:48.5701506Z ##[error]+ .$squirrel -releasify "$build_dir\MyNupkg.nupkg"
2015-12-29T12:57:48.5701506Z ##[error]+  ~~~~~~~~~
 2015-12-29T12:57:48.5701506Z ##[error]    + CategoryInfo          : ObjectNotFound: (C:\a\1\packages...ls\Squirrel.exe:String) [], CommandNotFoundException
2015-12-29T12:57:48.5701506Z ##[error]    + FullyQualifiedErrorId : CommandNotFoundException
2015-12-29T12:57:48.5701506Z ##[error] 
2015-12-29T12:57:48.5701506Z ##[error]Process completed with exit code 0 and had 1 error(s) written to the error stream.

How can I fix this error? Is there a better approach? Why can't powershell run a program that is in that directory?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
PlTaylor
  • 7,345
  • 11
  • 52
  • 94

2 Answers2

2

The error is pretty clear:

It's not finding the file in the path you're specifying, which is: C:\a\1\packages\squirrel.windows.*\tools\Squirrel.exe

Correct the path to point to the correct folder.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
0

"$env:Agent_BuildDirectory" is the local path on the agent where all folders for a given build definition are created. It isn't the complete path for your project solution. You need to use the path "$env:BUILD_SOURCESDIRECTORY\\" to navigate to packages folder. So update the script to following should fix your problem:

$squirrel = "$env:BUILD_SOURCESDIRECTORY\<project name>\packages\squirrel.windows.*\tools\Squirrel.exe"
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60