1

I'm trying to do a dnu restore on my ASP.NET 5 RC1 application using the new build system available on Visual Studio Team Services (aka Visual Studio Online).

My project.json contains a postrestore command as follows:

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

After a dnu restore I can see an error in the build log repeated several times saying:

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.

If I do a dnu restore on the command line on my local dev machine I don't encounter this problem. Why does this happen on VSTS build and how do I fix it?

My build script is as follows:

#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"

Here is the part of the logs from when the postrestore is executed:

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
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
neodymium
  • 3,686
  • 6
  • 23
  • 31

1 Answers1

0

You are hitting the NTFS file, path and name length limit of 255 characters. NPM nesting of package dependencies is the reason you are hitting the limitation, which is a known Node issue on the Windows stack. You should try to update NPM to the latest version, 3.0 or greater, where they now use a flat approach to handle package dependencies.

Perform the following:

1) Update NPM on the build machine, by updating to the latest version of Node (download from https://nodejs.org/download).

2) Make sure that Visual Studio Team System does not use the packaged NodeJS version when building your project by passing in the following parameter to MSBuild.

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

or (x86) if applies:

/p:ExternalToolsPath="C:\Program Files (x86)\nodejs"
Roberto Hernandez
  • 2,397
  • 1
  • 16
  • 18
  • 1
    On VSTS how do I ensure point 1 considering the build system is hosted and the build agent can run any build machine? Regarding point 2, I'm not invoking MSBuild directly, so where should I pass the nodejs path information? – neodymium Dec 29 '15 at 00:38