Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to publish Blazor app because path length #6149

Closed
astrowalker opened this issue Feb 11, 2021 · 8 comments
Closed

Unable to publish Blazor app because path length #6149

astrowalker opened this issue Feb 11, 2021 · 8 comments
Assignees
Labels
Area: Debuggability Issues impacting the diagnosability of builds, including logging and clearer error messages. closed-by-bot Closed due to lack of activity initial-investigation Perform initial investigation, apply untriaged label when done. needs-more-info Issues that need more info to continue investigation. stale For issues that haven't had activity in some time. triaged

Comments

@astrowalker
Copy link

This is repost of report against Blazor: dotnet/aspnetcore#30067

Describe the bug

I have Blazor web client project which I can run OK both from Visual Studio 2019 (16.8.4) and from command line. Now I would like to publish this project into local folder (I used the defaults -- "bin\Release\net5.0\browser-wasm\publish"). When I hit Publish I got this output:

C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(237,5): Warning MSB3026: Could not copy "C:\Users\macias.nuget\packages\microsoft.aspnetcore.components.webassembly.authentication\5.0.3\staticwebassets\AuthenticationService.js" to "D:\temp\Xxxxxxx\Aaa-AAA\PpppppppppppOooooo\Xxxxxxx.Yyyyyy.Zzzzzzzzzzzzzzzzzz\Xxxxxxx.Yyyyyy.Zzzzzzzzzzzzzzzzzz.WebBlazor\Client\obj\Release\net5.0\browser-wasm\PubTmp\Out\wwwroot_content\Microsoft.AspNetCore.Components.WebAssembly.Authentication\AuthenticationService.js". Beginning retry 1 in 1000ms. Could not find a part of the path 'D:\temp\Xxxxxxx\Aaa-AAA\PpppppppppppOooooo\Xxxxxxx.Yyyyyy.Zzzzzzzzzzzzzzzzzz\Xxxxxxx.Yyyyyy.Zzzzzzzzzzzzzzzzzz.WebBlazor\Client\obj\Release\net5.0\browser-wasm\PubTmp\Out\wwwroot_content\Microsoft.AspNetCore.Components.WebAssembly.Authentication\AuthenticationService.js'.

The source file exists, the destination directory exists. I can copy the file manually, no problem.

When I copy the file myself first, and then try to publish I got extra error first stating

C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk.Publish\targets\CopyTargets\Microsoft.NET.Sdk.Publish.CopyFiles.targets(50,5): Warning MSB3231: Unable to remove directory "D:\temp\Xxxxxxx\Aaa-AAA\PpppppppppppOooooo\Xxxxxxx.Yyyyyy.Zzzzzzzzzzzzzzzzzz\Xxxxxxx.Yyyyyy.Zzzzzzzzzzzzzzzzzz.WebBlazor\Client\obj\Release\net5.0\browser-wasm\PubTmp\Out". Could not find a part of the path 'AuthenticationService.js'.

To Reproduce

Create example Blazor app located in flat/short directory, like d:\test. This will work.

Create example Blazor app located in somewhat longer path (as above). This will work initially, but then just install nuget package to web client project "Microsoft.AspNetCore.Components.WebAssembly.Authentication" and this will tip over the path limit -- this won't work (i.e. you will not be able to publish web client).

Issues found

I see here several issues which I think should be addressed:

  • the error messages are misleading, "cannot copy" is maybe accurate internally, but should be spelled out as "path is too long"
  • more serious one -- since total length path in Windows is limited to 260 characters, it is good to take user part and "infrastructure" part into consideration. The latter is this sequence "\obj\Release\net5.0\browser-wasm\PubTmp\Out\wwwroot_content\Microsoft.AspNetCore.Components.WebAssembly.Authentication\AuthenticationService.js" (it is 145 characters long). It means the user controls only 115 characters. It might seem like a lot but after you move from naming your project "BlazorApp1" you can quickly exceed the limit. Besides common sense tells that taking majoriy of space from the user is kind of unfair :-)
  • maybe minor thing, but still, it is kind of "surprise" effect when you can build you app, run it (path length is not exceeded), and yet you cannot publish just because of the way publish internally works (I can change the publish target folder, but the error is about "obj" not target)

Further technical details

ASP.NET 5.0

PM> dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.102
Commit: 71365b4d42

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.102\

Host (useful for support):
Version: 5.0.2
Commit: cb5f173b96

.NET SDKs installed:
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]
2.1.509 [C:\Program Files\dotnet\sdk]
2.1.513 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.2.104 [C:\Program Files\dotnet\sdk]
5.0.101 [C:\Program Files\dotnet\sdk]
5.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@Forgind
Copy link
Member

Forgind commented Feb 24, 2021

#53 (comment)

It isn't perfect, but I think that's the best we can offer. MSBuild supports long paths, but not all the tools around it do.

@Forgind Forgind closed this as completed Feb 24, 2021
@astrowalker
Copy link
Author

@Forgind , "the best"? The prefix of the path is "\obj\Release\net5.0\browser-wasm\PubTmp\Out", from top of my head "\obj\Release\net5.0\wasm" -- here, it is shorter making more space for the user.

Secondly, the message is really also "the best"? I would say "Cannot use path XYZ because it exceeds the limit of ABC characters" is way more useful.

@Forgind
Copy link
Member

Forgind commented Mar 1, 2021

Closing this was probably premature. We can improve the error experience (possibly just adding a catch in Copy.cs, though I would've thought this would do it) here, but I don't think we can change the path.

@Forgind Forgind reopened this Mar 1, 2021
@Forgind Forgind added Area: Debuggability Issues impacting the diagnosability of builds, including logging and clearer error messages. help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. and removed needs-triage Have yet to determine what bucket this goes in. bug labels Mar 1, 2021
@djthegr8
Copy link

I think that along with MSBuild, this is a fundamental problem in (probably) .NET or maybe System.IO, as I'm frequently getting System.IO.FileNotFoundException in cases where the exception should've ideally been PathTooLong, for example in the screenshot attached.
image
Maybe this is a bug upstream?

@MikkelChristensen3Shape

Closing this was probably premature. We can improve the error experience (possibly just adding a catch in Copy.cs, though I would've thought this would do it) here, but I don't think we can change the path.

Who can change the path? dotnet/aspnetcore refused to do anything about this and redirected the OP to you.

@benvillalobos benvillalobos added the needs-triage Have yet to determine what bucket this goes in. label May 20, 2021
@Forgind Forgind removed the help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. label May 26, 2021
@Forgind Forgind self-assigned this May 26, 2021
@Forgind Forgind added initial-investigation Perform initial investigation, apply untriaged label when done. and removed needs-triage Have yet to determine what bucket this goes in. labels May 26, 2021
@Forgind
Copy link
Member

Forgind commented Oct 26, 2021

I made a project along the lines you suggested:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-rc.2.21480.10" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-rc.2.21480.10" PrivateAssets="all" />
	<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.0-rc.2.21480.10" />
  </ItemGroup>

</Project>

...which is here:
"C:\Users\forgind1\Folders\Archives\Bug-specific\6149\folderwithalongnameboooooooooooooooooooooooooooooooooomfolderwithalongnameboooooooooooooooooooooooooooooooooomfolderwithalongnameboooooooooooooooooooooooooooooooooom\folderrrrrrrrrrrrrrrr.csproj"

I tried dotnet publish from there, and it succeeded. Did I do some part of that wrong?

I think that along with MSBuild, this is a fundamental problem in (probably) .NET or maybe System.IO, as I'm frequently getting System.IO.FileNotFoundException in cases where the exception should've ideally been PathTooLong, for example in the screenshot attached. image Maybe this is a bug upstream?

Does that FileNotFoundException have an inner exception? That might explain why the PathTooLongException in the catch didn't trigger and would suggest an easy way to correct that part of the bug, that is, an easy way to switch the displayed exception to "Path was too long" instead of just failing to copy it.

Who can change the path? dotnet/aspnetcore refused to do anything about this and redirected the OP to you.

I don't think dotnet/aspnetcore properly looked at it, from the conversation. I'm guilty of the same, having initially thought this was a generic long paths problem. I think they're the ones who can make the path shorter or at least provide a way to opt into that behavior—that doesn't have anything to do with MSBuild, as far as I know.

@Forgind Forgind added the needs-more-info Issues that need more info to continue investigation. label Nov 3, 2021
@ghost ghost added the stale For issues that haven't had activity in some time. label Dec 4, 2021
@ghost
Copy link

ghost commented Dec 4, 2021

This issue is marked as stale because feedback has been requested for 30 days with no response. Please respond within 14 days or this issue will be closed due to inactivity.

@ghost ghost closed this as completed Dec 18, 2021
@ghost
Copy link

ghost commented Dec 18, 2021

This issue was closed due to inactivity. If you can still reproduce this bug, please comment with the requested information, detailed steps to reproduce the problem, or any other notes that might help in the investigation.

@ghost ghost added the closed-by-bot Closed due to lack of activity label Dec 18, 2021
@AR-May AR-May added the triaged label Feb 21, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Debuggability Issues impacting the diagnosability of builds, including logging and clearer error messages. closed-by-bot Closed due to lack of activity initial-investigation Perform initial investigation, apply untriaged label when done. needs-more-info Issues that need more info to continue investigation. stale For issues that haven't had activity in some time. triaged
Projects
None yet
Development

No branches or pull requests

6 participants