views:

395

answers:

1

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?

A: 

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;
  }
madgnome
This helped, but I had to create a new engine. The BuildEngine property only contained an EngineProxy which I was unable to case to an Engine... And when i created a new engine non of the properties vas evaluated. So i just got out $(something). Suggestions? :)
Oddleif
Unable to cast I ment, not case :)
Oddleif
My answer is edited, this solution works for me.
madgnome