ASP.NET Publish Error (The specified path, file name, or both are too long)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 15:40:09

问题


I am getting an error like the following while publishing a project with Visual Studio:

Copying file Areas\AdminPanel\Content\assets\global\plugins\bootstrap-editable\inputs-ext\wysihtml5\bootstrap-wysihtml5-0.0.2\bootstrap-wysihtml5-0.0.2.css to obj\Release\Package\PackageTmp\Areas\AdminPanel\Content\assets\global\plugins\bootstrap-editable\inputs-ext\wysihtml5\bootstrap-wysihtml5-0.0.2\bootstrap-wysihtml5-0.0.2.css failed. 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.

Is there a simple way to solve this problem or should I make the path shorter?

I am working with ASP.NET Web Forms btw.


回答1:


Windows has a limitation that can be configured. See NicoRiff's answer.

That beeing said, the following string is "only" 173 chars long:

obj\Release\Package\PackageTmp\Areas\AdminPanel\Content\assets\global\plugins\bootstrap-editable\inputs-ext\wysihtml5\bootstrap-wysihtml5-0.0.2\bootstrap-wysihtml5-0.0.2.css

I suggest you, to create a folder in the root of your disc, for example D:/Dev where all your projectes are stored.

Changing the registry would also be an option, but needs to be configured for every developer, which is suboptimal. Generaly you should go for shorter paths. Checkout and Build should be the motto.

When you ship the software you should also minify/bundle your client side scripts. This way you only have one short path bundle.css in your published output.




回答2:


That is a Windows limitation. You can disable it this way:

  1. Execute 'regedit.exe'
  2. Navigate to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem"

  3. Find a value named LongPathsEnabled and double-click it. If you don’t see the value listed, you’ll need to create it by right-clicking the FileSystem key, choosing New > DWORD (32-bit) Value, and then naming the new value LongPathsEnabled

  4. Change the value from 0 to 1 in the “Value data” box and then click OK.

After that, you would probably have to restart visual studio.



来源:https://stackoverflow.com/questions/48990537/asp-net-publish-error-the-specified-path-file-name-or-both-are-too-long

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!