Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 2fa6c67

Browse files
authored
Merge pull request #87 from mrward/dev-api-intersect-reference-paths
Support all ApiIntersect parameters api
2 parents defabfd + 9de8081 commit 2fa6c67

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

src/Build/NuGet.Build.Packaging.Tasks/ApiIntersect.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ public class ApiIntersect : ToolTask
1515
[Required]
1616
public ITaskItem[] IntersectionAssembly { get; set; }
1717

18+
public ITaskItem[] ReferencePath { get; set; }
19+
20+
public ITaskItem[] ExcludeType { get; set; }
21+
22+
public ITaskItem[] RemoveAbstractTypeMembers { get; set; }
23+
24+
public ITaskItem[] ExcludeAssembly { get; set; }
25+
26+
public string KeepInternalConstructors { get; set; }
27+
28+
public string KeepMarshalling { get; set; }
29+
1830
[Required]
1931
public ITaskItem RootOutputDirectory { get; set; }
2032

@@ -56,6 +68,38 @@ protected override string GenerateCommandLineCommands()
5668
builder.AppendFileNameIfNotNull(assembly.ItemSpec);
5769
}
5870

71+
foreach (var referencePath in ReferencePath.NullAsEmpty())
72+
{
73+
builder.AppendSwitch("-r");
74+
builder.AppendFileNameIfNotNull(referencePath.ItemSpec);
75+
}
76+
77+
foreach (var excludeType in ExcludeType.NullAsEmpty())
78+
{
79+
builder.AppendSwitch("-b");
80+
builder.AppendTextUnquoted(" \"");
81+
builder.AppendTextUnquoted(excludeType.ItemSpec);
82+
builder.AppendTextUnquoted("\"");
83+
}
84+
85+
foreach (var removeAbstractType in RemoveAbstractTypeMembers.NullAsEmpty())
86+
{
87+
builder.AppendSwitch("-a");
88+
builder.AppendTextUnquoted(" \"");
89+
builder.AppendTextUnquoted(removeAbstractType.ItemSpec);
90+
builder.AppendTextUnquoted("\"");
91+
}
92+
93+
foreach (var assembly in ExcludeAssembly.NullAsEmpty())
94+
{
95+
builder.AppendSwitch("-e");
96+
builder.AppendFileNameIfNotNull(assembly.ItemSpec);
97+
}
98+
99+
AppendSwitchIfTrue(builder, "-k", KeepInternalConstructors);
100+
101+
AppendSwitchIfTrue(builder, "-m", KeepMarshalling);
102+
59103
return builder.ToString();
60104
}
61105

@@ -102,5 +146,15 @@ static string GetPortableRootDirectory()
102146
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86, Environment.SpecialFolderOption.DoNotVerify),
103147
@"Reference Assemblies\Microsoft\Framework\.NETPortable");
104148
}
149+
150+
static void AppendSwitchIfTrue(CommandLineBuilder builder, string switchName, string value)
151+
{
152+
if (string.IsNullOrEmpty(value))
153+
return;
154+
155+
bool result;
156+
if (bool.TryParse(value, out result))
157+
builder.AppendSwitch(switchName);
158+
}
105159
}
106160
}

src/Build/NuGet.Build.Packaging.Tasks/NuGet.Build.Packaging.targets

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,25 @@ Copyright (c) .NET Foundation. All rights reserved.
517517
Inputs="@(IntersectionAssembly)"
518518
Outputs="@(_ReferenceAssemblyTargetPath)">
519519

520+
<PropertyGroup>
521+
<EnableDefaultIntersectionAssemblyReferencePath Condition="'$(EnableDefaultIntersectionAssemblyReferencePath)' == ''">true</EnableDefaultIntersectionAssemblyReferencePath>
522+
</PropertyGroup>
523+
524+
<ItemGroup>
525+
<_IntersectionReferencePath Include="@(IntersectionAssembly->'%(RootDir)%(Directory)')" Condition="'$(EnableDefaultIntersectionAssemblyReferencePath)' == 'true'" />
526+
<_IntersectionReferencePath Include="$(IntersectionAssemblyReferencePath)" />
527+
</ItemGroup>
528+
520529
<ApiIntersect
521530
Framework="%(ReferenceAssemblyFramework.Identity)"
522531
RootOutputDirectory="$(IntermediateOutputPath)"
523532
IntersectionAssembly="@(IntersectionAssembly)"
533+
ReferencePath="@(_IntersectionReferencePath)"
534+
ExcludeType="$(IntersectionExcludeType)"
535+
RemoveAbstractTypeMembers="$(IntersectionRemoveAbstractTypeMembers)"
536+
ExcludeAssembly="@(IntersectionExcludeAssembly)"
537+
KeepInternalConstructors="$(IntersectionKeepInternalConstructors)"
538+
KeepMarshalling="$(IntersectionKeepMarshalling)"
524539
ToolPath="$(ApiIntersectToolPath)"
525540
ToolExe="$(ApiIntersectToolExe)">
526541
<Output TaskParameter="OutputDirectory" ItemName="_ReferenceAssemblyBuildInfo" />

0 commit comments

Comments
 (0)