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

Commit 174f998

Browse files
committed
[MSBuild] Add ApiIntersect keep interop and internal ctor flags
The flags to keep the marshalling/interop information and keep internal constructors can now be set in the MSBuild project.
1 parent c91825c commit 174f998

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public class ApiIntersect : ToolTask
1919

2020
public ITaskItem[] ExcludeType { get; set; }
2121

22+
public string KeepInternalConstructors { get; set; }
23+
24+
public string KeepMarshalling { get; set; }
25+
2226
[Required]
2327
public ITaskItem RootOutputDirectory { get; set; }
2428

@@ -74,6 +78,10 @@ protected override string GenerateCommandLineCommands()
7478
builder.AppendTextUnquoted("\"");
7579
}
7680

81+
AppendSwitchIfTrue(builder, "-k", KeepInternalConstructors);
82+
83+
AppendSwitchIfTrue(builder, "-m", KeepMarshalling);
84+
7785
return builder.ToString();
7886
}
7987

@@ -120,5 +128,15 @@ static string GetPortableRootDirectory()
120128
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86, Environment.SpecialFolderOption.DoNotVerify),
121129
@"Reference Assemblies\Microsoft\Framework\.NETPortable");
122130
}
131+
132+
static void AppendSwitchIfTrue(CommandLineBuilder builder, string switchName, string value)
133+
{
134+
if (string.IsNullOrEmpty(value))
135+
return;
136+
137+
bool result;
138+
if (bool.TryParse(value, out result))
139+
builder.AppendSwitch(switchName);
140+
}
123141
}
124142
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ Copyright (c) .NET Foundation. All rights reserved.
523523
IntersectionAssembly="@(IntersectionAssembly)"
524524
ReferencePath="$(IntersectionAssemblyReferencePath)"
525525
ExcludeType="$(IntersectionExcludeType)"
526+
KeepInternalConstructors="$(IntersectionKeepInternalConstructors)"
527+
KeepMarshalling="$(IntersectionKeepMarshalling)"
526528
ToolPath="$(ApiIntersectToolPath)"
527529
ToolExe="$(ApiIntersectToolExe)">
528530
<Output TaskParameter="OutputDirectory" ItemName="_ReferenceAssemblyBuildInfo" />

0 commit comments

Comments
 (0)