Too long deployment path

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.

This post describes a few different ways of fixing the error “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.” one can get when trying to package/publish a SharePoint solution, web site or Azure Webjob.

UPDATE 11.4.2016: I actually got this nasty exception on another occasion (Azure webjob publish), so I updated the text accordingly.

Symptoms

Visual Studio throws the following error when packaging a SharePoint solution to a .wsp file, OR when deploying or publishing your web project (for example Azure Webjob).

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.

 

Solution

We’ll need to get the feature’s deployment path to be shorter. If it’s actually about just a few characters (and it often is), you can try the following solution:

Too long deployment path
Too long deployment path
  1. Open the feature’s extended settings by double-clicking it’s name
  2. Select “Deployment path”. You should see something like “$SharePoint.Project.FileNameWithoutExtension$_$SharePoint.Feature.FileNameWithoutExtension$”
  3. Remove the first token, or replace it with a short name describing your project or solution.
  4. Save and build/package/deploy.
  5. The problem should be gone now.

In case you’re publishing a webjob or other web project, or the difference is not by just a few characters, you could also try the following:

  1. Unload your web/webjob project
  2. Select “Edit <yourprojectfilename>.csproj”
  3. Add the following entry under the first <PropertyGroup> that exists in the xml file:
    1. <IntermediateOutputPath>..\Temp</IntermediateOutputPath>
  4. Reload the project
  5. Clean the project and rebuild
  6. Try the deployment/publish again – it should work now.

So, what did this do? It quite simply shortened the temporary build/publish output path for Visual Studio, so that it didn’t exceed the 260-character limit. The publish to Azure went fine after this.

In case you STILL encounter this problem, you may have to actually use some slightly blackish magic to map your code to somewhere on your file system where your paths become shorter.

More info

The following two tabs change content below.

Antti K. Koskela

Solutions Architect / Escalations Engineer at Koskila / Norppandalotti Software / Valo Solutions
Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world. He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff. This is his personal professional (e.g. professional, but definitely personal) blog.

2 thoughts on “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.

  1. Long path error!
    “Long path tool” is very helpful for this problem. You can solve this problem like copy, delete, long path files by using this tool.
    I used to have similar problems too, but after using “long path tool” everything was solved.

    1. Hey,

      I actually checked a few different tools for this, but finally thought that the deployment/temp path changing was way simpler. Thanks for the tip anyway!

      .. the long path tool website seems super fishy, though. Just saying!

Let me know your thoughts!