Crazy Deep Path Length in .Net Core 1.1
Asked Answered
T

2

11

Has anyone seen a problem in .NET Core 1.1 where beneath the netcoreapp1.1\publish folder they end up with a bin folder that seems to loop on itself and eventually causes a path too long message to appear in Windows. Trying to delete this folder in Windows Explorer cause a Source Too Long message to appear. The only solution was to use RoboCopy.

Here is an example of one of the generated paths:

bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\Debug\netcoreapp1.1\publish\bin\release\netcoreapp1.1\publish\bin\release\netcoreapp1.1\publish\bin\release\netcoreapp1.1\publish\bin\release\netcoreapp1.1\publish\bin\release\netcoreapp1.1\publish\Controllers\

Is this a problem caused by something I have setup incorrectly?

The last cleanup returned the following stats:

Folders: 6866 Files: 7391

I am publishing using the following command:

dotnet publish -c debug

It seems each publish makes the folder structure deeper and this seems to be related to the CSHTML files in my project creating this folder structure:

\publish\bin\debug\netcoreapp1.1\publish\Controllers\Account\Views

Then on second build this structure:

  \publish\bin\debug\netcoreapp1.1\publish\bin\debug\netcoreapp1.1\publish\Controllers\Account\Views

And so on...

I am using SDK 1.0.0-preview2-1-003177

Three answered 4/3, 2017 at 8:48 Comment(5)
If I'm reading this correctly, that nested folder structure actually exists on disk?Selfpropelled
Also, I don't think you will be able to delete that folder with Windows Explorer since that program is limited in many ways to the MAX_PATH definition (260). You can write a program that will delete the folder for you. Edit: I suppose Robocopy works too. The real problem was the path being greater than MAX_PATHSelfpropelled
How did you publish it?Anabolite
What is the sdk version you are using?Befoul
@marc I have added this to the question.Three
F
7

I remember that I had same issue with preview2 of .NET Core SDK. It was fixed in either preview3 or preview4. And it is definitely fixed in .NET Core SDK 1.0. as mentioned by @Marc. Just update you SDK https://www.microsoft.com/net/download/core#/sdk.

With new SDK your project will be converted to csproj and MSBuild, so no project.json anymore.

EDIT: Project will automatically be converted in VS 2017, if you use command line tool you should apply dotnet-migrate command.

Formally answered 14/3, 2017 at 20:26 Comment(0)
B
2

Try updating the sdk to release version available now. Version 1.0 and version 1.1 are (at the time of this post) included in one package download from here. https://www.microsoft.com/net/download/core

as Mentioned by @Andrii Litvinov the migration will occur for VS2017. if you need help: Microsoft is offering free migration help for project.json to msbuild. (as of the time of this update march 15 2017]

check out: http://landinghub.visualstudio.com/migrate-dotnetcore

Befoul answered 10/3, 2017 at 14:58 Comment(4)
Where is the best place to find the string is need to add to the global.json file to indicate that it should used the latest SDK, i.e. the ""1.0.0-preview2-1-003177"" part?Three
@MichaelEdwards it is not pulled as part of the project it is part of the environment. You need to download and upgrade your Dev environment.Befoul
I have run the update EXE but I have no idea what to string value I should now use for the Global.json. Should this update automatically?Three
@MichaelEdwards the version is not required to be updated, as the development environment is pulling the libraries on the machine at compile time. the SDK is the net core app library that is used in your development library. Your global.json targets a specific version within the library of the SDK. since you had a preview version of the SDK previously, updating the actual SDK will ensure that anything that is used within your project is using production code.Befoul

© 2022 - 2024 — McMap. All rights reserved.