Glenn
Glenn

Reputation: 1855

Reference a reserved property from an inline task?

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.

Upvotes: 1

Views: 83

Answers (1)

stijn
stijn

Reputation: 35901

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).

Upvotes: 1

Related Questions