Question

Is there some way to access the value of a msbuild property from a custom task? I know I can send them all in, but it would be nice not to :) Trying to do this from a tfs build.

Or is there som way to access the "build script" currently running? Maybe like an object model and from there get what I need?

Was it helpful?

Solution

This 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;
  }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top