从Web项目中排除node_modules目录

时间:2015-06-17 15:02:12

标签: visual-studio-2013

如果我右键单击我的项目并选择Publish Web Project,我将收到有关目录名长度的错误。我已将其跟踪到node_modules。我想从进程中排除这个目录及其内容。

我们使用.pubxml文件,并尝试添加以下内容之一或其组合:

<ExcludeFoldersFromDeployment>node_modules</ExcludeFoldersFromDeployment>
<ExcludeFilesFromDeployment>node_modules\**\*.*</ExcludeFilesFromDeployment>

似乎都没有做到这一点。仍然得到相同的错误。如果您真的对错误感兴趣,请点击这里:

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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.Web.Publishing.Tasks.CollectFilesinFolder.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

更新

我还尝试将node_modules隐藏属性(及其内容)设置为true并在VS中刷新。相同的结果。

1 个答案:

答案 0 :(得分:1)

我在ASP.NET网站项目中遇到了同样的问题,this中有一条评论(@robd)SO建议将该文件夹标记为 Hidden 。然后我就可以发布我的网站并继续使用Gulp。