1

Is it possible to reference one of these properties from an inline task?

https://msdn.microsoft.com/en-us/library/ms164309.aspx?f=255&MSPPError=-2147217396

I'd like to get the value of MSBuildThisFile from the inline C# code.

Glenn
  • 1,687
  • 15
  • 21

1 Answers1

1

You can't access all of those reserved properties in the same way, but the path of the project happens to be easily accessible as a string via BuildEngine.ProjectFileOfTaskNode (see documentation: inline task code runs as an ITask, and ITask has a BuildEngine property of type IBuildEngine):

<![CDATA[
Log.LogMessage(BuildEngine.ProjectFileOfTaskNode);  
]]>  

For other properties you'll have to resolve to methods like How to access the MSBuild 's properties list when coding a custom task?, or pass them a an argument (which is the better solution if you only need a couple of them).

Community
  • 1
  • 1
stijn
  • 34,664
  • 13
  • 111
  • 163
  • Thank you and thanks for the documentation reference. Sorry I missed in the docs that an inline task implements ITask. – Glenn Dec 07 '16 at 16:57
  • 1
    No problem :] But it's interesting to know, also the difference between the different code types. – stijn Dec 07 '16 at 19:31