【发布时间】:2015-04-13 10:35:23
【问题描述】:
我正在尝试使用 TFS 后期构建脚本中的 nuget 打包和发布库。似乎 TFS 构建不使用标准项目输出路径,所以它使事情变得复杂。我要做的就是构建项目(它确实如此),然后用 nuget 打包和发布。
这是我的脚本。它在我的本地机器上运行良好。
param([string]$project, [string]$version)
if (-not $project)
{
Write-Error ("The project parameter is required.")
exit 1
}
if (-not $version)
{
$version = $Env:TF_BUILD_BUILDNUMBER
}
if (-not $version)
{
Write-Error ("Either the version parameter or the TF_BUILD_BUILDNUMBER environment variable is required.")
exit 1
}
$projectFile = "$project\$project.csproj"
$packageFile = "$project.$version.nupkg"
$nugetPath = ".nuget\NuGet.exe"
if ($Env:TF_BUILD_SOURCESDIRECTORY)
{
# relative paths won't work on the build server
$projectFile = "$Env:TF_BUILD_SOURCESDIRECTORY\$projectFile"
$packageFile = "$Env:TF_BUILD_SOURCESDIRECTORY\$packageFile"
$nugetPath = "$Env:TF_BUILD_SOURCESDIRECTORY\$nugetPath"
}
else
{
$nugetPath = ".\$nugetPath"
}
Write-Host ("packing $projectFile...")
& $nugetPath pack "$projectFile" -Version $version -Symbols -IncludeReferencedProjects
这是我遇到的错误。
& : The term '.\.nuget\NuGet.exe' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\a\src\project\.build\PublishPackage.ps1:85 char:3
+ & $nugetPath pack "$projectFile" -Version $version -Symbols -IncludeReferencedPr ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.\.nuget\NuGet.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我简化了脚本,因此行号不匹配,但您可以看到它是导致错误的最后一行。我正在使用带有托管构建控制器的 Visual Studio Online。
【问题讨论】:
标签: powershell tfs nuget tfsbuild azure-devops