Skip to content

Commit 87589c1

Browse files
[Xamarin.Android.Build.Tasks] default $(AndroidUseAssemblyStore) to false for debug builds (#6660)
Context: https://github.com/xamarin/QualityAssurance/tree/master/Manual/CrossPlatformDebugging Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1430409 Fixes: #6480 A `CrossPlatformDebugging` sample project in the QA repo fails to debug with: System.InvalidProgramException Message=Invalid IL code in Mono.SystemDependencyProvider:Initialize (): IL_002e: endfinally The problem goes away if you do one of: * Turn *on* Fast Deployment * Add `<AndroidUseAssemblyStore>false</AndroidUseAssemblyStore>` * Change `$(DebugType)` to `portable`. (the project has `full`) The problem appears to be: 1. `$(AndroidUseAssemblyStore)` defaults to `true` when you turn Fast Deployment *off*. 2. Assembly stores appear to have some issue when `DebugType=full` -- that is where the crash occurs. In this case let's address No. 1, as we don't *really* want the assembly store to be used when debugging. I reordered default values for MSBuild properties, so that `$(AndroidIncludeDebugSymbols)` is taken into account. I added parameters for a debugging test for `DebugType=full`, and I updated another test that used to set `AndroidUseAssemblyStore=false` that should not be needed.
1 parent a84eccb commit 87589c1

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,6 @@ public void BuildBasicApplicationCheckPdb ()
10351035
var proj = new XamarinAndroidApplicationProject {
10361036
EmbedAssembliesIntoApk = true,
10371037
};
1038-
proj.SetProperty ("AndroidUseAssemblyStore", "False");
10391038
using (var b = CreateApkBuilder ()) {
10401039
var reference = new BuildItem.Reference ("PdbTestLibrary.dll") {
10411040
WebContentFileNameFromAzure = "PdbTestLibrary.dll"

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
179179
<AndroidFragmentType Condition=" '$(AndroidFragmentType)' == '' ">Android.App.Fragment</AndroidFragmentType>
180180
<AndroidEnableAssemblyCompression Condition=" '$(AndroidEnableAssemblyCompression)' == '' ">True</AndroidEnableAssemblyCompression>
181181
<AndroidIncludeWrapSh Condition=" '$(AndroidIncludeWrapSh)' == '' ">False</AndroidIncludeWrapSh>
182-
<AndroidUseAssemblyStore Condition=" '$(EmbedAssembliesIntoApk)' == 'False' Or '$(BundleAssemblies)' == 'True'">False</AndroidUseAssemblyStore>
183-
<AndroidUseAssemblyStore Condition=" '$(AndroidUseAssemblyStore)' == '' ">True</AndroidUseAssemblyStore>
184182
<_AndroidCheckedBuild Condition=" '$(_AndroidCheckedBuild)' == '' "></_AndroidCheckedBuild>
185183

186184
<!-- Currently only C# is supported -->
@@ -330,6 +328,11 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
330328
</Otherwise>
331329
</Choose>
332330

331+
<PropertyGroup>
332+
<AndroidUseAssemblyStore Condition=" '$(AndroidUseAssemblyStore)' == '' and ('$(EmbedAssembliesIntoApk)' != 'true' or '$(AndroidIncludeDebugSymbols)' == 'true' or '$(BundleAssemblies)' == 'true') ">false</AndroidUseAssemblyStore>
333+
<AndroidUseAssemblyStore Condition=" '$(AndroidUseAssemblyStore)' == '' ">true</AndroidUseAssemblyStore>
334+
</PropertyGroup>
335+
333336
<!-- Do not resolve from the GAC under any circumstances in Mobile -->
334337
<PropertyGroup>
335338
<AssemblySearchPaths>

tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,49 +274,63 @@ public override void OnCreate ()
274274
/* fastDevType */ "Assemblies",
275275
/* allowDeltaInstall */ false,
276276
/* user */ null,
277+
/* debugType */ "",
278+
},
279+
new object[] {
280+
/* embedAssemblies */ true,
281+
/* fastDevType */ "Assemblies",
282+
/* allowDeltaInstall */ false,
283+
/* user */ null,
284+
/* debugType */ "full",
277285
},
278286
new object[] {
279287
/* embedAssemblies */ false,
280288
/* fastDevType */ "Assemblies",
281289
/* allowDeltaInstall */ false,
282290
/* user */ null,
291+
/* debugType */ "",
283292
},
284293
new object[] {
285294
/* embedAssemblies */ false,
286295
/* fastDevType */ "Assemblies",
287296
/* allowDeltaInstall */ true,
288297
/* user */ null,
298+
/* debugType */ "",
289299
},
290300
new object[] {
291301
/* embedAssemblies */ false,
292302
/* fastDevType */ "Assemblies:Dexes",
293303
/* allowDeltaInstall */ false,
294304
/* user */ null,
305+
/* debugType */ "",
295306
},
296307
new object[] {
297308
/* embedAssemblies */ false,
298309
/* fastDevType */ "Assemblies:Dexes",
299310
/* allowDeltaInstall */ true,
300311
/* user */ null,
312+
/* debugType */ "",
301313
},
302314
new object[] {
303315
/* embedAssemblies */ true,
304316
/* fastDevType */ "Assemblies",
305317
/* allowDeltaInstall */ false,
306318
/* user */ DeviceTest.GuestUserName,
319+
/* debugType */ "",
307320
},
308321
new object[] {
309322
/* embedAssemblies */ false,
310323
/* fastDevType */ "Assemblies",
311324
/* allowDeltaInstall */ false,
312325
/* user */ DeviceTest.GuestUserName,
326+
/* debugType */ "",
313327
},
314328
};
315329
#pragma warning restore 414
316330

317331
[Test, Category ("SmokeTests"), Category ("Debugger")]
318332
[TestCaseSource (nameof(DebuggerTestCases))]
319-
public void ApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, string fastDevType, bool allowDeltaInstall, string username)
333+
public void ApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, string fastDevType, bool allowDeltaInstall, string username, string debugType)
320334
{
321335
AssertCommercialBuild ();
322336
AssertHasDevices ();
@@ -356,6 +370,9 @@ public Foo ()
356370
app.AddReference (lib);
357371
app.SetAndroidSupportedAbis ("armeabi-v7a", "x86");
358372
app.SetProperty (KnownProperties._AndroidAllowDeltaInstall, allowDeltaInstall.ToString ());
373+
if (!string.IsNullOrEmpty (debugType)) {
374+
app.SetProperty ("DebugType", debugType);
375+
}
359376
app.SetDefaultTargetDevice ();
360377
using (var libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName)))
361378
using (var appBuilder = CreateApkBuilder (Path.Combine (path, app.ProjectName))) {

0 commit comments

Comments
 (0)