public XamarinAndroidApplicationProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release", [CallerMemberName] string packageName = "") : base(debugConfigurationName, releaseConfigurationName) { if (Builder.UseDotNet) { SetProperty(KnownProperties.OutputType, "Exe"); SetProperty("XamarinAndroidSupportSkipVerifyVersions", "True"); SetProperty("_FastDeploymentDiagnosticLogging", "True"); // Workaround for AndroidX, see: https://github.com/xamarin/AndroidSupportComponents/pull/239 Imports.Add(new Import(() => "Directory.Build.targets") { TextContent = () => @"<Project> <PropertyGroup> <VectorDrawableCheckBuildToolsVersionTaskBeforeTargets /> </PropertyGroup> </Project>" }); } else { SetProperty("_FastDeploymentDiagnosticLogging", "True"); SetProperty("AndroidApplication", "True"); SetProperty("AndroidResgenClass", "Resource"); SetProperty("AndroidResgenFile", () => "Resources\\Resource.designer" + Language.DefaultDesignerExtension); SetProperty("AndroidManifest", "Properties\\AndroidManifest.xml"); SetProperty(DebugProperties, "AndroidLinkMode", "None"); SetProperty(ReleaseProperties, "AndroidLinkMode", "SdkOnly"); SetProperty(DebugProperties, KnownProperties.EmbedAssembliesIntoApk, "False", "'$(EmbedAssembliesIntoApk)' == ''"); SetProperty(ReleaseProperties, KnownProperties.EmbedAssembliesIntoApk, "True", "'$(EmbedAssembliesIntoApk)' == ''"); } AndroidManifest = default_android_manifest; TargetSdkVersion = AndroidSdkResolver.GetMaxInstalledPlatform().ToString(); LayoutMain = default_layout_main; StringsXml = default_strings_xml; PackageName = $"com.xamarin.{(packageName ?? ProjectName).ToLower ()}"; JavaPackageName = JavaPackageName ?? PackageName.ToLowerInvariant(); OtherBuildItems.Add(new BuildItem.NoActionResource("Properties\\AndroidManifest.xml") { TextContent = ProcessManifestTemplate, }); AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Main.axml") { TextContent = () => LayoutMain }); AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml") { TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName) }); Sources.Add(new BuildItem.Source(() => "MainActivity" + Language.DefaultExtension) { TextContent = () => ProcessSourceTemplate(MainActivity ?? DefaultMainActivity) }); }
public XASdkProject(string outputType = "Exe") { Sdk = "Microsoft.NET.Sdk"; TargetFramework = "net5.0-android"; TargetSdkVersion = AndroidSdkResolver.GetMaxInstalledPlatform().ToString(); PackageName = PackageName ?? string.Format("{0}.{0}", ProjectName); JavaPackageName = JavaPackageName ?? PackageName.ToLowerInvariant(); GlobalPackagesFolder = Path.Combine(XABuildPaths.TopDirectory, "packages"); SetProperty(KnownProperties.OutputType, outputType); // Add relevant Android content to our project without writing it to the .csproj file if (outputType == "Exe") { Sources.Add(new BuildItem.Source("Properties\\AndroidManifest.xml") { TextContent = ProcessManifestTemplate }); } Sources.Add(new BuildItem.Source($"MainActivity{Language.DefaultExtension}") { TextContent = () => ProcessSourceTemplate(MainActivity ?? DefaultMainActivity) }); Sources.Add(new BuildItem.Source("Resources\\layout\\Main.axml") { TextContent = () => default_layout_main }); Sources.Add(new BuildItem.Source("Resources\\values\\Strings.xml") { TextContent = () => default_strings_xml.Replace("${PROJECT_NAME}", ProjectName) }); Sources.Add(new BuildItem.Source("Resources\\drawable-mdpi\\Icon.png") { BinaryContent = () => icon_binary_mdpi }); Sources.Add(new BuildItem.Source($"Resources\\Resource.designer{Language.DefaultExtension}") { TextContent = () => string.Empty }); }