Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

visual studio macro with the path of a props file

The short question:

I want to be able to use the path of the props file as a macro from inside the props file (like the ability to reference the project directory as $(ProjectDir) )

The long question

I use props files to add reference to various 3rd party libraries.

This is simple if I can specify an absolute path to the 3rd party library.

However, I want to specify a relative path - as different team members use different location for the source control tree. is there a method to add such relative paths to the props file?

specifying a path relative to the project directory isn't a good solution either, as the location of projects isn't fixed (so for one project I would need $(SolutionDir)\..\XXXX and for another one I would need $(SolutionDir)\..\..\XXXX

like image 734
Ophir Yoktan Avatar asked May 01 '12 15:05

Ophir Yoktan


People also ask

Where is directory build props?

Build. props in the root folder that contains your source code and solution file, is executed when MSBuild runs and Microsoft. Common. props searches your directory structure for the Directory.

Where are Visual Studio macros stored?

A user-defined macro is stored in a property sheet. If your project doesn't already contain a property sheet, you can create one by following the steps under Share or reuse Visual Studio project settings.

Where is the Vcxproj file?

vcxproj file by using any text or XML editor. You can view it in Visual Studio by right-clicking on the project in Solution Explorer, choosing Unload project and then choosing Edit Foo.

What is $( SolutionDir?

$(SolutionDir) This is the Path of your working Solution Directory. $(ConfigurationName) This is the option of setting when you compile project,for example Debug or Release.


1 Answers

The solution is: $(MSBuildThisFileFullPath) (or, rather $(MSBuildThisFileDirectory)). (Which is noted in passing here.)

If this is used within a property sheet file (.props) it will refer to this property file/dir itself. (Note: When used on the .vcxproj level, it will refer to the project file/dir.

Tested with VS2013 RC and VS2010.

like image 175
Martin Ba Avatar answered Nov 15 '22 22:11

Martin Ba