If you’re seeing this error when you’re trying to build a package with Web Deploy then you have some deeply nested folders in your project which is causing the problem. A common problem web developers of 2015 have to wrestle with is fighting the Node Package Manager on a Windows developer box. Read on to get this issue quickly solved so you can deploy your site.
Problem
When attempting to build a Web Deploy package Visual Studio fails with an error message similar to this:
Error Message Severity Code Description Project File Line Error The "CollectFilesinFolder" task failed unexpectedly. System.IO.PathTooLongException: 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. at System.IO.PathHelper.GetFullPathName() at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) at System.IO.Path.GetFullPathInternal(String path) at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) at System.IO.FileSystemInfo.get_FullName() at Microsoft.Web.Publishing.Tasks.CollectFilesinFolder.CollectAllFiles(String rootPath, DirectoryInfo dirinfo, Boolean recursive, List`1 result, Boolean defaultInclude, Regex[] fullPathMatchs, Regex[] relativePathMatchs, Regex[] excludeFullPathMatchs, Regex[] excludeRelativePathMatchs) at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Orchard.Web 0
You have some deeply nested folders, most probably a node_modules
folder.
Solution
At this point the only solution I know of is for you to delete the node_modules
folder.
It seems that even if it’s excluded from your solution, Web Deploy will still try to scoop up the files.
The node_modules
folder is a special folder used by Node Package Manager, or NPM. It’s gained a lot of popularity recently as one of the main way for developers to distribute JavaScript based code and keep it up to date.
Don't worry about deleting the folder, its a special folder and it can be automatically repopulated when you reopen the project in Visual Studio 2015 or use the NPM command line.
It's not required for your site to run on the webserver. It is just used by whatever pipeline you have set up for development; like compressing CSS, minifying JS, compiling pre-processors etc.
Basically if you don't know what it is then you aren't likely to need it unless you're following a tutorial explaining how to use it. That said, if you don’t know what it is then let this be a wake up call for you. Its an intrinsic part of many modern development techniques and it means you are probably getting pretty behind in your web development skills.
Anyway, because the path is so long Windows Explorer might not be able to delete it. The best way I have found is to use 7-Zip. If you just open 7-Zip up via the start menu you can navigate around your hard drives using it as a file system. The quickest way is to copy / paste the path to the folder into the path bar at the top. When you delete it, you must press SHIFT-DELETE
otherwise it will still fail, even in 7-Zip, because the path is too long to put it into the recycle bin.
Luckily, after fierce debate in the NPM GitHub issues, it seems that NPM 3 is adopting a new flat file hierarchy which should stop most of these problems. Not long now…
No comments :
Post a Comment