Visual Studio gone bonkers: 'The directory name is invalid' error when trying to compile

你说的曾经没有我的故事 提交于 2019-11-30 08:50:39
Abel

Solved! Thanks for the input, I meanwhile found a solution. The cause is rare, but it may happen to others, so I decided to answer my own question here:

Cause

An incorrect or inaccessible %TEMP% location, or an inaccessible %USERPROFILE% path.

I had moved these paths to a faster SSD drive to speed up compiling. The drive crashed and the OS did not find it anymore (as reported on ServerFault here) and consequently, the moved locations (internet caches, my documents and temp) had become inaccessible.

The error mentioned by Visual Studio is misleading: it has nothing to do with the name of the file (while I'm still wondering why it was querying the executable as a directory), the error was about the %TEMP% location being bad.

Solution

Fix the %USERPROFILE% or %TEMP% environment variables, (in case you forgot, it's here: System > Advanced > Environment Variables).

Note: The typical and default TEMP setting is to use the USERPROFILE environment variable as in the default %USERPROFILE%\AppData\Local\Temp. This works, but only if in the registry, the key under HKCU\Environment\TEMP is of the type REG_EXPAND_SZ and not REG_SZ.

Make sure that you have enough free space in your drive, I have experienced the same issue, got it resolved after allocating more free space.

user_v

I was also getting a similar error Could not write to output file '..........................' -- 'The directory name is invalid. '

I tried deleting folder, changing Environment variables as suggested above (i.e. %USERPROFILE% or %TEMP%), but nothing seemed to work. When I again looked at the output in the Output Pane/Window in VS 2008, I found the following line

"c:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(3397,13): error MSB6003: The specified task executable "cmd.exe" could not be run. Could not find directory path: C:\Users\Administrator\AppData\Local\Temp\2\"

This line led me to the solution. I just created the non existing 2 folder in "C:\Users\Administrator\AppData\Local\Temp" folder.

%USERPROFILE% = C:\Users\Administrator\AppData\Local\Temp

By the way we noticed this only on all of our Cloud instances. Something do with virualization? .. Dont know really

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!