From a task, we'd like to access the global properties of the current project. This is so you can do evaluations outside of MSBuild but part of a task. The global properties passed from the command-line are not made available to any running component like tasks at the moment.
I spoke with @rainersigwald and we thought of two possible implementations:
Add a new GetGlobalProperties task
A new task could be made to fetch global properties into an item group. This item group could then be passed to the task that needs the values:
<Project>
<Target Name="Example">
<!--
Call a new task that gets the global properties stores them in a return ItemGroup
-->
<GetProjectGlobalProperties>
<Output TaskParameter="GlobalProperties" ItemName="CurrentProjectGlobalProperties" />
</GetProjectGlobalProperties>
<!-- Call my task that takes the item containing global properties -->
<MyTask GlobalProperties="@(CurrentProjectGlobalProperties)" />
</Target>
</Project>
The nice thing about this implementation is that logs would clearly show that global properties were fetched and passed along.
One drawback of this approach is that escaping could be difficult since things need to made available as strings for items.
Add IBuildEngine6
We could also implement a new interface to extend IBuildEngine which would have a method like:
public interface IBuildEngine6 : IBuildEngine5
{
IReadOnlyDictionary<string, string> GetGlobalProperties();
}
This method would return a copy of the global properties and the task could call it to get them.
The drawback of this implementation is that its not as clear in any logs that global properties were fetched and used.
From a task, we'd like to access the global properties of the current project. This is so you can do evaluations outside of MSBuild but part of a task. The global properties passed from the command-line are not made available to any running component like tasks at the moment.
I spoke with @rainersigwald and we thought of two possible implementations:
Add a new
GetGlobalPropertiestaskA new task could be made to fetch global properties into an item group. This item group could then be passed to the task that needs the values:
The nice thing about this implementation is that logs would clearly show that global properties were fetched and passed along.
One drawback of this approach is that escaping could be difficult since things need to made available as strings for items.
Add
IBuildEngine6We could also implement a new interface to extend
IBuildEnginewhich would have a method like:This method would return a copy of the global properties and the task could call it to get them.
The drawback of this implementation is that its not as clear in any logs that global properties were fetched and used.