Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting an environment variable for the performance analyzer in visual studio 2013

I am currently trying to use the performance analyzer for my projects in Visual Studio 2013 (C++). The project runs in debug and release mode in Visual Studio with the Configuration Properties -> debugging -> Environment set to PATH=$(MYPATH);%path.

I use this to allow Visual Studio to find all the dlls I need which are scattered in different directories (for instance the boost dlls are all in one place on my computer).

For some reason, it does not work when using the Performance Wizard. I used the recommended CPU sampling and made sure my app could start on F5. When started from the performance wizard it says :

"The program can't start because mydll.dll is missing from your computer..."

I suspect the problem is with the environment variable the profiler uses on start. Is there anyway to tell the profiler to use a specific environment variable ?

I have searched for a while but I have not found any information on how to do that. Maybe I am not using the proper keywords ? I have read these but they do not really help :

  • clearly not what I want : https://msdn.microsoft.com/en-us/library/dd557761.aspx

  • won't fix the problem for the integrated profiler : How do I set Environmental variable for my application while profiling it under visual studio 2008

  • this is not the same problem : How do I run the Visual Studio 2012 memory profiler? I'm getting the error DA0002

  • I am using property sheets much like described here but for VS2013: C++ - Using environment variable in property sheet for Visual Studio 2010

**To be noted : if I copy the missing dlls in my .exe folder it works fine. This solution requires a lot of copying and I would rather avoid it if possible.

like image 485
ahesa Avatar asked Feb 03 '16 19:02

ahesa


People also ask

How do I set Environment Variables in Visual Studio?

To access this page, select a project node in Solution Explorer, select Project > Properties from the Visual Studio menu, and then select the Environment Variables tab. Specifies the name of an environment variable that will be used when the project is built or when the project is run from Visual Studio.

How do I run a performance profiler in Visual Studio?

Open the Performance Profiler by choosing Debug > Performance Profiler (or Alt + F2). For more information on using the CPU Usage or Memory usage tool in the Performance Profiler vs. the debugger-integrated tools, see Run profiling tools with or without the debugger.


1 Answers

After some more research I finally found this: https://connect.microsoft.com/VisualStudio/feedback/details/981900/profiler-does-not-respect-debugging-environment-variables-for-project

It seems it is a known issue and Microsoft won't be fixing it.

It seems my only choice is a copy script as a pre-build step. If anyone has a better solution, I'd still be interested to hear it!

like image 64
ahesa Avatar answered Sep 29 '22 18:09

ahesa