"Path too long" when publishing asp.net 5 from Visual Studio 2015
Asked Answered
I

3

15

This seems to be a common problem and I found several Stack Overflow questions, but they all seem to pertain to MSBuild.

I'm trying to publish by right-clicking on my asp.net 5 rc1 project in Visual Studio and invoking a file system-based publish profile.

Its settings look like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <CompileSource>False</CompileSource>
        <_DefaultDNXVersion>dnx-clr-win-x86.1.0.0-rc1-final</_DefaultDNXVersion>
        <UsePowerShell>True</UsePowerShell>
        <IISCommand>web</IISCommand>
        <WebRoot>wwwroot</WebRoot>
        <WwwRootOut>wwwroot</WwwRootOut>
        <IncludeSymbols>False</IncludeSymbols>
        <Native>False</Native>
        <IgnoreDNXRuntime>False</IgnoreDNXRuntime>
        <publishUrl>C:\Source\CCollections\artifacts\bin\CCollections.Client.Web.Angular\Release\PublishOutput</publishUrl>
        <DeleteExistingFiles>False</DeleteExistingFiles>
    </PropertyGroup>
</Project>

This yields this output:

C:\Source\CCollections\src\CCollections.Client.Web.Angular>C:\Users\Christopher\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-final\bin\dnu.cmd publish "C:\Source\CCollections\src\CCollections.Client.Web.Angular" --out "C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96" --configuration Release --runtime dnx-clr-win-x86.1.0.0-rc1-final --wwwroot "wwwroot" --wwwroot-out "wwwroot" --iis-command "web"
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16202

Executing script 'prepublish' in project.json
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No license field.
npm WARN unmet dependency C:\Source\CCollections\src\CCollections.Client.Web.Angular\node_modules\gulp-cssmin\node_modules\gulp-util requires minimist@'^0.2.0' but will load
npm WARN unmet dependency C:\Source\CCollections\src\CCollections.Client.Web.Angular\node_modules\gulp-cssmin\node_modules\minimist,
npm WARN unmet dependency which is version 1.1.1
npm WARN unmet dependency C:\Source\CCollections\src\CCollections.Client.Web.Angular\node_modules\gulp-cssmin\node_modules\through2 requires readable-stream@'~1.0.17' but will load
npm WARN unmet dependency C:\Source\CCollections\src\CCollections.Client.Web.Angular\node_modules\gulp-cssmin\node_modules\readable-stream,
npm WARN unmet dependency which is version 1.1.13
[12:15:37] Using gulpfile C:\Source\CCollections\src\CCollections.Client.Web.Angular\gulpfile.js
[12:15:37] Starting 'clean:js'...
[12:15:37] Starting 'clean:css'...
[12:15:37] Finished 'clean:js' after 8.17 ms
[12:15:37] Finished 'clean:css' after 7.58 ms
[12:15:37] Starting 'clean'...
[12:15:37] Finished 'clean' after 6.63 μs
[12:15:38] Using gulpfile C:\Source\CCollections\src\CCollections.Client.Web.Angular\gulpfile.js
[12:15:38] Starting 'min:js'...
[12:15:38] Finished 'min:js' after 14 ms
[12:15:38] Starting 'min:css'...
[12:15:38] Finished 'min:css' after 3.02 ms
[12:15:38] Starting 'min'...
[12:15:38] Finished 'min' after 6.03 μs
[12:15:40] Using gulpfile C:\Source\CCollections\src\CCollections.Client.Web.Angular\gulpfile.js
[12:15:40] Starting 'libcopy'...
[12:15:40] Finished 'libcopy' after 19 ms
Copying to output path C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96
Using Package dependency Microsoft.AspNet.DataProtection.Abstractions 1.0.0-rc1-final
Using Package dependency Microsoft.CodeAnalysis.CSharp 1.1.0-rc1-20151109-01
Using Package dependency Microsoft.AspNet.Identity 3.0.0-rc1-final
Using Package dependency Microsoft.Extensions.Configuration.CommandLine 1.0.0-rc1-final
Using Package dependency Microsoft.Extensions.Logging.Console 1.0.0-rc1-final
Using Package dependency System.Runtime.InteropServices 4.0.0
Using Package dependency System.Diagnostics.Debug 4.0.0
Using Package dependency Microsoft.AspNet.Mvc.Razor.Host 6.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.Mvc.Razor.Host\6.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.Mvc.Razor.Host\6.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\System.Runtime.InteropServices\4.0.0
Using Package dependency EntityFramework.Commands 7.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\EntityFramework.Commands\7.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\EntityFramework.Commands\7.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.CodeAnalysis.CSharp\1.1.0-rc1-20151109-01
    Source C:\Users\Christopher\.dnx\packages\Microsoft.Extensions.Configuration.CommandLine\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Extensions.Configuration.CommandLine\1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.DataProtection.Abstractions\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.DataProtection.Abstractions\1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\System.Diagnostics.Debug\4.0.0
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\System.Diagnostics.Debug\4.0.0
Using Package dependency Microsoft.AspNet.Mvc.TagHelpers 6.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.Mvc.TagHelpers\6.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.Mvc.TagHelpers\6.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.CodeAnalysis.CSharp\1.1.0-rc1-20151109-01
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\System.Runtime.InteropServices\4.0.0
Using Package dependency Microsoft.Extensions.Configuration.EnvironmentVariables 1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.Extensions.Configuration.EnvironmentVariables\1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.Extensions.Logging.Console\1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.Identity\3.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.Identity\3.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Extensions.Configuration.EnvironmentVariables\1.0.0-rc1-final
Using Package dependency Microsoft.AspNet.Diagnostics 1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.Diagnostics\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.Diagnostics\1.0.0-rc1-final
Using Package dependency EntityFramework.Core 7.0.0-rc1-final
Using Package dependency Microsoft.AspNet.Mvc.ViewFeatures 6.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.Mvc.ViewFeatures\6.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.Mvc.ViewFeatures\6.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Extensions.Logging.Console\1.0.0-rc1-final
Using Package dependency Microsoft.Dnx.Compilation.Abstractions 1.0.0-rc1-final
Using Package dependency Microsoft.Extensions.Configuration.FileExtensions 1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.Extensions.Configuration.FileExtensions\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Extensions.Configuration.FileExtensions\1.0.0-rc1-final
Using Package dependency Microsoft.AspNet.Identity.EntityFramework 3.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.Identity.EntityFramework\3.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\EntityFramework.Core\7.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\EntityFramework.Core\7.0.0-rc1-final
Using Package dependency System.Diagnostics.DiagnosticSource 4.0.0-beta-23516
Using Package dependency Microsoft.Extensions.Logging.Debug 1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.Extensions.Logging.Debug\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Extensions.Logging.Debug\1.0.0-rc1-final

Using Package dependency Microsoft.AspNet.Diagnostics.Abstractions 1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.Diagnostics.Abstractions\1.0.0-rc1-final
Using Package dependency Microsoft.AspNet.PageExecutionInstrumentation.Interfaces 1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.AspNet.PageExecutionInstrumentation.Interfaces\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.PageExecutionInstrumentation.Interfaces\1.0.0-rc1-final
Using Package dependency Microsoft.Extensions.Configuration.FileProviderExtensions 1.0.0-rc1-final
    Source C:\Users\Christopher\.dnx\packages\Microsoft.Dnx.Compilation.Abstractions\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Dnx.Compilation.Abstractions\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.Identity.EntityFramework\3.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.AspNet.Diagnostics.Abstractions\1.0.0-rc1-final
Using Package dependency System.Text.Encoding 4.0.0
    Source C:\Users\Christopher\.dnx\packages\System.Text.Encoding\4.0.0
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\System.Text.Encoding\4.0.0
    Source C:\Users\Christopher\.dnx\packages\System.Diagnostics.DiagnosticSource\4.0.0-beta-23516
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\System.Diagnostics.DiagnosticSource\4.0.0-beta-23516
    Source C:\Users\Christopher\.dnx\packages\Microsoft.Extensions.Configuration.FileProviderExtensions\1.0.0-rc1-final
    Target C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Extensions.Configuration.FileProviderExtensions\1.0.0-rc1-final
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.
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.

C:\Source\CCollections\src\CCollections.Client.Web.Angular>

I think my problem is here: C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\

I need to use a shorter path, like C:\Temp.

I've tried some of the suggestions in other stack overflow answers.

Adding <AspnetCompileMergeIntermediateOutputPath>c:\shortPath\</AspnetCompileMergeIntermediateOutputPath> to the profile doesn't appear to help.

Adding <IntermediateOutputPath>..\Temp</IntermediateOutputPath> doesn't seem to work either.

I'm guessing it's because these settings get picked up by MSBuild, but not dnu publish.

So how to I tell dnu publish to build the package in C:\Temp instead of my appdata directory?

Update: Finding the culprits: I think the files that exceed the path limit are not in the above log, and that only the successful copies are logged. To test this hypothesis:

  1. I deployed to c:\temp by running dnu publish manually
  2. Copied the files from c:\temp to C:\Users\Christopher\AppData\Local\Temp\PublishTemp
  3. Ran a script to iterate all files recursively and output path lengths that exceed 248 characters. Results:

    C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Extensions.Configuration.FileProviderExtensions\1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.FileProviderExtensions.dll

    File path long: 249 chars

    C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96\approot\packages\Microsoft.Extensions.Configuration.FileProviderExtensions\1.0.0-rc1-final\lib\netcore50\Microsoft.Extensions.Configuration.FileProviderExtensions.dll

    File path long: 252 chars

The biggest folder is 191 characters, and with the file it's 252 characters, so that's not exceeding 240 and 260 characters, respectively.

Regardless of all this, how do I tell Visual Studio 2015 to use "C:\temp" as its temp directory, instead of my profile's temp directory?

Iver answered 20/11, 2015 at 17:27 Comment(9)
At what stage of the publish does this happen? Does this happen when your node packages are being installed?Golf
If I watch the path C:\Users\Christopher\AppData\Local\Temp\PublishTemp\CCollections.Client.Web.Angular96 with Explorer during the execution of dnu publish, I see folders such as Microsoft.AspNet.PageExecutionInstrumentation.Interfaces showing up in approot/packages immediately before I get the error.Iver
Could you post the output of your dnu publish? Also, you can change the output by dnu publish -o <path>.Golf
Sure thing. Edited my post to include the full output.Iver
Second edit to include the FULL output (no --quiet switch)Iver
Have you tried the -o (or --output if you want to be explicit) switch?Golf
That's an alias for --out, which I am already using. I understand the nature of this error, and deploying to a shorter path like c:\inetpub\site works fine when I run this command manually. My question is how do I get Visual Studio to supply a different directory when I use its publishing feature. It's using that long temp directory and I don't know how to tell it to execute dnu publish with a different, shorter, temp directory.Iver
The longest string (path + file name) in your output is only 176 characters - well short of the 260 // 248 maxpath boundary. I've had trouble with paths that had "."s in them, and I see one of your directories is labeled: "CCollections.Client.Web.Angular96" thus. That may be an issue. I also have problems with %20 - or spaces sometimes. Usually these problems come from files created on Unix-based (Linux) systems and then ported over to Windows.Sneck
Interesting observation. To test my hypotheses that only the successful copies are logged, I conducted an experiment and added the results to my post. There are two paths that are over 248 characters.Iver
G
34

Change the temp output to a path with a shorter path name.

  1. Open your target .pubxml in .\Properties\PublishProfiles from a text editor.
  2. Change or add an element called PublishOutputPathNoTrailingSlash under PropertyGroup and set the value to your desired path.
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishOutputPathNoTrailingSlash>C:\Temp\Publish</PublishOutputPathNoTrailingSlash>
  </PropertyGroup>
</Project>
Golf answered 20/11, 2015 at 20:41 Comment(15)
That works! It uses that path for the temp files, but still goes where I want it to ultimately.Iver
If you ever visit Dallas, I will buy you a beer.Iver
If you ever visit London, I will buy you a beer.Armbrecht
If you ever visit Sydney, I will buy you a beer.Attune
If you ever visit Moscow, I will buy you some vodka.Rodney
If you ever visit Paris, I know someone that will buy you a beerTrautman
If you ever visit Melbourne, I'll buy you a slab.Klondike
If you ever visit Brazil, I'll buy you a capirinha.Reviviscence
I like checking this answer every couple months to see where in the world @Golf gets free stuff.Iver
If you ever visit Latvia, I'll buy you some great potato with your name on it! +bonus: this deal available for @Chris too.Townsville
This doesn't help me too much because I'm using a web Project, but ... Hey if you visit Zaragoza(Spain) i will buy you a beer.Fann
If you ever visit Belgium, I will try to find you some security ;)Hekate
If you ever visit India, I will buy you a beer !!Bulky
If you ever visit Ukraine, I will buy you a borschtBibliotaph
if you ever visit jersey I'll buy you a vegan cheesesteak! I didnt use your answer but stumbled upon this and thought I'd extend the great hospitality of New Jersey to you. a world unto itself.Expressive
S
2

For new asp.net mvc 6 in project.json use

"exclude": [ "wwwroot", "node_modules" ],`
"publishExclude": [ "**.user",  "**.vspscc" ]
Subliminal answered 15/4, 2016 at 16:53 Comment(0)
S
0

I think this is what you're looking for:

When you go into the "Publish Web' dialog, you'll need to change the 'Target Location' within the "Connection" tab. (Hit the Square Box with ...) and then browse to C:\Temp and your files go there...

The dialog won't allow you to create C:\Temp on the fly, so if you haven't created it already , you'll need to do so beforehand.

I do hope this does it.

Sneck answered 20/11, 2015 at 19:56 Comment(7)
Unfortunately, that doesn't work for two reasons. 1) I do not want to publish to temp. 2) It still fails for the exact same reason because the path it uses as a temp directory (before copying files to c:\temp) is too long.Iver
What about changing the file path to exclude the dots(.) as in: CCollections.Client.Web.Angular96 ??Sneck
The problem is that the publish feature uses my windows profile's temp path to construct the files it will ultimately deploy. I do not know where to instruct visual studio to use a shorter path.Iver
Under "PublishProfiles" in Solution Explorer, there is a an xml file that will allow you to modify the _PublishTargetUrl. Mine looks lilke this: <?xml version="1.0" encoding="utf-8"?> <!-- <PropertyGroup> <TimeStampOfAssociatedLegacyPublishXmlFile /> <_PublishTargetUrl>C:\Users\Stephen\AppData</_PublishTargetUrl> </PropertyGroup> </Project>Sneck
Are you using asp.net 5 rc1? As you can see in my original question, I do not have those items. When you execute the publish, is your output log showing "dnu publish"?Iver
My Dev machine is Win 10 asp.net 5 1.0.0-rc1-final...Underneath the project within 'src', there is a 'Properties' folder. Inside of that is the PublishProfiles folder. inside of thhta is a file with a .pubxml extension. Under that file is one with the .pubxml.user extension. That's where I was able to change the PublishTargetUrl field.Sneck
Again, that is not the temp folder that it uses. That is the final destination (this is just a user-specific version of it). If you actually did a publish, you would still see C:\Users\Stephen\AppData being used as the temp directory. opiants found the answer, though, so we're good!Iver

© 2022 - 2024 — McMap. All rights reserved.