Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

altering PATH via property sheets when firing up a debugger in visual studio

I have a set of property sheets which define include and link paths for commonly used 3rd partly libraries in my c++ project. Is there a way to also define PATH in those pages for the executable to find the binaries when I fire it up in a debugger ?

Edit: I noticed that if I add the following to a property sheet (via notepad)

<PropertyGroup>
   <VCRedistPaths>c:\path\bin\$(Platform);$(VCRedistPaths)</VCRedistPaths>
</PropertyGroup>

Then I get c:\path\bin\Win32 (for instance) path appended when app is run under debugger, but the problem here is that visual studio doesn't detect my changes instantly (if I change the path in property sheet or append another property sheet with another path) and I have to restart visual studio for the changes to pickup. Anyone knows if this is possible to avoid ?

like image 352
Sergey Avatar asked Oct 28 '12 13:10

Sergey


Video Answer


1 Answers

Here is an example property sheet that worked for me in VS2010:

mysheet.props

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <LocalDebuggerEnvironment>PATH=%MYLIB_ROOT%\bin;%PATH%$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <ClCompile>
      <AdditionalIncludeDirectories>$(MYLIB_ROOT)\include</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <AdditionalLibraryDirectories>$(MYLIB_ROOT)\lib</AdditionalLibraryDirectories>
      <AdditionalDependencies>mylib.lib</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup />
</Project>

I get the idea of using LocalDebuggerEnvironment from manually setting the PATH environment variable in the project's properties:

proj_prop_env_var

This change was reflected in the *.vcxproj.user project option file, which I then replicated in my own property sheet.

HTH

like image 97
Amro Avatar answered Oct 20 '22 10:10

Amro