0

The gulp files installed in a asp.net5 web project use the maximum path length. If you have a project path with more than a few characters long, the folders cannot be deleted.

This post refers to how to build using a short temp directory: "Path too long" when publishing asp.net 5 from Visual Studio 2015

The question is, how do you easily remove these files when you need to clean up, restore, or archive a project?

Community
  • 1
  • 1
MarkD
  • 1,511
  • 18
  • 32

3 Answers3

0

Simple answer is file system basics. Create a directory in the same root as your project and give it a really short name (like "c:\t"). Then move all the files in node_modules there. then delete them.

I hear ms is working on a more workable gulp folder structure.

MarkD
  • 1,511
  • 18
  • 32
  • Actually, this doesn't work for me. The subfolder structure in npm_modules folder is so out of control that even though I created a folder named "i" under my C drive -- C:\i -- I still can't publish my app because of this issue. – Sam Jul 11 '16 at 22:20
0

The reason you are hitting the NTFS file, path and name length limit of 255 characters is because of NPM nesting of package dependencies, 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. This will help you avoid the problem "unable to delete" because you will never have paths beyond 255 characters.

Perform the following:

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

2) Update Visual Studio 2015 External Web Tools to point to the folder with the new tools. (Tools-Options-Projects And Solutions-External Web Tools). Usually:

C:\Program Files\nodejs"

or

C:\Program Files (x86)\nodejs"

  • Make sure this is the top option on the list of paths.

3) (On automated build) Make sure that Visual Studio 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
0

After doing a lot of head hunting, I found about robocopy and this command has been my friend since then. I use the following steps to remove a file or folder when the windows path is too long

  1. Create a folder anywhere in your system to use as a source (leave it empty).
  2. Take back up from the folder you want to delete (if there is something important)
  3. Open Command prompt
  4. Type the following command. Modify the placeholders to suit your needs.

robocopy C:\path-to-source-empty-folder E:\path-to-folder-you-cant-delete /purge.

robocopy sample

Note: If there are spaces in source or destination path in Step 4, the path must be enclosed by quotation marks.

  1. After successful execution of the command, you will get execution report like the following

robocopy success

  1. Everything inside the destination folder will be deleted forever.

You can also type robocopy in command prompt to see other options.

I hope this helps.