Visual studio relative path macro to projects location - visual-studio-2010

Is there a macro in Visual Studio 2010 which refers to the "Projects location" as specified under Options > Projects and Solutions > General? I would like to set up some includes relative to this location rather than specifying an absolute path.
For example, if my default project location is:
c:\projects
And I have a project at:
c:\projects\solution1\project1
I would like to do something like this:
$(ProjectsDir)\<mypath>
The closest I've found is to do:
$(SolutionDir)\..\<mypath>
But that means that if I ever relocate my solution, the path will break.

Related

How can I force a complete rewrite of the csproj file in VS 2019?

I have two of these warnings in my project. They are identical. I have shortened the full path for brevity.
Load of property 'ReferencePath' failed. Cannot add
"...\packages\DeltaCompressionDotNet.2.0.1\lib\netstandard1.3' as a
reference path as it is relative. Please specify an absolute path.
When I look up help for it the cause is blamed on "...editing the project file by hand." which I did not do.
How can I make VS 2019 Enterprise regenerate the csproj file?

Including Text Files in Build of Visual Studio 2013 Solution

I want a text file to be included in the build, so I used Add->Existing Item to load it into the solution. However, I can't open it in a ifstream unless I use an absolute path to the original file. I set Excluded from Build to No and Item Type to Text. For a relative path to file.txt, I tried "file.txt", "../file.txt", "/file.txt" but none of them work. I don't know if it's my syntax that's wrong, or if it's just not included in the build, or both.
The program is in C++.
I came across some old answers that mentioned an option to specify additional directories in the build, but I don't see it in Visual Studio 2013.

How to set relative include path in Visual Studio 2010?

I wrote a library called MyLib with some Visual Studio projects in MyLib\Samples\, and the include files reside in MyLib\inc. In order to make these include files accessible in the projects, I need to add their path in the project properties.
I want to use a relative path, so that I don't need to change the properties each time I move the whole library folder to other places. But what does the relative path look like? For example, one of the project path is: ...\MyLib\Samples\proj1, how do I represent the ...\MyLib\inc relative to the project path?
Use the $(SolutionDir) or $(ProjectDir) MSBuild properties to root the paths. These are replaced at build-time with the directory in which the Solution and Project are located, respectively.
What you're looking for is custom properties for your project.
Visual Studio has support for defining custom properties which you can subsequently use in macro expansions in your include path, for example.
Here's an example of how it looks like:

Including an external library in Visual Studio 2010 project

I'm new to visual studio and can't seem to find an answer to this anywhere.
I'm working on a project in VC++ with VS2010. I have another project that builds into a .lib file set up as a reference, but can't figure out how to actually include the headers. Google has proved useless. Please help!
Generally this is done by adding the directory where the include files live to the project's "Additional Include Directories" property (in the "C/C++ | General" property page).
Note that the location can be a relative path if the different projects will always be at the same file system level relative to one another, or they can use VS macros or environment variables.

why referenced c# dll is in full path in VS2010?

why the referenced dll of a c# project is in full path? when i move the source code to a different pc, the reference is broken.
Visual Studio tries not to use full paths to DLL's whenever possible to avoid situations like this. It tries to reference DLL's with a relative path if possible.
Is there a relative path in this scenario that would work? If so could you try editing the .csproj file manually and setting it to use this relative path and see what happens?

Resources