7

I am trying to publish a pure client project - that is - plain html/js/css files, that during dev being managed by nodejs. Node creates a very deep path (longer than 260 chars) - inside node_modules/...
Although I have excluded node_modules completly:

<ExcludeFoldersFromDeployment>test;node_modules</ExcludeFoldersFromDeployment>

It still throws an exception when I try publishing:

Error   1   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()

I know it is specifically the node_modules, because manually removing it solves the issue.
Other then that, excluding works fine (the 'test' folder is being excluded).

How do I keep these files from being considered for the publish?

roufamatic
  • 18,187
  • 7
  • 57
  • 86
Tomer
  • 4,382
  • 5
  • 38
  • 48
  • I'm having the same issue. It doesn't matter if the folder is never added to the project file, either. It has to be removed from the project's containing folder entirely. – roufamatic Dec 05 '14 at 00:54
  • Unfortunately I haven't solved it but rather moved to a completely different approach of CI using Jenkins, where I just use grunt to build the client - which is very straight forward and has many features to include/exclude/compile). – Tomer Dec 05 '14 at 08:31

2 Answers2

1

I solved this by installing some (if not all) of the dependecies globally:

npm install -g package

and then installing into the project using

npm install --link

The result is that NPM will create shortcuts to your globally installed packages instead of copying them, and it seems that msbuild does not try to follow these links.

0

You can simply hide the folder, i.e. set the hidden attribute, and aspnet_compiler will skip it avoiding this error to happen.

I've tested this with TypeScript typings, and grunt tasks, and they work perfectly with this folder hidden. Of course, npm install and npm update also work fine.

If you hide this in the command line or using a script, use this command

  attrib +H "path\to\folder\to\hide"

You can also use this command in a msbuild task, as explained in this answer to How do you handle excluded files with aspnet_compiler?

JotaBe
  • 38,030
  • 8
  • 98
  • 117