How to get the value of the MSBuild property from a custom task?

Is there any way to access the value of the MSBuild property from a custom task?

I know that I can send them all, but it would be nice not to do this :) I am trying to do this from the TFS assembly .

Or is there any way to access the “build script” currently running? Maybe, as an object model, and from there to get what I need?

+3
source share
1 answer

That should do the job.

  public override bool Execute()
  {
    string projectFile = BuildEngine.ProjectFileOfTaskNode;

    Engine buildEngine = new Engine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory());

    Project project = new Project(buildEngine);
    project.Load(projectFile);
    foreach(var o in project.EvaluatedProperties)
    {
      // Use properties
    }

    return true;
  }
+2
source

Source: https://habr.com/ru/post/1704185/


All Articles