Skip to content

Commit

Permalink
[One .NET] set env var automatically for $(UseInterpreter) (#6027)
Browse files Browse the repository at this point in the history
Fixes: #6016
Context: https://github.com/dotnet/maui/blob/main/src/Templates/src/templates/maui-mobile/MauiApp1/Android/AndroidEnvironment.txt

Currently, the the .NET MAUI project template includes a
`@(AndroidEnvironment)` file for "Hot Reload" scenarios. Let's setup
this value by default so it will not be needed.
  • Loading branch information
jonathanpeppers committed Jun 18, 2021
1 parent 941dc3a commit ee49249
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Expand Up @@ -3929,17 +3929,21 @@ public void AbiNameInIntermediateOutputPath ()
public void PackageNamingPolicy ([Values ("LowercaseMD5", "LowercaseCrc64")] string packageNamingPolicy)
{
var proj = new XamarinAndroidApplicationProject ();
proj.SetProperty ("UseInterpreter", "true");
proj.SetProperty ("AndroidPackageNamingPolicy", packageNamingPolicy);
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86");
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "build should have succeeded.");
var environment = b.Output.GetIntermediaryPath (Path.Combine ("__environment__.txt"));
FileAssert.Exists (environment);
var values = new List<string> {
$"__XA_PACKAGE_NAMING_POLICY__={packageNamingPolicy}"
};
if (Builder.UseDotNet) {
Assert.AreEqual ($"__XA_PACKAGE_NAMING_POLICY__={packageNamingPolicy}{Environment.NewLine}mono.enable_assembly_preload=0", File.ReadAllText (environment).Trim ());
} else {
Assert.AreEqual ($"__XA_PACKAGE_NAMING_POLICY__={packageNamingPolicy}", File.ReadAllText (environment).Trim ());
values.Add ("mono.enable_assembly_preload=0");
values.Add ("DOTNET_MODIFIABLE_ASSEMBLIES=Debug");
}
Assert.AreEqual (string.Join (Environment.NewLine, values), File.ReadAllText (environment).Trim ());
}
}

Expand Down
Expand Up @@ -1513,6 +1513,7 @@ because xbuild doesn't support framework reference assemblies.
<ItemGroup>
<_GeneratedAndroidEnvironment Include="__XA_PACKAGE_NAMING_POLICY__=$(AndroidPackageNamingPolicy)" />
<_GeneratedAndroidEnvironment Include="mono.enable_assembly_preload=0" Condition=" '$(AndroidEnablePreloadAssemblies)' != 'True' " />
<_GeneratedAndroidEnvironment Include="DOTNET_MODIFIABLE_ASSEMBLIES=Debug" Condition=" '$(UsingAndroidNETSdk)' == 'true' and '$(AndroidIncludeDebugSymbols)' == 'true' and '$(AndroidUseInterpreter)' == 'true' " />
</ItemGroup>
<WriteLinesToFile
File="$(IntermediateOutputPath)__environment__.txt"
Expand Down

0 comments on commit ee49249

Please sign in to comment.