0

I'm trying to create a new C++ project in VS 10, and can't even get an empty project to load from the template. I get an error...

The "exists" function only accepts a scalar value but its argument "$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" evaluates to "{~}" which is not a scalar value.

The {~} value is what I have stored in the LOCALAPPDATA variable in the computer Environment Variables, concatenated with "\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props" at the end.

I'm reluctant to go changing any template files without understanding what's going on.

Random
  • 1,896
  • 3
  • 21
  • 33
  • Are you observing this behavior in Windows 7? I'm looking right now at my list of environment variables and LOCALAPPDATA is not explicitly defined. It seems to default to C:\Users\user_name\AppData\Local. Maybe some strange application that you installed decided to redefine it for some reason... As a test, try typing dir %LOCALAPPDATA% in a console and let me know what is the output. – Mihai Todor Jul 27 '12 at 19:29
  • Windows XP. There are some file paths in there for additional applications, but I've tried changing the contents to try to get different results. Haven't tried an empty string, though. – Random Jul 27 '12 at 20:56

2 Answers2

0

Well, it looks like Windows XP doesn't provide any default value for this variable and "~" is definitely not a valid directory on your PC. Try to set it as described here, and maybe you'll get lucky. VS2010 had some bug related to this. Perhaps you also need to upgrade it to SP1.

Mihai Todor
  • 8,014
  • 9
  • 49
  • 86
0

The links provided by @Mihai gave the information I needed to find a solution. The problem was that LocalAppData didn't have the value it was looking for (just what the error message says). I couldn't change that data because other apps had modified it for their own purposes (the value wasn't "~", that was a placeholder for this post).

Instead, I opened the .vcxproj file in Notepad, and modified the ImportGroup nodes causing the error. Instead of the attribute:

Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"

... it now reads

Condition="exists('$(UserProfile)\Local Settings\Application Data\Microsoft.Cpp.$(Platform).user.props')"

The project now loads.

Random
  • 1,896
  • 3
  • 21
  • 33