Skip to content

Commit 3416fb5

Browse files
dellis1972jonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks] Fix PCL _DesignTimeFacadeAssemblies Detetion. (#867)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=57849 We are sometimes getting duplicate assembly references in the `@(ReferencePath)` ItemGroup. This is comming from the DesignTime Facade assembly detection. Looking at the msbuild targets [1], they do duplicate detection by checking the `%(Filename)` does not exist in the assembly list already. So we should do the same in our Xamarin.Android.PCLSupport.targets. We use the `CreateItem` Task rather than `ItemGroup`. This is because it seems xbuild does NOT like it when you use `%(ItemGroup.MetaData)` when defining additonal metadata using the `ItemGroup` syntax.. It things its an assembly it needs to load... weird. [1] https://github.com/mono/msbuild/blob/xplat-master/src/Tasks/Microsoft.NETFramework.CurrentVersion.targets#L103
1 parent 5955b6b commit 3416fb5

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ public void CheckIncludedAssemblies ()
9898
{
9999
var proj = new XamarinAndroidApplicationProject () {
100100
IsRelease = true,
101+
Packages = {
102+
new Package () {
103+
Id = "System.Runtime.InteropServices.WindowsRuntime",
104+
Version = "4.0.1",
105+
TargetFramework = "monoandroid71",
106+
},
107+
},
101108
};
102109
proj.References.Add (new BuildItem.Reference ("Mono.Data.Sqlite.dll"));
103110
var expectedFiles = new string [] {

src/Xamarin.Android.Build.Tasks/Xamarin.Android.PCLSupport.targets

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,22 @@
2424

2525
<ItemGroup Condition="'$(_HasReferenceToSystemRuntime)' == 'true'">
2626
<_DesignTimeFacadeAssemblies Include="%(DesignTimeFacadeDirectories.Identity)*.dll"/>
27-
<ReferencePath Remove="@(_DesignTimeFacadeAssemblies)"/>
28-
<ReferencePath Include="%(_DesignTimeFacadeAssemblies.Identity)">
27+
</ItemGroup>
28+
29+
<CreateItem Include="%(_DesignTimeFacadeAssemblies.FileName)"
30+
AdditionalMetadata="OriginalIdentity=%(_DesignTimeFacadeAssemblies.Identity)">
31+
<Output TaskParameter="Include" ItemName="_DesignTimeFacadeAssemblies_Names" />
32+
</CreateItem>
33+
34+
<CreateItem Include="%(ReferencePath.FileName)"
35+
AdditionalMetadata="OriginalIdentity=%(ReferencePath.Identity)">
36+
<Output TaskParameter="Include" ItemName="_ReferencePath_Names" />
37+
</CreateItem>
38+
39+
<ItemGroup>
40+
<_DesignTimeFacadeAssemblies_Names Remove="@(_ReferencePath_Names)"/>
41+
42+
<ReferencePath Include="@(_DesignTimeFacadeAssemblies_Names->'%(OriginalIdentity)')">
2943
<WinMDFile>false</WinMDFile>
3044
<CopyLocal>false</CopyLocal>
3145
<ResolvedFrom>ImplicitlyExpandDesignTimeFacades</ResolvedFrom>

0 commit comments

Comments
 (0)