Skip to content

Commit 0809427

Browse files
committed
Revert "[Xamarin.Android.Build.Tasks] Don't package reference assemblies (#706)"
This reverts commit d15-4/0bd26fd3c19fb973316172c10aa2c9e9ae43c1e3. Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58679 Turns Out™ that `@(ReferenceCopyLocalPaths)` isn't a "drop-in" replacement for `@(ReferencePaths)`: `@(ReferenceCopyLocalPaths)` doesn't contain `Mono.Android.Export.dll`, which means that every app which uses `Mono.Android.Export.dll` and properly contains a `<Reference Include="Mono.Android.Export" />` now elicits the packaging error: error XA4210: You need to add a reference to Mono.Android.Export.dll when you use ExportAttribute or ExportFieldAttribute. Revert the fix for now until we can create a better fix.
1 parent a3e0cdf commit 0809427

File tree

4 files changed

+2
-22
lines changed

4 files changed

+2
-22
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ TEST_APK_PROJECTS = \
148148
# Syntax: $(call BUILD_TEST_APK,path/to/project.csproj)
149149
define BUILD_TEST_APK
150150
# Must use xabuild to ensure correct assemblies are resolved
151-
MSBUILD="$(MSBUILD)" tools/scripts/xabuild $(MSBUILD_FLAGS) /t:SignAndroidPackage $(1)
151+
MSBUILD="$(MSBUILD)" tools/scripts/xabuild /t:SignAndroidPackage $(1)
152152
endef # BUILD_TEST_APK
153153

154154
run-apk-tests:

src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,6 @@ private void AddAssemblies (ZipArchiveEx apk)
275275

276276
int count = 0;
277277
foreach (ITaskItem assembly in ResolvedUserAssemblies) {
278-
279-
if (MonoAndroidHelper.IsReferenceAssembly (assembly.ItemSpec)) {
280-
Log.LogWarning ($"{assembly.ItemSpec} is a reference assembly!");
281-
}
282278
// Add assembly
283279
apk.Archive.AddFile (assembly.ItemSpec, GetTargetDirectory (assembly.ItemSpec) + "/" + Path.GetFileName (assembly.ItemSpec), compressionMethod: CompressionMethod.Store);
284280

@@ -311,9 +307,6 @@ private void AddAssemblies (ZipArchiveEx apk)
311307
count = 0;
312308
// Add framework assemblies
313309
foreach (ITaskItem assembly in ResolvedFrameworkAssemblies) {
314-
if (MonoAndroidHelper.IsReferenceAssembly (assembly.ItemSpec)) {
315-
Log.LogWarning ($"{assembly.ItemSpec} is a reference assembly!");
316-
}
317310
apk.Archive.AddFile (assembly.ItemSpec, "assemblies/" + Path.GetFileName (assembly.ItemSpec), compressionMethod: CompressionMethod.Store);
318311
var config = Path.ChangeExtension (assembly.ItemSpec, "dll.config");
319312
AddAssemblyConfigEntry (apk, config);

src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Mono.Security.Cryptography;
99
using Xamarin.Android.Build.Utilities;
1010
using Xamarin.Tools.Zip;
11-
using Mono.Cecil;
1211

1312
#if MSBUILD
1413
using Microsoft.Build.Framework;
@@ -261,14 +260,6 @@ public static bool IsFrameworkAssembly (string assembly, bool checkSdkPath)
261260
return TargetFrameworkDirectories == null || !checkSdkPath ? false : ExistsInFrameworkPath (assembly);
262261
}
263262

264-
public static bool IsReferenceAssembly (string assembly)
265-
{
266-
var a = AssemblyDefinition.ReadAssembly (assembly, new ReaderParameters() { InMemory = true, ReadSymbols = false, });
267-
if (!a.HasCustomAttributes)
268-
return false;
269-
return a.CustomAttributes.Any (t => t.AttributeType.FullName == "System.Runtime.CompilerServices.ReferenceAssemblyAttribute");
270-
}
271-
272263
public static bool ExistsInFrameworkPath (string assembly)
273264
{
274265
return TargetFrameworkDirectories

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,11 +1429,7 @@ because xbuild doesn't support framework reference assemblies.
14291429
<Target Name="_ResolveAssemblies">
14301430
<!--- Remove the ImplicitlyExpandDesignTimeFacades assemblies. We have already build the app there are not required for packaging -->
14311431
<ItemGroup>
1432-
<FilteredAssemblies Include="%(ReferenceCopyLocalPaths.Identity)"
1433-
Condition="'%(ReferenceCopyLocalPaths.ResolvedFrom)' != 'ImplicitlyExpandDesignTimeFacades' And '%(ReferenceCopyLocalPaths.Extension)' == '.dll' And '%(ReferenceCopyLocalPaths.DestinationSubDirectory)' == '' "/>
1434-
<!-- Fallback to @(ReferencePath) if @(ReferenceCopyLocalPaths) is empty. This is for xbuild support -->
1435-
<FilteredAssemblies Include="%(ReferencePath.Identity)"
1436-
Condition="'%(ReferencePath.ResolvedFrom)' != 'ImplicitlyExpandDesignTimeFacades' And '@(ReferenceCopyLocalPaths)' == '' "/>
1432+
<FilteredAssemblies Include="@(ReferencePath)" Condition="'%(ReferencePath.ResolvedFrom)' != 'ImplicitlyExpandDesignTimeFacades'" />
14371433
</ItemGroup>
14381434
<!-- Find all the assemblies this app requires -->
14391435
<ResolveAssemblies

0 commit comments

Comments
 (0)