New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support gathering additional arbitrary properties from referenced projects #5994
Changes from 2 commits
19284a3
9ca4269
63cd06e
8682eb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.Build.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
|
||
namespace Microsoft.Build.Tasks | ||
{ | ||
public class CombineTargetFrameworkInfoProperties : TaskExtension | ||
{ | ||
public string RootElementName { get; set; } | ||
|
||
public ITaskItem[] PropertiesAndValues { get; set; } | ||
|
||
[Output] | ||
public string Result { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
XElement root = new XElement(RootElementName); | ||
|
||
foreach (var item in PropertiesAndValues) | ||
{ | ||
root.Add(new XElement(item.ItemSpec, item.GetMetadata("Value"))); | ||
} | ||
|
||
Result = root.ToString(); | ||
|
||
return true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return !HasLoggedErrors? Same below. |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.Build.Framework; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copyright header |
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
|
||
namespace Microsoft.Build.Tasks | ||
{ | ||
public class CombineXmlElements : TaskExtension | ||
{ | ||
public string RootElementName { get; set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Required annotations for these? |
||
|
||
public ITaskItem [] XmlElements { get; set; } | ||
|
||
[Output] | ||
public string Result { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
XElement root = new XElement(RootElementName); | ||
|
||
foreach (var item in XmlElements) | ||
{ | ||
root.Add(XElement.Parse(item.ItemSpec)); | ||
} | ||
|
||
Result = root.ToString(); | ||
|
||
return true; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1725,11 +1725,19 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<Error Condition="'$(IsCrossTargetingBuild)' == 'true'" | ||
Text="Internal MSBuild error: Non-CrossTargeting GetTargetFrameworks target should not be used in cross targeting (outer) build" /> | ||
|
||
<CombineXmlElements | ||
RootElementName="AdditionalProjectProperties" | ||
XmlElements="@(_TargetFrameworkInfo->'%(AdditionalPropertiesFromProject)')"> | ||
<Output TaskParameter="Result" | ||
PropertyName="_AdditionalPropertiesFromProject"/> | ||
</CombineXmlElements> | ||
|
||
<ItemGroup> | ||
<_ThisProjectBuildMetadata Include="$(MSBuildProjectFullPath)"> | ||
<TargetFrameworks>@(_TargetFrameworkInfo)</TargetFrameworks> | ||
<TargetFrameworkMonikers>@(_TargetFrameworkInfo->'%(TargetFrameworkMonikers)')</TargetFrameworkMonikers> | ||
<TargetPlatformMonikers>@(_TargetFrameworkInfo->'%(TargetPlatformMonikers)')</TargetPlatformMonikers> | ||
<AdditionalPropertiesFromProject>$(_AdditionalPropertiesFromProject)</AdditionalPropertiesFromProject> | ||
|
||
<HasSingleTargetFramework>true</HasSingleTargetFramework> | ||
|
||
|
@@ -1743,12 +1751,26 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |
<Target Name="GetTargetFrameworksWithPlatformForSingleTargetFramework" | ||
Returns="@(_TargetFrameworkInfo)"> | ||
|
||
<ItemGroup> | ||
<_AdditionalTargetFrameworkInfoPropertyWithValue Include="@(AdditionalTargetFrameworkInfoProperty)"> | ||
<Value>$(%(AdditionalTargetFrameworkInfoProperty.Identity))</Value> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't realize you could have a metadata reference as an identifier for a property. Neat! |
||
</_AdditionalTargetFrameworkInfoPropertyWithValue> | ||
</ItemGroup> | ||
|
||
<CombineTargetFrameworkInfoProperties | ||
RootElementName="$(TargetFramework)" | ||
PropertiesAndValues="@(_AdditionalTargetFrameworkInfoPropertyWithValue)"> | ||
<Output TaskParameter="Result" | ||
PropertyName="_AdditionalTargetFrameworkInfoProperties"/> | ||
</CombineTargetFrameworkInfoProperties> | ||
|
||
<ItemGroup> | ||
<_TargetFrameworkInfo Include="$(TargetFramework)"> | ||
<TargetFrameworks>$(TargetFramework)</TargetFrameworks> | ||
<TargetFrameworkMonikers>$(TargetFrameworkMoniker)</TargetFrameworkMonikers> | ||
<TargetPlatformMonikers>$(TargetPlatformMoniker)</TargetPlatformMonikers> | ||
<TargetPlatformMonikers Condition="'$(TargetPlatformMoniker)' == ''">None</TargetPlatformMonikers> | ||
<AdditionalPropertiesFromProject>$(_AdditionalTargetFrameworkInfoProperties)</AdditionalPropertiesFromProject> | ||
</_TargetFrameworkInfo> | ||
</ItemGroup> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright header