1

我正在尝试dnu restore使用 Visual Studio Team Services(又名 Visual Studio Online)上提供的新构建系统在我的 ASP.NET 5 RC1 应用程序上做一个。

Myproject.json包含postrestore如下命令:

"scripts": {
    "postrestore": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}

之后,dnu restore我可以在构建日志中看到重复多次的错误,说:

2015-12-28T17:49:15.6910525Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

如果我dnu restore在本地开发机器上的命令行上执行操作,则不会遇到此问题。为什么在 VSTS 构建上会发生这种情况,我该如何解决?

我的构建脚本如下:

#Requires -Version 3.0

param($vsoProjectName, $projectName, $buildConfiguration, $buildSourcesDirectory)

$VerbosePreference = "continue"
$ErrorActionPreference = "Continue"

&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
$globalJson = Get-Content -Path "$PSScriptRoot\global.json" -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore

if($globalJson)
{
    $dnxVersion = $globalJson.sdk.version
}
else
{
    Write-Warning "Unable to locate global.json to determine using 'latest'"
    $dnxVersion = "latest"
}

& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r coreclr -arch x86 -Persistent

$dnxRuntimePath = "$($env:USERPROFILE)\.dnx\runtimes\dnx-coreclr-win-x86.$dnxVersion"

Write-Host "BuildSourcesDirectory: $buildSourcesDirectory"
Write-Host "Project Path: $PSScriptRoot\src\$projectName"
Write-Host "Publish output: $buildSourcesDirectory\$vsoProjectName\artifacts\bin\$buildConfiguration\Publish"

Write-Host "Print dnu version"

& "dnu" "--version"

Write-Host "Starting DNU restore on all projects"

 # run DNU restore on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools
Get-ChildItem -Path $PSScriptRoot\src -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }

Write-Host "Finished DNU restore"

以下是执行 postrestore 时的部分日志:

2015-12-28T17:46:49.2776081Z Executing script 'postrestore' in project.json
2015-12-28T17:48:57.7983599Z rimraf@2.2.8 node_modules\rimraf
2015-12-28T17:48:57.7993593Z gulp-concat@2.5.2 node_modules\gulp-concat
2015-12-28T17:48:57.7993593Z Γö£ΓöÇΓöÇ through2@0.6.5 (xtend@4.0.1, readable-stream@1.0.33)
2015-12-28T17:48:57.8003598Z Γö£ΓöÇΓöÇ gulp-util@3.0.7 (array-differ@1.0.0, array-uniq@1.0.2, lodash._reevaluate@3.0.0, object-assign@3.0.0, lodash._reinterpolate@3.0.0, beeper@1.1.0, lodash._reescape@3.0.0, fancy-log@1.1.0, replace-ext@0.0.1, has-gulplog@0.1.0, minimist@1.2.0, chalk@1.1.1, vinyl@0.5.3, gulplog@1.0.0, lodash.template@3.6.2, through2@2.0.0, multipipe@0.1.2, dateformat@1.0.12)
2015-12-28T17:48:57.8003598Z ΓööΓöÇΓöÇ concat-with-sourcemaps@1.0.4 (source-map@0.5.3)
2015-12-28T17:48:57.8013590Z gulp-cssmin@0.1.7 node_modules\gulp-cssmin
2015-12-28T17:48:57.8163579Z Γö£ΓöÇΓöÇ filesize@2.0.4
2015-12-28T17:48:57.8163579Z Γö£ΓöÇΓöÇ graceful-fs@2.0.3
2015-12-28T17:48:57.8173592Z Γö£ΓöÇΓöÇ map-stream@0.0.4
2015-12-28T17:48:57.8173592Z Γö£ΓöÇΓöÇ gulp-rename@1.1.0
2015-12-28T17:48:57.8183601Z Γö£ΓöÇΓöÇ temp-write@0.1.1 (tempfile@0.1.3)
2015-12-28T17:48:57.8183601Z Γö£ΓöÇΓöÇ gulp-util@2.2.20 (lodash._reinterpolate@2.4.1, minimist@0.2.0, chalk@0.5.1, vinyl@0.2.3, through2@0.5.1, lodash.template@2.4.1, multipipe@0.1.2, dateformat@1.0.12)
2015-12-28T17:48:57.8193590Z ΓööΓöÇΓöÇ clean-css@3.4.8 (commander@2.8.1, source-map@0.4.4)
2015-12-28T17:48:57.8193590Z gulp@3.9.0 node_modules\gulp
2015-12-28T17:48:57.8193590Z Γö£ΓöÇΓöÇ interpret@0.6.6
2015-12-28T17:48:57.8203588Z Γö£ΓöÇΓöÇ pretty-hrtime@1.0.1
2015-12-28T17:48:57.8203588Z Γö£ΓöÇΓöÇ deprecated@0.0.1
2015-12-28T17:48:57.8213583Z Γö£ΓöÇΓöÇ archy@1.0.0
2015-12-28T17:48:57.8213583Z Γö£ΓöÇΓöÇ tildify@1.1.2 (os-homedir@1.0.1)
2015-12-28T17:48:57.8223587Z Γö£ΓöÇΓöÇ minimist@1.2.0
2015-12-28T17:48:57.8223587Z Γö£ΓöÇΓöÇ v8flags@2.0.11 (user-home@1.1.1)
2015-12-28T17:48:57.8223587Z Γö£ΓöÇΓöÇ chalk@1.1.1 (escape-string-regexp@1.0.4, ansi-styles@2.1.0, supports-color@2.0.0, has-ansi@2.0.0, strip-ansi@3.0.0)
2015-12-28T17:48:57.8233588Z Γö£ΓöÇΓöÇ semver@4.3.6
2015-12-28T17:48:57.8233588Z Γö£ΓöÇΓöÇ orchestrator@0.3.7 (stream-consume@0.1.0, sequencify@0.0.7, end-of-stream@0.1.5)
2015-12-28T17:48:57.8243588Z Γö£ΓöÇΓöÇ liftoff@2.2.0 (extend@2.0.1, rechoir@0.6.2, flagged-respawn@0.3.1, resolve@1.1.6, findup-sync@0.3.0)
2015-12-28T17:48:57.8243588Z Γö£ΓöÇΓöÇ gulp-util@3.0.7 (array-differ@1.0.0, array-uniq@1.0.2, lodash._reevaluate@3.0.0, lodash._reinterpolate@3.0.0, fancy-log@1.1.0, beeper@1.1.0, lodash._reescape@3.0.0, object-assign@3.0.0, replace-ext@0.0.1, has-gulplog@0.1.0, vinyl@0.5.3, gulplog@1.0.0, lodash.template@3.6.2, through2@2.0.0, multipipe@0.1.2, dateformat@1.0.12)
2015-12-28T17:48:57.8253601Z ΓööΓöÇΓöÇ vinyl-fs@0.3.14 (graceful-fs@3.0.8, vinyl@0.4.6, defaults@1.0.3, strip-bom@1.0.0, mkdirp@0.5.1, through2@0.6.5, glob-stream@3.1.18, glob-watcher@0.0.6)
2015-12-28T17:48:57.8253601Z gulp-uglify@1.2.0 node_modules\gulp-uglify
2015-12-28T17:48:57.8263595Z Γö£ΓöÇΓöÇ deap@1.0.0
2015-12-28T17:48:57.8263595Z Γö£ΓöÇΓöÇ through2@0.6.5 (xtend@4.0.1, readable-stream@1.0.33)
2015-12-28T17:48:57.8273590Z Γö£ΓöÇΓöÇ vinyl-sourcemaps-apply@0.1.4 (source-map@0.1.43)
2015-12-28T17:48:57.8273590Z Γö£ΓöÇΓöÇ gulp-util@3.0.7 (array-differ@1.0.0, array-uniq@1.0.2, lodash._reevaluate@3.0.0, lodash._reinterpolate@3.0.0, fancy-log@1.1.0, lodash._reescape@3.0.0, beeper@1.1.0, object-assign@3.0.0, replace-ext@0.0.1, has-gulplog@0.1.0, minimist@1.2.0, vinyl@0.5.3, gulplog@1.0.0, chalk@1.1.1, lodash.template@3.6.2, through2@2.0.0, multipipe@0.1.2, dateformat@1.0.12)
2015-12-28T17:48:57.8283589Z ΓööΓöÇΓöÇ uglify-js@2.4.19 (uglify-to-browserify@1.0.2, async@0.2.10, source-map@0.1.34, yargs@3.5.4)
2015-12-28T17:49:13.9980542Z [17:49:13] Using gulpfile C:\a\1\s\AspNet5Rc1\src\AspNet5Rc1\gulpfile.js
2015-12-28T17:49:13.9980542Z [17:49:13] Starting 'clean:js'...
2015-12-28T17:49:13.9990527Z [17:49:13] Starting 'clean:css'...
2015-12-28T17:49:13.9990527Z [17:49:13] Finished 'clean:js' after 1.77 ms
2015-12-28T17:49:14.0000527Z [17:49:13] Finished 'clean:css' after 1.62 ms
2015-12-28T17:49:14.0000527Z [17:49:13] Starting 'clean'...
2015-12-28T17:49:14.0440528Z [17:49:13] Finished 'clean' after 6.9 ╬╝s
2015-12-28T17:49:15.4640537Z [17:49:15] Using gulpfile C:\a\1\s\AspNet5Rc1\src\AspNet5Rc1\gulpfile.js
2015-12-28T17:49:15.4650529Z [17:49:15] Starting 'min:js'...
2015-12-28T17:49:15.4650529Z [17:49:15] Starting 'min:css'...
2015-12-28T17:49:15.5170528Z [17:49:15] Finished 'min:js' after 69 ms
2015-12-28T17:49:15.5420528Z [17:49:15] Finished 'min:css' after 83 ms
2015-12-28T17:49:15.5490528Z [17:49:15] Starting 'min'...
2015-12-28T17:49:15.5490528Z [17:49:15] Finished 'min' after 18 ╬╝s
2015-12-28T17:49:15.5660525Z Restore complete, 246685ms elapsed
2015-12-28T17:49:15.5670522Z Feeds used:
2015-12-28T17:49:15.5670522Z     https://api.nuget.org/v3-flatcontainer/
2015-12-28T17:49:15.5700509Z Installed:
2015-12-28T17:49:15.5720509Z     211 package(s) to C:\Users\buildguest\.dnx\packages
2015-12-28T17:49:15.6910525Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.6930524Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.6940524Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.6990526Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.7750517Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.7760529Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.7810522Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.7830524Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.8200522Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.8230511Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.8280527Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.8300524Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.8630530Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.8640526Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.8690519Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.8710530Z ##[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
2015-12-28T17:49:15.9030521Z Finished DNU restore
4

1 回答 1

0

您正在达到 255 个字符的 NTFS 文件、路径和名称长度限制。包依赖项的 NPM 嵌套是您遇到限制的原因,这是 Windows 堆栈上的一个已知节点问题。您应该尝试将 NPM 更新到最新版本 3.0 或更高版本,他们现在使用平面方法来处理包依赖项。

执行以下操作:

1) 在构建机器上更新 NPM,通过更新到最新版本的 Node(从https://nodejs.org/download下载)。

2) 通过将以下参数传递给 MSBuild,确保 Visual Studio Team System 在构建项目时不使用打包的 NodeJS 版本。

/p:ExternalToolsPath="C:\Program Files\nodejs"

或 (x86) 如果适用:

/p:ExternalToolsPath="C:\Program Files (x86)\nodejs"
于 2015-12-28T18:56:49.100 回答