#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog

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."

koskila
Reading Time 4 min
Word Count 602 words
Comments 14 comments
Rating 4.8 (4 votes)
View

This post describes a few different ways of fixing the "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." error. One can encounter this issue when trying to package/publish a SharePoint solution, web site, or an Azure Webjob.

Symptoms

Visual Studio throws the following error when packaging a SharePoint solution to a .wsp file when deploying or publishing your web project (for example Azure Webjob). In the former case, the error shows in the console as a build error, and the build fails. In the latter case, depending on your tooling, the error is either shown in the console when the publishing fails, or it's shown in a pop-up in your Visual Studio after you've selected to publish your project to an Azure App Service.

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.

So, what to do to fix this?

Solution

Depending on the type of your project, the right solution might be just a bit different - although the error seems to be thrown by msbuild during the build/publish action in any case. And just like the error says, it's because a step in the process is failing because it's trying to use a folder that's located in a path that's too long.

How to fix SharePoint Solutions in Visual Studio?

We'll need to get the feature's deployment path to be shorter. This applies to AT LEAST the following typical, Classic SharePoint solutions:

  1. Full-trust solutions
  2. sandboxed solutions and
  3. add-in projects.

Too long a deployment path highlighted in Visual Studio - this is not going to work.

Too long a deployment path highlighted in Visual Studio - this is not going to work.

If it's actually about just a few characters (and it often is), you can try the following solution:

Time needed: 10 minutes.

How to change a SharePoint feature's deployment path in Visual Studio?

  1. Open the feature's extended settings

    This can be done by double-clicking it's name in the Solution Explorer in Visual Studio.

  2. Select "Deployment path"

    You should see something like "\(SharePoint.Project.FileNameWithoutExtension\)_\(SharePoint.Feature.FileNameWithoutExtension\)"

  3. Modify it

    Remove the first token, or replace it with a short name describing your project or solution.

  4. Save and build/package/deploy.

    The problem should be gone now!

This should fix the issue for your typical SharePoint projects. But what about other types of projects or solutions in Visual Studio?

How to resolve the issue for other project types?

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 steps.

How to change the path for the build process's temporary files?

  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. ..\Temp
  4. Reload the project
  5. Clean the project
  6. Try the deployment/publish again - it should work now.

So, what does this do? It quite simply shortens the temporary build/publish output path for Visual Studio, so that it doesn't exceed the 260-character limit. For me, 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. Symbolic links might help you - but I never had to go that deep. If this doesn't fix your issue, let me know in the comments section below!

References

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.
2016-08-19 19:56:38)
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.
2016-08-25 12:35:28
Hey, Thanks for the spam. I hate it.
Reece Howitt
2019-01-27 12:47:21)
Hey just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Internet explorer. I'm not sure if this is a formatting issue or something to do with browser compatibility but I thought I'd post to let you know. The layout look great though! Hope you get the issue resolved soon. Many thanks
2019-01-27 18:54:16
Okay - so I guess this is a spam bot, but I still approved the comment. Why? Because it's the most helpful bot I've encountered in quite a while. The comment is spot on. The styles were really off and IE was messing up. See below before I fixed it: https://tiedostot.koskila.net/public/iexplore_2019-01-28_01-46-52.jpg Oh, and why do I guess it's a spam bot? Because the message is autogenerated based on a cookbook, that's available here. It just might be the most famous comment spammer on the internet - and it came to help me out here. See below for the exact message: https://tiedostot.koskila.net/public/chrome_2019-01-27_20-34-57.jpg Furthermore, instead of spamming links to CBD or drug websites, it links to opera.com, which used to be my favorite web browser a few years back. Before they became all creepy with their weird rootkit-like shenanigans. All in all, a valuable yet confusing comment. So, the comment above was posted either by a helpful spambot or an actual person wanting to look like a spambot. In any case, thanks for the heads-up!
Alexander
2019-06-27 05:06:45)
Thanks, the solution IntermediateOutputPath with helped me
2019-06-27 05:53:12
Hi Alexander, Happy to hear it was helpful! :)
Alina Valker
2019-07-28 11:04:28)
Long path tool can be very useful in this regard. It helped me a lot. It can solve your problem easily.
2019-07-28 17:32:16
Thanks for your comment Alina. It's exceptional in a sense, that even though it's spammy and shilling for a sub-par product, I allowed it through. Why? Let me explain. Back when I first published this post, I started getting hundreds of spammy comments linking and mentioning to said tool. Likely, every single one of them were left by robots. Likely this one was as well. "Long path tool" is the reason why I had to waste a few hours of my life finding a better tool to curb the constant spam. I ended up finding one, configuring it, and leaving it on - only to find out 6 months later by someone contacting me on Twitter, that it was way, WAY too strict: it was blocking 90% of legitimate comments as well. I had to embark on another journey to find a good comment moderation tool. Well, eventually I did find a pretty good solution - but not before wasting more time. Long path tool caused me plenty of trouble, it has the most annoying marketing strategy ever, and despite their mentions of free version, it's a paid tool. Also, for this particular instance, it's absolutely unnecessary. The issue can be easily solved without paying anything to these bad-mannered spammers. And if this spam keeps going, I will download the tool, dissect it's doings, and write a (likely scathing) review, and do whatever I can to be ranked as first result for anyone searching for "Long Path tool review". Please stop the spam and shady practices and learn to market properly! Cheers.
Amit Verma
2020-05-04 20:42:47)
Very Good Explanation a Big thanks for sharing it....
2020-05-10 15:45:27
Cheers, Amit!
Dhanesh Deshmukh
2021-01-13 18:34:13)
Thanks Reece appreciated work for me
[…] Fixing error: “The specified path, file name, or both are too long. The fully qualified file name … […]
Whitewater Magpie Ltd.
© 2025
Static Site Generation timestamp: 2025-08-12T07:18:34Z