1

我正在为 Visual Studio Team Services(即 Visual Studio Online)上的桌面应用程序设置构建过程,并希望在某些构建案例下自动运行 squirrel 安装程序 Releasify 命令。到目前为止,我已经创建了以下我在项目构建后运行的 powershell 脚本

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"

这导致以下错误消息

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.

我该如何解决这个错误?有更好的方法吗?为什么 powershell 不能运行该目录中的程序?

4

2 回答 2

2

错误很明显:

它没有在您指定的路径中找到文件,即:C:\a\1\packages\squirrel.windows.*\tools\Squirrel.exe

更正路径以指向正确的文件夹。

于 2015-12-29T19:12:09.840 回答
0

"$env:Agent_BuildDirectory" 是代理上的本地路径,其中为给定构建定义创建所有文件夹。这不是您的项目解决方案的完整路径。您需要使用路径“$env:BUILD_SOURCESDIRECTORY\\”导航到包文件夹。因此,将脚本更新为以下应该可以解决您的问题:

$squirrel = "$env:BUILD_SOURCESDIRECTORY\<project name>\packages\squirrel.windows.*\tools\Squirrel.exe"
于 2015-12-30T01:59:08.410 回答