Publish fails in Visual Studio 2019

324 views Asked by At

We are just moving to using Visual Studio 2019 at our workplace.
One of the projects we have already started using VS 2019 with is an ASP.NET Core 1 project.
We have done the necessary adjustments and stuff and the project builds and runs just fine.
The problem starts when we try to publish the web app project. Long story short, I believe the problem is because the out path is too long. Here's the output of one of the errors we get when publishing the app (there are 18 errors like this one in total):

Unable to copy file  
"C:\Dev\ashilon\DigitalRural\Main\Mchp.DigitalRural.Portal\wwwroot\app\main\educationPlaceWorkers\views\educationPlaceWorkersDetails\tabs\educationAndCourses\components\educationCoursesList\educationCoursesList.component.js" to  
"C:\Dev\ashilon\DigitalRural\Main\Mchp.DigitalRural.Portal\obj\Release\net461\win7-x86\PubTmp\Out\wwwroot\app\main\educationPlaceWorkers\views\educationPlaceWorkersDetails\tabs\educationAndCourses\components\educationCoursesList\educationCoursesList.component.js".  
Could not find a part of the path  
'C:\Dev\ashilon\DigitalRural\Main\Mchp.DigitalRural.Portal\obj\Release\net461\win7-x86\PubTmp\Out\wwwroot\app\main\educationPlaceWorkers\views\educationPlaceWorkersDetails\tabs\educationAndCourses\components\educationCoursesList\educationCoursesList.component.js'.  

As you can see the output path is very long and is 261 characters long, which I think is more than the maximum allowed in Windows, or Visual Studio, not sure where the limit is.
Is there a setting somewhere in Visual Studio or elsewhere that I can set that tells the publish process to start from lets say C:\Drop instead of the directory of the project? That is, if the problem is with the path. If the error is not related to the path, then I would love to get solution to that.
Thank you very much.
ashilon

1

There are 1 answers

1
dev-masih On

You can turn on long path support inside your windows registry like:

The registry key HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled (Type: REG_DWORD) must exist and be set to 1. The key's value will be cached by the system so better to restart windows after it. source

Or you can change the output path for the project directly from solution Properties, Built tab and output path. source

But generally, MSBuild is managed application and CLR have restriction on path/filename length and it's not safe to have a long path inside your visual studio project, so cutting down the file's path or move the base visual studio project to a shorter path is the better option here.