MsBuild: get the current target directory

I have an msbuild target and it has an Import tag like this:

<Import Project="$(MSBuildExtensionsPath)\Company\Company.LifeCycle.targets" /> 

In the contents of the Company.LifeCycle.targets file, how can I get the program version of the current directory (in this case: C: \ Program Files \ MsBuild \ Company ) ??

I am using VS 2008, .NET 3.5

Edit: I saw the link, How to get the current directory in the msbuild script? but not suitable for me: $ (MSBuildProjectDirectory me this value, C: \ Work \ Company \ Projects \ Test001 \ ProyectSW3

+6
directory path msbuild targets msbuild-task
source share
2 answers

With MSBuild 4, you can use the new "MSBuildThisFileDirectory" property, see my blog http://sedodream.com/2010/03/11/MSBuild40ReservedProperties.aspx . If you are not using MSBuild 4, you cannot do this easily.

+8
source share

Your question has already been given in another post here: MsBuild: Get the current target directory . I hope the answers there will satisfy you.

Basically you can use MSBuildProjectDirectory , which will provide you with the path to your current project file, and you can do it.

+2
source share

All Articles