Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2015: Could not write lines to file "obj\Debug\\TemporaryGeneratedFile

Using VS2015 I am compiling some code that worked on VS2013 (on Win8). Now in VS2015 I am getting the following error:

Could not write lines to file "obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs". Could not find a part of the path 'C:\dev\Projects\BAG\Importer\Data\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs'. Data

I have ONLY Visual Studio 2015 installed on a completely clean machine. Targeting Framework 4.6

I have read some other SO questions that hint to switch off code analysis. I did this as well to no avail.

How can I proceed to track this error down?

like image 881
Paul Avatar asked Nov 07 '15 22:11

Paul


People also ask

Could not write lines to file obj Debug?

To resolve the issue I would go to the folder and manually delete the obj folder and try to rebuild it. If you cannot delete the folder, close your VS and try again, if it still does not work, run iisreset and try, then if it still does not work, restart your machine and delete.

Could not write lines to file Filelistabsolute TXT access to the path Filelistabsolute TXT is denied?

Possible Cause: To resolve this issue: Delete the "obj" and "bin" folder in source control. Delete the "obj" and "bin" folders on your hard disk.


2 Answers

I just ran into the same issue on Windows 10 1903 and Visual Studio 2019 PREVIEW.

The error message is correct to a degree - the max length is indeed exceeded though it is not necessary to be 260 chars. It is some default setting of Windows which is read-write only for Windows 10 1903 and up. So if you happen to have Such.A.Long.Project.Name.Which.Might.Be.Buried.Somewhere.Deep.In.Your.Filesystem.csproj, the build might throw because it tries to generate other files, based on the project names so you might end up with something like obj\Debug\netstandard2.0\Such.A.Long.Project.Name.Which.Might.Be.Buried.Somewhere.Deep.In.Your.Filesystem.csproj.FileList.txt which violates the default filename length constraint.

The solution is to enable the long Win32 paths in the Group Policy (or directly poke the registry, which I'm not going to explain here).

The path to the GP setting is: Computer Configuration -> Administrative Templates -> System -> Filesystem. There you will find the Enable Win32 long paths setting. Enable it, do gpupdate (or just restart the machine), and you're good to go.

like image 136
Bozhidar Stoyneff Avatar answered Oct 07 '22 08:10

Bozhidar Stoyneff


Based on my experience removing the obj subfolder under each project was enough.

Here some people solved the problem in the same way.

like image 42
juagicre Avatar answered Oct 07 '22 07:10

juagicre