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
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.
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.
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.
$(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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With