Hi,
I've been working on multiple apps in Visual Studio and the current project I'm working on started about a month ago. All worked great until I get the following 2 error messages today:
Files has invalid value "obj\Release\Klantvolgsysteem.Droid.C_.Projects.Klantvolgsysteem.Trunk.Klantvolgsysteem.Klantvolgsysteem.Klantvolgsysteem.UI.Pages.FormCategoriesPage.FormCategoriesPageView.xaml.g.cs". 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. Klantvolgsysteem.Droid
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. Klantvolgsysteem.Droid C:\Projects\Klantvolgsysteem\Trunk\Klantvolgsysteem\Klantvolgsysteem\Klantvolgsysteem\UI\Pages\FormCategoriesPage\FormCategoriesPageView.xaml
The error message is very clear, but I can not seem to find out why the error occurs, or how to solve it. The problem seems to be that when the app is build, the files in the obj folder get the full path to the source file as the file name... For example:
I have a xaml page named "HomePageView.xaml", the source file is located at:
"C:\Projects\Klantvolgsysteem\Trunk\Klantvolgsysteem\Klantvolgsysteem\Klantvolgsysteem\UI\Pages\HomePage\HomePageView.xaml"
Now, when the app is build, the obj folder will contain a file named
"Klantvolgsysteem.Droid.C_.Projects.Klantvolgsysteem.Trunk.Klantvolgsysteem.Klantvolgsysteem.Klantvolgsysteem.UI.Pages.HomePage.HomePageView.xaml.g.cs"
Which in the end has the full pathname:
"C:\Projects\Klantvolgsysteem\Trunk\Klantvolgsysteem\Klantvolgsysteem\Klantvolgsysteem.Droid\obj\Debug\Klantvolgsysteem.Droid.C_.Projects.Klantvolgsysteem.Trunk.Klantvolgsysteem.Klantvolgsysteem.Klantvolgsysteem.UI.Pages.HomePage.HomePageView.xaml.g.cs"
For this page in particular the filepath was not too long, but as shown in the error message the "FormCategoriesPageView" fails to build.
Now I would like to understand why the file in the obj folder gets these long filenames, because this is not the default behaviour.
Hi all!
As discussed above, the easiest way to avoid this issue is to move your source to the C:/ drive (or another location with fewer characters in the path) or install the long path tool. To help reduce the likelihood this error occurs, we have shortened up some of our generated path names behind-the-scenes. For more information, see Bug #30147. The fix should be included in a future release.
Thanks again for all the reports; keep 'em coming!
Answers
Just discoverd that the problem is not directly related to Visual Studio, but to an update of the Xamarin.Forms Nuget package. Downgrading to 1.4.3.6376 seems to resolve the errors, any upgrades (until 1.5.0-pre1 at the time of writing) seem to have have some influence on how the files in the obj folder are named.. not sure yet why this happens..
Added a comment on the Xamarin.Forms 1.5.0-pre1 thread about this problem.
As a workaround for the "Filepath too long" build exception, I just upgraded to the latest Xamarin.Forms and I replaced the target file for the new Xamarin.Forms (1.4.4 +) with the target file from the last working Xamarin.Forms Nuget package (1.4.3.6376).
This target file can be found in the Nuget Packages folder:
[Path-To-Project]\packages\Xamarin.Forms.1.4.3.6376\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets
This made it possible for me to build and deploy the project again, with my existing file and foldernames.
I discussed this workaround with @CodyBeyer via Xamarin Support mail. He told me this issue will probably be fixed in long term and that the suggested workaround can be used untill the issue is solved..
I have the same issue. Could you explain a bit more i didn't really understand your workaround. Also is there any information from Xamarin team on when this will be solved?
I had this problem for a long time.
My friend recommended me Long Path Tool for fixing this.
I am skeptic with this king of tool but I was wrong.
This tool can do anything.
You can downloaded on http://longpathtool.com/.
You wont regret.
I've the same problem with paths.
Solution is:
In this link https://bugzilla.xamarin.com/show_bug.cgi?id=18495
17 comment said "A general workaround in this case is to move your files closer to the root drive, thus shortening the path."
Xamarin 2.3.2..127 have same issue I have fed up with it, Kindly give me solution for this. My client app has stucked.
i have resolved this by adding package into android support library(components=>packages=>Add packages)
sometimes it is not because of the path issue...it may be becuase of your zip files corrupted....to resolve this download m2repository and placed in
appropriate folder
Nikita Minaev's post helped me...
Just copy your entire project folder to a new place on your computer that is closer to the root directory.
For example: If your project is currently located at :
Move the entire folder to something like:
This will shorten the path hopefully enough that you won't get this error again.
Hope this helps!
I just got this in Release mode while during Debug it works. What about move that limit to 500 characters? Would it lead to new problems?
I would suggest you to use Long Path Tool. Its an ideal tool for such situations.
In other words search google for Long Path Tool and it will resolve all of your problems.
Hi, I also encounter this problem but only Long path tool help me resolved the problem . I hope it helps.
Hi all!
As discussed above, the easiest way to avoid this issue is to move your source to the C:/ drive (or another location with fewer characters in the path) or install the long path tool. To help reduce the likelihood this error occurs, we have shortened up some of our generated path names behind-the-scenes. For more information, see Bug #30147. The fix should be included in a future release.
Thanks again for all the reports; keep 'em coming!
@PierceBoggan
Do you know of a way to find out what file is making this error?
or maybe you know off a way to set a temp. output/build folder...
The bug you link is "Fixed" but i still get this error even when my repo is "c/workspace/.... and i have updated xamarin for vs2017 to 4.7, the forms nuget and the android build nuget.
stacktrace:
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: The "ResolveLibraryProjectImports" task failed unexpectedly.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: System.IO.PathTooLongException: 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.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at System.IO.PathHelper.GetFullPathName()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at Xamarin.Tools.Zip.ZipEntry.DoExtract(IntPtr zipFile, String destinationPath, FileMode outputFileMode, EntryExtractEventArgs args)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at Xamarin.Tools.Zip.ZipEntry.Extract(String destinationDir, String destinationFileName, FileMode outputFileMode)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String destination, Action2 progressCallback) 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1060,2): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
Can try the Long Path Tool for best results.
Can anyone help me, I too have the same error.
Can I change the release path