Relative paths with environment variables
-
Monday, October 10, 2011 6:38 AM
We have migrated a C++ project from Visual Studio 2005 to Visual Studio 2010 (+service pack 1), but now have problems with relative paths (that is when selecting a file in Solution Explorer and showing File Properties).
The problem is when using environment variables to specify paths. This works fine in Visual Studio 2005 and even when migrating to 2010 the relative paths are kept for existing files. But when including new files and trying to set the relative path the environment variables are not parsed correctly.
For example, if I specify the relative path to:
"$(PATH)/history.cpp"
When pressing enter, it's immediately replaced with
"%2524%2528PATH%2529\history.cpp"
This was not the case in Visual Studio 2005 where the $ and () were kept, but more importantly - the full path was at the same time changed to:
"C:\NEW_PATH\history.cpp" (depending on the environment variable PATH of each computer, in this case "C:\NEW_PATH").
However, in VS 2010 the relative path is only appended to the end of the original path, which sets the full path to:"C:\Projects\myProject\$(PATH)\history.cpp"
Is this a bug in VS 2010? Any workaround available? Please help, we really need this flexibility.
All Replies
-
Tuesday, October 11, 2011 9:05 AMModerator
Hi Williamsson,
Please try to create a new project in VS2010, do we have the problem? Since there are many changes when you upgrade the c++ project from VS2005 to VS2010. You can refer to the following link:
Visual Studio 2010 C++ Project Upgrade Guide:
http://blogs.msdn.com/b/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx
If this issue still exists, you can try the following workarounds:
1. If we reboot the operating system to safe mode, do we have the problem? This can help to isolate whether any other applications are interfering with Visual Studio. Note that some features (like IIS) are not available under safe mode. Please check whether this can apply or not. In addition to safe mode, we can also suggest “clean boot”: http://support.microsoft.com/kb/310353.
2. If we create a new user account, do we have the problem? This can help to isolate user profile corruption related causes.
3. If we disable Add-ins (e.g. “Tools” | “Add-in Manager”) and run “devenv.exe /safemode”, do we still have the problem? This can eliminate the possibility that third party Add-ins are causing problems.
4. If we use “devenv.exe /resetsettings”, does it solve the problem? It restores Visual Studio default settings.
5. If the problem remains, we can use Visual Studio Setup Wizard (via Control Panel) to repair Visual Studio. It can restore the Visual Studio Installation into its original state.
Best regards,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
Wednesday, October 12, 2011 7:29 AM
Lucy, thank you for replying.
Yes, it happens every time in a new project. We have tried it on several computers. It's not related to upgrading a project - it's just that it always works in VS 2005, so something has changed with Visual Studio 2010 (or possibly in our environment, if any of your suggested workarounds would fix this). Here's the result of our investigation:
1. Same problem when running Windows 7 in safe mode.2. Didn't try yet, but all programmers (different computers and user accounts) in the team experience this problem so it seems unlikely that all profiles would be corrupted.
3. There are no Add-ins in my list, and running with /safemode didn't help (I tested with a new project).
4 & 5. Didn't try yet. I'd rather not drop my settings unless there is any way to restore them immediately after this test (?).
Please, can you do a quick test to confirm that you do not have this problem also? Just select any file in the Solution Explorer (and press Alt+Enter if the properties window is not already visible). Input any existing environment variable into the "Relative Path" property. The value (not the name) of the environment variable should show in the "Full Path" property (this is how it works in VS 2005).
If it indeed works on your system, I will continue with 2, 4 and 5 to isolate the problem.
-
Thursday, October 13, 2011 5:47 AMModerator
Hi Williamsson,
I cannot reproduce this issue in my local computer. Which language do you use in you windows 7 system?
Please try to change it to English. And try the 2, 4,5 solutions.
Thank you for your understanding!
Best regards,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Edited by lucy-liuModerator Thursday, October 13, 2011 5:47 AM

