Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 593
Shadouspan Avatar asked Feb 26 '18 14:02

Shadouspan


2 Answers

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.

like image 53
NicoRiff Avatar answered Oct 17 '22 04:10

NicoRiff


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.

like image 5
Christian Gollhardt Avatar answered Oct 17 '22 04:10

Christian Gollhardt