From 5205a5f0f0d6f85a765038138a4713c1c2e0a783 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 1 Mar 2024 14:31:11 -0600 Subject: [PATCH 1/6] [Mono.Android] fix trimming warnings, part 2 (#8758) Context: https://github.com/xamarin/xamarin-android/issues/5652 Context: https://github.com/xamarin/xamarin-android/issues/8724 Context: https://github.com/xamarin/java.interop/issues/1165 Context: https://github.com/xamarin/java.interop/commit/b8f6f8884ac11775107cbb55a9f57a38cbd53240 Context: dc3dc3ccf28cdbe9f8c0a705400b83c11a85c81a980ccf2 Fix another set of trimmer warnings found via: true true ~~ JavaObjectExtensions ~~ `Extensions.JavaCast()` now requires `PublicConstructors` and `NonPublicConstructors` because `TypeManager.CreateProxy()` uses `ConstructorInfo.Invoke()`. This change bubbles up to various other types that have a `Find*ById()` method: * `Activity` * `Dialog` * `FragmentManager` * `View` * `Window` `JavaObjectExtensions.GetInvokerType()` also has suppressions around `Assembly.GetType()` and `Type.MakeGenericType()`. We track this for the future at xamarin/xamarin-android#8724. ~~ AndroidRuntime ~~ Update `[DynamicallyAccessedMembers]` based on changes to `RegisterNativeMembers` in xamarin/java.interop@b8f6f888. ~~ JNINativeWrapper ~~ `$(EnableAotAnalyzer)` found usage of `DynamicMethod`. Suppress for now, as we track this for the future at xamarin/xamarin-android#8724. ~~ ResourceIdManager ~~ Usage of `Type.GetMethod ("UpdateIdValues")` leads to decoration of `[ResourceDesignerAttribute]` with: [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] public string FullName { get; set; } I also had to suppress warnings around `Assembly.GetType()`. This *should* be OK, as `Resource.designer.cs` is always in the "root assembly" of Android application projects. Additionally, this code should no longer be used in .NET 8+ apps; see dc3ccf28. ~~ JavaProxyThrowable ~~ Suppress warning around `StackFrame.GetMethod()`; we already handle `null` return values and exceptions. The existing code appears to be "best effort" to provide additional stack trace information. ~~ TypeManager ~~ Suppress warning around a call to `Type.GetType()` with a string passed in from Java. There is not much we can really do yet, except rely on the `MarkJavaObjects` trimmer step. Likely also a problem for the future: * xamarin/java.interop#1165 * xamarin/xamarin-android#8724 ~~ Impact on `.apk` size ~~ `BuildReleaseArm64XFormsDotNet.apkdesc` shows a ~33KB size increase in the `.apk`. Much of this is attributable to changes from dotnet/runtime (`System.Private.CoreLib.dll` is ~20KB larger). Some of this is due to increases in the size of `classes*.dex`. These changes are because more managed constructors are now preserved by the trimmer, which causes more constructors to be emitted into the Java Callable Wrappers. --- src/Mono.Android/Android.App/Activity.cs | 14 +- src/Mono.Android/Android.App/Dialog.cs | 6 +- .../Android.App/FragmentManager.cs | 23 ++- .../Android.Runtime/AndroidRuntime.cs | 13 +- .../Android.Runtime/Extensions.cs | 5 +- .../Android.Runtime/JNINativeWrapper.cs | 5 + .../Android.Runtime/JavaProxyThrowable.cs | 11 +- .../ResourceDesignerAttribute.cs | 6 +- .../Android.Runtime/ResourceIdManager.cs | 11 +- src/Mono.Android/Android.Views/View.cs | 12 +- src/Mono.Android/Android.Views/Window.cs | 5 +- .../Java.Interop/JavaObjectExtensions.cs | 51 ++++-- src/Mono.Android/Java.Interop/TypeManager.cs | 6 +- .../BuildReleaseArm64XFormsDotNet.apkdesc | 148 +++++++++--------- 14 files changed, 214 insertions(+), 102 deletions(-) diff --git a/src/Mono.Android/Android.App/Activity.cs b/src/Mono.Android/Android.App/Activity.cs index a8156ec04c6..dd881a6b539 100644 --- a/src/Mono.Android/Android.App/Activity.cs +++ b/src/Mono.Android/Android.App/Activity.cs @@ -1,19 +1,27 @@ using System; - +using System.Diagnostics.CodeAnalysis; using Android.Runtime; namespace Android.App { partial class Activity { - public T? FindViewById (int id) + internal const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; + + public T? FindViewById< + [DynamicallyAccessedMembers (Constructors)] + T + > (int id) where T : Android.Views.View { return this.FindViewById (id)!.JavaCast (); } // See: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/app/Activity.java;l=3430 - public T RequireViewById (int id) + public T RequireViewById< + [DynamicallyAccessedMembers (Constructors)] + T + > (int id) where T : Android.Views.View { var view = FindViewById (id); diff --git a/src/Mono.Android/Android.App/Dialog.cs b/src/Mono.Android/Android.App/Dialog.cs index 14f32f00bc1..2a1a1f10ce8 100644 --- a/src/Mono.Android/Android.App/Dialog.cs +++ b/src/Mono.Android/Android.App/Dialog.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using Android.Runtime; namespace Android.App { @@ -8,7 +9,10 @@ public partial class Dialog { protected Dialog (Android.Content.Context context, bool cancelable, EventHandler cancelHandler) : this (context, cancelable, new Android.Content.IDialogInterfaceOnCancelListenerImplementor () { Handler = cancelHandler }) {} - public T? FindViewById (int id) + public T? FindViewById< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + T + > (int id) where T : Android.Views.View { return this.FindViewById (id).JavaCast (); diff --git a/src/Mono.Android/Android.App/FragmentManager.cs b/src/Mono.Android/Android.App/FragmentManager.cs index 5d32da4a247..5269111a1a0 100644 --- a/src/Mono.Android/Android.App/FragmentManager.cs +++ b/src/Mono.Android/Android.App/FragmentManager.cs @@ -1,18 +1,35 @@ using Android.OS; using Android.Runtime; +using System.Diagnostics.CodeAnalysis; #if ANDROID_11 namespace Android.App { public partial class FragmentManager { - public T? FindFragmentById (int id) where T : Fragment + const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; + + public T? FindFragmentById< + [DynamicallyAccessedMembers (Constructors)] + T + > (int id) + where T : Fragment { return FindFragmentById (id).JavaCast (); } - public T? FindFragmentByTag (string tag) where T : Fragment + + public T? FindFragmentByTag< + [DynamicallyAccessedMembers (Constructors)] + T + > (string tag) + where T : Fragment { return FindFragmentByTag (tag).JavaCast (); } - public T? GetFragment (Bundle bundle, string key) where T : Fragment + + public T? GetFragment< + [DynamicallyAccessedMembers (Constructors)] + T + > (Bundle bundle, string key) + where T : Fragment { return GetFragment (bundle, key).JavaCast (); } diff --git a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs index cd815b76391..d7876273983 100644 --- a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs +++ b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs @@ -247,6 +247,9 @@ struct JniRemappingReplacementMethod bool jniAddNativeMethodRegistrationAttributePresent; + const DynamicallyAccessedMemberTypes Methods = DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods; + const DynamicallyAccessedMemberTypes MethodsAndPrivateNested = Methods | DynamicallyAccessedMemberTypes.NonPublicNestedTypes; + public AndroidTypeManager (bool jniAddNativeMethodRegistrationAttributePresent) { this.jniAddNativeMethodRegistrationAttributePresent = jniAddNativeMethodRegistrationAttributePresent; @@ -473,7 +476,7 @@ static bool CallRegisterMethodByIndex (JniNativeMethodRegistrationArguments argu public override void RegisterNativeMembers ( JniType nativeClass, - [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] + [DynamicallyAccessedMembers (MethodsAndPrivateNested)] Type type, string? methods) => RegisterNativeMembers (nativeClass, type, methods.AsSpan ()); @@ -483,7 +486,7 @@ public override void RegisterNativeMembers ( [UnconditionalSuppressMessage ("Trimming", "IL2072", Justification = "Delegate.CreateDelegate() can never statically know the string value parsed from parameter 'methods'.")] public void RegisterNativeMembers ( JniType nativeClass, - [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)] Type type, + [DynamicallyAccessedMembers (MethodsAndPrivateNested)] Type type, ReadOnlySpan methods) { try { @@ -619,7 +622,11 @@ public override void WaitForGCBridgeProcessing () AndroidRuntimeInternal.WaitForBridgeProcessing (); } - public override IJavaPeerable? CreatePeer (ref JniObjectReference reference, JniObjectReferenceOptions options, Type? targetType) + public override IJavaPeerable? CreatePeer ( + ref JniObjectReference reference, + JniObjectReferenceOptions options, + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + Type? targetType) { if (!reference.IsValid) return null; diff --git a/src/Mono.Android/Android.Runtime/Extensions.cs b/src/Mono.Android/Android.Runtime/Extensions.cs index 93a442f5356..2d41fa03e2b 100644 --- a/src/Mono.Android/Android.Runtime/Extensions.cs +++ b/src/Mono.Android/Android.Runtime/Extensions.cs @@ -7,7 +7,10 @@ namespace Android.Runtime { public static class Extensions { [return: NotNullIfNotNull ("instance")] - public static TResult? JavaCast (this IJavaObject? instance) + public static TResult? JavaCast< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + TResult + > (this IJavaObject? instance) where TResult : class, IJavaObject { return Java.Interop.JavaObjectExtensions.JavaCast(instance); diff --git a/src/Mono.Android/Android.Runtime/JNINativeWrapper.cs b/src/Mono.Android/Android.Runtime/JNINativeWrapper.cs index 87cd87a30da..fc87ab63c28 100644 --- a/src/Mono.Android/Android.Runtime/JNINativeWrapper.cs +++ b/src/Mono.Android/Android.Runtime/JNINativeWrapper.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Reflection.Emit; using System.Threading; @@ -52,7 +53,11 @@ public static Delegate CreateDelegate (Delegate dlg) param_types [i] = parameters [i].ParameterType; } + // FIXME: https://github.com/xamarin/xamarin-android/issues/8724 + // IL3050 disabled in source: if someone uses NativeAOT, they will get the warning. + #pragma warning disable IL3050 var dynamic = new DynamicMethod (DynamicMethodNameCounter.GetUniqueName (), ret_type, param_types, typeof (DynamicMethodNameCounter), true); + #pragma warning restore IL3050 var ig = dynamic.GetILGenerator (); LocalBuilder? retval = null; diff --git a/src/Mono.Android/Android.Runtime/JavaProxyThrowable.cs b/src/Mono.Android/Android.Runtime/JavaProxyThrowable.cs index 7e350980638..5755f705f30 100644 --- a/src/Mono.Android/Android.Runtime/JavaProxyThrowable.cs +++ b/src/Mono.Android/Android.Runtime/JavaProxyThrowable.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using StackTraceElement = Java.Lang.StackTraceElement; @@ -38,6 +39,14 @@ public static JavaProxyThrowable Create (Exception innerException) void TranslateStackTrace () { + // FIXME: https://github.com/xamarin/xamarin-android/issues/8724 + // StackFrame.GetMethod() will return null under NativeAOT; + // However, you can still get useful information from StackFrame.ToString(): + // MainActivity.OnCreate() + 0x37 at offset 55 in file:line:column :0:0 + [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "StackFrame.GetMethod() is \"best attempt\", we handle null & exceptions")] + static MethodBase? StackFrameGetMethod (StackFrame frame) => + frame.GetMethod (); + var trace = new StackTrace (InnerException, fNeedFileInfo: true); if (trace.FrameCount <= 0) { return; @@ -59,7 +68,7 @@ void TranslateStackTrace () for (int i = 0; i < frames.Length; i++) { StackFrame managedFrame = frames[i]; - MethodBase? managedMethod = managedFrame.GetMethod (); + MethodBase? managedMethod = StackFrameGetMethod (managedFrame); var throwableFrame = new StackTraceElement ( declaringClass: managedMethod?.DeclaringType?.FullName, diff --git a/src/Mono.Android/Android.Runtime/ResourceDesignerAttribute.cs b/src/Mono.Android/Android.Runtime/ResourceDesignerAttribute.cs index 88f61075d0c..9528a5097e8 100644 --- a/src/Mono.Android/Android.Runtime/ResourceDesignerAttribute.cs +++ b/src/Mono.Android/Android.Runtime/ResourceDesignerAttribute.cs @@ -1,15 +1,19 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace Android.Runtime { [AttributeUsage (AttributeTargets.Assembly)] public class ResourceDesignerAttribute : Attribute { - public ResourceDesignerAttribute (string fullName) + public ResourceDesignerAttribute ( + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] + string fullName) { FullName = fullName; } + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] public string FullName { get; set; } public bool IsApplication { get; set; } diff --git a/src/Mono.Android/Android.Runtime/ResourceIdManager.cs b/src/Mono.Android/Android.Runtime/ResourceIdManager.cs index 4a9590dcba4..5ef1e6255df 100644 --- a/src/Mono.Android/Android.Runtime/ResourceIdManager.cs +++ b/src/Mono.Android/Android.Runtime/ResourceIdManager.cs @@ -31,12 +31,19 @@ public static void UpdateIdValues () } } - [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Types in Resource.designer.cs are preserved, because it is the root assembly passed to the linker.")] + [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] static Type? GetResourceTypeFromAssembly (Assembly assembly) { + const string rootAssembly = "Resources.UpdateIdValues() methods are trimmed away by the LinkResourceDesigner trimmer step. This codepath is not called unless $(AndroidUseDesignerAssembly) is disabled."; + + [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = rootAssembly)] + [UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = rootAssembly)] + [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] + static Type AssemblyGetType (Assembly a, string name) => a.GetType (name); + foreach (var customAttribute in assembly.GetCustomAttributes (typeof (ResourceDesignerAttribute), true)) { if (customAttribute is ResourceDesignerAttribute resourceDesignerAttribute && resourceDesignerAttribute.IsApplication) { - var type = assembly.GetType (resourceDesignerAttribute.FullName); + var type = AssemblyGetType (assembly, resourceDesignerAttribute.FullName); if (type != null) return type; } diff --git a/src/Mono.Android/Android.Views/View.cs b/src/Mono.Android/Android.Views/View.cs index 2a17143e167..58de9a2c027 100644 --- a/src/Mono.Android/Android.Views/View.cs +++ b/src/Mono.Android/Android.Views/View.cs @@ -14,6 +14,8 @@ public enum SystemUiFlags { public partial class View { + internal const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; + #if ANDROID_16 [Obsolete ("This method uses wrong enum type. Please use PerformAccessibilityAction(Action) instead.")] public bool PerformAccessibilityAction (GlobalAction action, Bundle arguments) @@ -22,14 +24,20 @@ public bool PerformAccessibilityAction (GlobalAction action, Bundle arguments) } #endif - public T? FindViewById (int id) + public T? FindViewById< + [DynamicallyAccessedMembers (Constructors)] + T + > (int id) where T : Android.Views.View { return this.FindViewById (id).JavaCast (); } // See: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/View.java;l=25322 - public T RequireViewById (int id) + public T RequireViewById< + [DynamicallyAccessedMembers (Constructors)] + T + > (int id) where T : Android.Views.View { var view = FindViewById (id); diff --git a/src/Mono.Android/Android.Views/Window.cs b/src/Mono.Android/Android.Views/Window.cs index 6164a970d6a..1d82b614ec4 100644 --- a/src/Mono.Android/Android.Views/Window.cs +++ b/src/Mono.Android/Android.Views/Window.cs @@ -6,7 +6,10 @@ namespace Android.Views { partial class Window { - public T? FindViewById (int id) + public T? FindViewById< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + T + > (int id) where T : Android.Views.View { return this.FindViewById (id).JavaCast (); diff --git a/src/Mono.Android/Java.Interop/JavaObjectExtensions.cs b/src/Mono.Android/Java.Interop/JavaObjectExtensions.cs index 27564bb602b..5b083487c5b 100644 --- a/src/Mono.Android/Java.Interop/JavaObjectExtensions.cs +++ b/src/Mono.Android/Java.Interop/JavaObjectExtensions.cs @@ -8,6 +8,7 @@ namespace Java.Interop { public static class JavaObjectExtensions { + const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; [Obsolete ("Use Android.Runtime.JavaCollection.ToLocalJniHandle()")] public static JavaCollection ToInteroperableCollection (this ICollection instance) @@ -46,13 +47,19 @@ public static JavaDictionary ToInteroperableCollection (this IDictiona } [return: NotNullIfNotNull ("instance")] - public static TResult? JavaCast (this IJavaObject? instance) + public static TResult? JavaCast< + [DynamicallyAccessedMembers (Constructors)] + TResult + > (this IJavaObject? instance) where TResult : class, IJavaObject { return _JavaCast (instance); } - internal static TResult? _JavaCast (this IJavaObject? instance) + internal static TResult? _JavaCast< + [DynamicallyAccessedMembers (Constructors)] + TResult + > (this IJavaObject? instance) { if (instance == null) return default (TResult); @@ -74,7 +81,10 @@ public static JavaDictionary ToInteroperableCollection (this IDictiona throw new NotSupportedException (FormattableString.Invariant ($"Unable to convert type '{instance.GetType ().FullName}' to '{resultType.FullName}'.")); } - static IJavaObject CastClass (IJavaObject instance, Type resultType) + static IJavaObject CastClass ( + IJavaObject instance, + [DynamicallyAccessedMembers (Constructors)] + Type resultType) { var klass = JNIEnv.FindClass (resultType); try { @@ -97,7 +107,10 @@ static IJavaObject CastClass (IJavaObject instance, Type resultType) return (IJavaObject) TypeManager.CreateProxy (resultType, instance.Handle, JniHandleOwnership.DoNotTransfer); } - internal static IJavaObject? JavaCast (IJavaObject? instance, Type resultType) + internal static IJavaObject? JavaCast ( + IJavaObject? instance, + [DynamicallyAccessedMembers (Constructors)] + Type resultType) { if (resultType == null) throw new ArgumentNullException ("resultType"); @@ -120,23 +133,43 @@ static IJavaObject CastClass (IJavaObject instance, Type resultType) // typeof(Foo) -> FooInvoker // typeof(Foo<>) -> FooInvoker`1 - [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "*Invoker types are preserved by the MarkJavaObjects linker step.")] - [UnconditionalSuppressMessage ("Trimming", "IL2055", Justification = "*Invoker types are preserved by the MarkJavaObjects linker step.")] + [return: DynamicallyAccessedMembers (Constructors)] internal static Type? GetInvokerType (Type type) { + const string InvokerTypes = "*Invoker types are preserved by the MarkJavaObjects linker step."; + + [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = InvokerTypes)] + [UnconditionalSuppressMessage ("Trimming", "IL2055", Justification = InvokerTypes)] + [UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = InvokerTypes)] + [return: DynamicallyAccessedMembers (Constructors)] + static Type? AssemblyGetType (Assembly assembly, string typeName) => + assembly.GetType (typeName); + + // FIXME: https://github.com/xamarin/xamarin-android/issues/8724 + // IL3050 disabled in source: if someone uses NativeAOT, they will get the warning. + [UnconditionalSuppressMessage ("Trimming", "IL2055", Justification = InvokerTypes)] + [UnconditionalSuppressMessage ("Trimming", "IL2068", Justification = InvokerTypes)] + [return: DynamicallyAccessedMembers (Constructors)] + static Type MakeGenericType (Type type, params Type [] typeArguments) => + #pragma warning disable IL3050 + type.MakeGenericType (typeArguments); + #pragma warning restore IL3050 + const string suffix = "Invoker"; + Type[] arguments = type.GetGenericArguments (); if (arguments.Length == 0) - return type.Assembly.GetType (type + suffix); + return AssemblyGetType (type.Assembly, type + suffix); Type definition = type.GetGenericTypeDefinition (); int bt = definition.FullName!.IndexOf ("`", StringComparison.Ordinal); if (bt == -1) throw new NotSupportedException ("Generic type doesn't follow generic type naming convention! " + type.FullName); - Type? suffixDefinition = definition.Assembly.GetType ( + Type? suffixDefinition = AssemblyGetType ( + definition.Assembly, definition.FullName.Substring (0, bt) + suffix + definition.FullName.Substring (bt)); if (suffixDefinition == null) return null; - return suffixDefinition.MakeGenericType (arguments); + return MakeGenericType (suffixDefinition, arguments); } } } diff --git a/src/Mono.Android/Java.Interop/TypeManager.cs b/src/Mono.Android/Java.Interop/TypeManager.cs index c0993e1a9d9..fb4e87216a4 100644 --- a/src/Mono.Android/Java.Interop/TypeManager.cs +++ b/src/Mono.Android/Java.Interop/TypeManager.cs @@ -237,6 +237,10 @@ static Exception CreateJavaLocationException () internal static Type? TypeRegistrationFallback (string class_name) { + [UnconditionalSuppressMessage ("Trimming", "IL2057", Justification = "Type should be preserved by the MarkJavaObjects trimmer step.")] + static Type? TypeGetType (string name) => + Type.GetType (name, throwOnError: false); + __TypeRegistrations.RegisterPackages (); Type? type = null; @@ -250,7 +254,7 @@ static Exception CreateJavaLocationException () return type; } } - if ((type = Type.GetType (JavaNativeTypeManager.ToCliType (class_name))) != null) { + if ((type = TypeGetType (JavaNativeTypeManager.ToCliType (class_name))) != null) { return type; } return null; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc index ddd5ba9e1b8..58f281d0e0c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc @@ -5,214 +5,214 @@ "Size": 6652 }, "assemblies/_Microsoft.Android.Resource.Designer.dll": { - "Size": 2281 + "Size": 2279 }, "assemblies/FormsViewGroup.dll": { - "Size": 8100 + "Size": 8090 }, "assemblies/Java.Interop.dll": { - "Size": 69705 + "Size": 72297 }, "assemblies/Mono.Android.dll": { - "Size": 458238 + "Size": 456687 }, "assemblies/Mono.Android.Runtime.dll": { - "Size": 5151 + "Size": 5143 }, "assemblies/mscorlib.dll": { - "Size": 4002 + "Size": 3999 }, "assemblies/netstandard.dll": { - "Size": 5643 + "Size": 5632 }, "assemblies/rc.bin": { "Size": 1512 }, "assemblies/System.Collections.Concurrent.dll": { - "Size": 11530 + "Size": 11523 }, "assemblies/System.Collections.dll": { - "Size": 15430 + "Size": 15415 }, "assemblies/System.Collections.NonGeneric.dll": { - "Size": 7452 + "Size": 7445 }, "assemblies/System.ComponentModel.dll": { - "Size": 1939 + "Size": 1941 }, "assemblies/System.ComponentModel.Primitives.dll": { - "Size": 2549 + "Size": 2555 }, "assemblies/System.ComponentModel.TypeConverter.dll": { - "Size": 6033 + "Size": 6089 }, "assemblies/System.Console.dll": { - "Size": 6578 + "Size": 6582 }, "assemblies/System.Core.dll": { - "Size": 1974 + "Size": 1976 }, "assemblies/System.Diagnostics.DiagnosticSource.dll": { - "Size": 9068 + "Size": 9064 }, "assemblies/System.Diagnostics.TraceSource.dll": { - "Size": 6552 + "Size": 6547 }, "assemblies/System.dll": { - "Size": 2328 + "Size": 2333 }, "assemblies/System.Drawing.dll": { - "Size": 1939 + "Size": 1937 }, "assemblies/System.Drawing.Primitives.dll": { - "Size": 11975 + "Size": 11966 }, "assemblies/System.IO.Compression.Brotli.dll": { - "Size": 11196 + "Size": 11192 }, "assemblies/System.IO.Compression.dll": { - "Size": 15880 + "Size": 15868 }, "assemblies/System.IO.IsolatedStorage.dll": { - "Size": 9875 + "Size": 9899 }, "assemblies/System.Linq.dll": { - "Size": 19599 + "Size": 20517 }, "assemblies/System.Linq.Expressions.dll": { - "Size": 165117 + "Size": 164631 }, "assemblies/System.Net.Http.dll": { - "Size": 67653 + "Size": 67564 }, "assemblies/System.Net.Primitives.dll": { - "Size": 22432 + "Size": 22363 }, "assemblies/System.Net.Requests.dll": { - "Size": 3602 + "Size": 3594 }, "assemblies/System.ObjectModel.dll": { - "Size": 8699 + "Size": 8572 }, "assemblies/System.Private.CoreLib.dll": { - "Size": 849922 + "Size": 869622 }, "assemblies/System.Private.DataContractSerialization.dll": { - "Size": 193991 + "Size": 193441 }, "assemblies/System.Private.Uri.dll": { - "Size": 42860 + "Size": 42907 }, "assemblies/System.Private.Xml.dll": { - "Size": 216226 + "Size": 216025 }, "assemblies/System.Private.Xml.Linq.dll": { - "Size": 16639 + "Size": 16627 }, "assemblies/System.Runtime.dll": { - "Size": 2708 + "Size": 2709 }, "assemblies/System.Runtime.InteropServices.dll": { - "Size": 4028 + "Size": 4022 }, "assemblies/System.Runtime.Serialization.dll": { "Size": 1865 }, "assemblies/System.Runtime.Serialization.Formatters.dll": { - "Size": 2484 + "Size": 2485 }, "assemblies/System.Runtime.Serialization.Primitives.dll": { - "Size": 3758 + "Size": 3757 }, "assemblies/System.Security.Cryptography.dll": { - "Size": 8111 + "Size": 8102 }, "assemblies/System.Text.RegularExpressions.dll": { - "Size": 159112 + "Size": 159848 }, "assemblies/System.Xml.dll": { - "Size": 1758 + "Size": 1760 }, "assemblies/System.Xml.Linq.dll": { - "Size": 1774 + "Size": 1775 }, "assemblies/UnnamedProject.dll": { - "Size": 5015 + "Size": 5007 }, "assemblies/Xamarin.AndroidX.Activity.dll": { - "Size": 16149 + "Size": 16116 }, "assemblies/Xamarin.AndroidX.AppCompat.AppCompatResources.dll": { - "Size": 6225 + "Size": 6216 }, "assemblies/Xamarin.AndroidX.AppCompat.dll": { - "Size": 138721 + "Size": 138025 }, "assemblies/Xamarin.AndroidX.CardView.dll": { - "Size": 6977 + "Size": 6959 }, "assemblies/Xamarin.AndroidX.CoordinatorLayout.dll": { - "Size": 17886 + "Size": 17921 }, "assemblies/Xamarin.AndroidX.Core.dll": { - "Size": 127505 + "Size": 126882 }, "assemblies/Xamarin.AndroidX.CursorAdapter.dll": { - "Size": 8997 + "Size": 8978 }, "assemblies/Xamarin.AndroidX.DrawerLayout.dll": { - "Size": 15319 + "Size": 15286 }, "assemblies/Xamarin.AndroidX.Fragment.dll": { - "Size": 51744 + "Size": 51498 }, "assemblies/Xamarin.AndroidX.Legacy.Support.Core.UI.dll": { - "Size": 6242 + "Size": 6233 }, "assemblies/Xamarin.AndroidX.Lifecycle.Common.dll": { - "Size": 6900 + "Size": 6890 }, "assemblies/Xamarin.AndroidX.Lifecycle.LiveData.Core.dll": { - "Size": 6743 + "Size": 6733 }, "assemblies/Xamarin.AndroidX.Lifecycle.ViewModel.dll": { - "Size": 7011 + "Size": 7002 }, "assemblies/Xamarin.AndroidX.Loader.dll": { - "Size": 13082 + "Size": 13063 }, "assemblies/Xamarin.AndroidX.RecyclerView.dll": { - "Size": 93990 + "Size": 93516 }, "assemblies/Xamarin.AndroidX.SavedState.dll": { - "Size": 5114 + "Size": 5107 }, "assemblies/Xamarin.AndroidX.SwipeRefreshLayout.dll": { - "Size": 13974 + "Size": 13946 }, "assemblies/Xamarin.AndroidX.ViewPager.dll": { - "Size": 19060 + "Size": 19014 }, "assemblies/Xamarin.Forms.Core.dll": { - "Size": 565831 + "Size": 563905 }, "assemblies/Xamarin.Forms.Platform.Android.dll": { - "Size": 374486 + "Size": 373374 }, "assemblies/Xamarin.Forms.Platform.dll": { - "Size": 18767 + "Size": 18753 }, "assemblies/Xamarin.Forms.Xaml.dll": { - "Size": 63655 + "Size": 63542 }, "assemblies/Xamarin.Google.Android.Material.dll": { - "Size": 66417 + "Size": 66169 }, "classes.dex": { - "Size": 9458972 + "Size": 9418292 }, "classes2.dex": { - "Size": 103648 + "Size": 150904 }, "kotlin/annotation/annotation.kotlin_builtins": { "Size": 928 @@ -236,19 +236,19 @@ "Size": 2396 }, "lib/arm64-v8a/libmono-component-marshal-ilgen.so": { - "Size": 87080 + "Size": 87352 }, "lib/arm64-v8a/libmonodroid.so": { - "Size": 339864 + "Size": 343896 }, "lib/arm64-v8a/libmonosgen-2.0.so": { - "Size": 3184512 + "Size": 3210968 }, "lib/arm64-v8a/libSystem.IO.Compression.Native.so": { "Size": 723560 }, "lib/arm64-v8a/libSystem.Native.so": { - "Size": 94504 + "Size": 94720 }, "lib/arm64-v8a/libSystem.Security.Cryptography.Native.Android.so": { "Size": 155568 @@ -407,7 +407,7 @@ "Size": 6 }, "META-INF/BNDLTOOL.RSA": { - "Size": 1223 + "Size": 1221 }, "META-INF/BNDLTOOL.SF": { "Size": 97490 @@ -2477,5 +2477,5 @@ "Size": 812848 } }, - "PackageSize": 10864931 + "PackageSize": 10897699 } \ No newline at end of file From a1c5111469a821a0048b7d6cdbe2d471adfff755 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 4 Mar 2024 10:22:15 -0800 Subject: [PATCH 2/6] [ci] Migrate to the 1ES template (#8747) Context: https://aka.ms/1espt The build pipeline has been updated to extend the 1ES pipeline template, which will keep the pipeline up to date with the latest compliance and security requirements. Most compliance tasks and scans will now run automatically as part of artifact upload steps. API Scan and policheck scans against multiple languages are not supported and will continue to run separately. --- .gdn/.gdnsettings | 7 + .gdn/.gdnsuppress | 62 + .gdn/.gitignore | 11 + .gdn/policheck/CHT.gdnsuppress | 26 + .../policheck}/PoliCheck.Exclusions.xml | 0 .gdn/policheck/source.gdnsuppress | 171 +++ .../guardian => .gdn}/tsaoptions-v2.json | 0 .../automation/azure-pipelines-nightly.yaml | 62 +- build-tools/automation/azure-pipelines.yaml | 1232 ++++++++--------- .../automation/guardian/CHT.gdnsuppress | 26 - .../guardian/CredScanSuppressions.json | 41 - .../automation/guardian/source.gdnsuppress | 250 ---- .../yaml-templates/apk-instrumentation.yaml | 35 +- .../yaml-templates/build-linux.yaml | 59 +- .../yaml-templates/build-macos.yaml | 69 +- .../yaml-templates/build-windows.yaml | 27 +- .../yaml-templates/commercial-build.yaml | 61 +- ...bal-tool.yaml => install-dotnet-tool.yaml} | 6 +- .../yaml-templates/plots-to-appinsights.yaml | 62 - .../yaml-templates/publish-artifact.yaml | 21 +- .../yaml-templates/run-designer-tests.yml | 79 -- .../yaml-templates/run-emulator-tests.yaml | 13 +- .../yaml-templates/run-installer.yaml | 40 - .../yaml-templates/run-msbuild-tests.yaml | 24 +- .../yaml-templates/run-nunit-tests.yaml | 74 +- .../run-sliced-nunit-tests.yaml | 10 +- .../yaml-templates/run-xaprepare.yaml | 3 +- .../setup-test-environment.yaml | 32 +- .../yaml-templates/setup-ubuntu.yaml | 23 - .../stage-msbuild-emulator-tests.yaml | 33 +- .../yaml-templates/stage-msbuild-tests.yaml | 4 +- .../yaml-templates/upload-results.yaml | 9 +- .../yaml-templates/use-dot-net.yaml | 1 - .../automation/yaml-templates/variables.yaml | 6 +- .../Utilities/BaseTest.cs | 12 +- 35 files changed, 1104 insertions(+), 1487 deletions(-) create mode 100644 .gdn/.gdnsettings create mode 100644 .gdn/.gdnsuppress create mode 100644 .gdn/.gitignore create mode 100644 .gdn/policheck/CHT.gdnsuppress rename {build-tools/automation/guardian => .gdn/policheck}/PoliCheck.Exclusions.xml (100%) create mode 100644 .gdn/policheck/source.gdnsuppress rename {build-tools/automation/guardian => .gdn}/tsaoptions-v2.json (100%) delete mode 100644 build-tools/automation/guardian/CHT.gdnsuppress delete mode 100644 build-tools/automation/guardian/CredScanSuppressions.json delete mode 100644 build-tools/automation/guardian/source.gdnsuppress rename build-tools/automation/yaml-templates/{install-global-tool.yaml => install-dotnet-tool.yaml} (75%) delete mode 100644 build-tools/automation/yaml-templates/plots-to-appinsights.yaml delete mode 100644 build-tools/automation/yaml-templates/run-designer-tests.yml delete mode 100644 build-tools/automation/yaml-templates/run-installer.yaml delete mode 100644 build-tools/automation/yaml-templates/setup-ubuntu.yaml diff --git a/.gdn/.gdnsettings b/.gdn/.gdnsettings new file mode 100644 index 00000000000..9ebd4133b35 --- /dev/null +++ b/.gdn/.gdnsettings @@ -0,0 +1,7 @@ +{ + "files": { }, + "folders": { }, + "overwriteLogs": true, + "telemetryFlushTimeout": 10, + "variables": { } +} diff --git a/.gdn/.gdnsuppress b/.gdn/.gdnsuppress new file mode 100644 index 00000000000..05025c8dc59 --- /dev/null +++ b/.gdn/.gdnsuppress @@ -0,0 +1,62 @@ +{ + "hydrated": false, + "properties": { + "helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions", + "hydrationStatus": "This file does not contain identifying data. It is safe to check into your repo. To hydrate this file with identifying data, run `guardian hydrate --help` and follow the guidance." + }, + "version": "1.0.0", + "suppressionSets": { + "default": { + "name": "default", + "createdDate": "2024-02-21 20:58:02Z", + "lastUpdatedDate": "2024-02-22 21:40:38Z" + } + }, + "results": { + "28e1a7a1157c8739dce8ac1bbd828a471e477444ec50d2656d0440948b58a274": { + "signature": "28e1a7a1157c8739dce8ac1bbd828a471e477444ec50d2656d0440948b58a274", + "alternativeSignatures": [], + "memberOf": [ + "default" + ], + "justification": "FillEventHistory+Event API documentation with generic example password.", + "createdDate": "2024-02-21 20:58:02Z" + }, + "0b7cc0b28f27b0eeb2a415f10e62c32675dd2d4edcffe35600eae35f8064004e": { + "signature": "0b7cc0b28f27b0eeb2a415f10e62c32675dd2d4edcffe35600eae35f8064004e", + "alternativeSignatures": [], + "memberOf": [ + "default" + ], + "justification": "Android.Service.Autofill.FillEventHistory+Event API documentation with generic example password.", + "createdDate": "2024-02-21 20:58:02Z" + }, + "e57727a14a28f6fd8f4aa87cd3c4b33401dfea1078ce32fb3cbdf342e8adf63d": { + "signature": "e57727a14a28f6fd8f4aa87cd3c4b33401dfea1078ce32fb3cbdf342e8adf63d", + "alternativeSignatures": [], + "memberOf": [ + "default" + ], + "justification": "Javax.Crypto.ISecretKey API documentation with generic example password.", + "createdDate": "2024-02-21 20:58:02Z" + }, + "15c51590a2e2bb503a7277448e05357f5fd8d4cb2f9b9b7446e41c872cceaac4": { + "signature": "15c51590a2e2bb503a7277448e05357f5fd8d4cb2f9b9b7446e41c872cceaac4", + "alternativeSignatures": [], + "memberOf": [ + "default" + ], + "justification": "Javax.Security.Auth.Callback.PasswordCallback API documentation with generic example password.", + "createdDate": "2024-02-21 20:58:02Z" + }, + "1ccf925aa704efd1035bac38e94d2e629fb5b0d1784d5473e4a52e6d13db16ee": { + "signature": "1ccf925aa704efd1035bac38e94d2e629fb5b0d1784d5473e4a52e6d13db16ee", + "alternativeSignatures": [], + "memberOf": [ + "default" + ], + "justification": "Dummy test.keystore file used for testing.", + "createdDate": "2024-02-21 20:58:02Z" + } + } +} diff --git a/.gdn/.gitignore b/.gdn/.gitignore new file mode 100644 index 00000000000..de1a20ab6d5 --- /dev/null +++ b/.gdn/.gitignore @@ -0,0 +1,11 @@ +## Ignore Guardian internal files +.r/ +rc/ +rs/ +i/ +p/ +c/ +o/ + +## Ignore Guardian Local settings +LocalSettings.gdn.json diff --git a/.gdn/policheck/CHT.gdnsuppress b/.gdn/policheck/CHT.gdnsuppress new file mode 100644 index 00000000000..4a7ab1881eb --- /dev/null +++ b/.gdn/policheck/CHT.gdnsuppress @@ -0,0 +1,26 @@ +{ + "hydrated": false, + "properties": { + "helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions", + "hydrationStatus": "This file does not contain identifying data. It is safe to check into your repo. To hydrate this file with identifying data, run `guardian hydrate --help` and follow the guidance." + }, + "version": "1.0.0", + "suppressionSets": { + "default": { + "name": "default", + "createdDate": "2023-02-24 00:05:39Z", + "lastUpdatedDate": "2024-02-22 21:40:38Z" + } + }, + "results": { + "04910d714a13bf4523ffa77350f654f52114fa4fa3d760c9f63186d41716c019": { + "signature": "04910d714a13bf4523ffa77350f654f52114fa4fa3d760c9f63186d41716c019", + "alternativeSignatures": [], + "memberOf": [ + "default" + ], + "justification": "Reference to the Android package format APK.", + "createdDate": "2023-02-24 00:05:39Z" + } + } +} diff --git a/build-tools/automation/guardian/PoliCheck.Exclusions.xml b/.gdn/policheck/PoliCheck.Exclusions.xml similarity index 100% rename from build-tools/automation/guardian/PoliCheck.Exclusions.xml rename to .gdn/policheck/PoliCheck.Exclusions.xml diff --git a/.gdn/policheck/source.gdnsuppress b/.gdn/policheck/source.gdnsuppress new file mode 100644 index 00000000000..f73824769dc --- /dev/null +++ b/.gdn/policheck/source.gdnsuppress @@ -0,0 +1,171 @@ +{ + "hydrated": false, + "properties": { + "helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions", + "hydrationStatus": "This file does not contain identifying data. It is safe to check into your repo. To hydrate this file with identifying data, run `guardian hydrate --help` and follow the guidance." + }, + "version": "1.0.0", + "suppressionSets": { + "default": { + "name": "default", + "createdDate": "2023-02-22 23:55:29Z", + "lastUpdatedDate": "2024-02-22 21:40:38Z" + } + }, + "results": { + "6789cab1bdc97b0cc3ad057b7fdd21d63cdf8bc2679391923803fa240ef81292": { + "signature": "6789cab1bdc97b0cc3ad057b7fdd21d63cdf8bc2679391923803fa240ef81292", + "alternativeSignatures": [ + "b5041e3ec6776af49d6d69148e4db480f366b559299d19ec8ea3e095295b39a8" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to an ISCII term.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "bbaf5f946cb72748567e41f0df5f1bae05550f4ba7381e21ec6b26d6c3ecec9f": { + "signature": "bbaf5f946cb72748567e41f0df5f1bae05550f4ba7381e21ec6b26d6c3ecec9f", + "alternativeSignatures": [ + "739cb5e6ee2409515900652ca668f819f697f23834becece8d2f9f9236723c1b" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to an ISCII term.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "db8916a0f0cdca4082c540921dd362e09a9ff413862ab826308411b76ee35789": { + "signature": "db8916a0f0cdca4082c540921dd362e09a9ff413862ab826308411b76ee35789", + "alternativeSignatures": [ + "a755747462567003e5aa2b7bf01aa72af5143714e427ad043747b1fb54b1c440" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to an Android logging function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "6d1fb3a483eb491710d6a09ed0b4bab47f13942d0c6fc744e6683614a66604ab": { + "signature": "6d1fb3a483eb491710d6a09ed0b4bab47f13942d0c6fc744e6683614a66604ab", + "alternativeSignatures": [ + "a755747462567003e5aa2b7bf01aa72af5143714e427ad043747b1fb54b1c440" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to an Android logging function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "b07e75fc8a506b94690dbd06877da06c1228e40e7deda3967f6b882b842f726d": { + "signature": "b07e75fc8a506b94690dbd06877da06c1228e40e7deda3967f6b882b842f726d", + "alternativeSignatures": [ + "a755747462567003e5aa2b7bf01aa72af5143714e427ad043747b1fb54b1c440" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to an Android logging function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "87d8313310c2dd42021844b95bdcb9121bf10036fea5b212b945e0732a456e5a": { + "signature": "87d8313310c2dd42021844b95bdcb9121bf10036fea5b212b945e0732a456e5a", + "alternativeSignatures": [ + "a755747462567003e5aa2b7bf01aa72af5143714e427ad043747b1fb54b1c440" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to an Android logging function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "8e5400e0233c8d887ad48bd8a48e8a7be5a579f9eefad521419b6df0828bbfac": { + "signature": "8e5400e0233c8d887ad48bd8a48e8a7be5a579f9eefad521419b6df0828bbfac", + "alternativeSignatures": [ + "a755747462567003e5aa2b7bf01aa72af5143714e427ad043747b1fb54b1c440" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to an Android logging function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "1b38e026fae90da4ae2fe9151c9c1ebd73c8b3c2c5f072ceae390a3ceec2fb97": { + "signature": "1b38e026fae90da4ae2fe9151c9c1ebd73c8b3c2c5f072ceae390a3ceec2fb97", + "alternativeSignatures": [ + "a755747462567003e5aa2b7bf01aa72af5143714e427ad043747b1fb54b1c440" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to an Android logging function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "a2b4d032c59a9d1211d218c3cd550cf8febb369941d70284d07d03ebee855bc0": { + "signature": "a2b4d032c59a9d1211d218c3cd550cf8febb369941d70284d07d03ebee855bc0", + "alternativeSignatures": [ + "9feaec8a73b72e0d212c0e18d863e4fe16ff010c5d33cf8d47d8b0f465cc4c5e" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to find first set bit function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "1c87b45a6044d205dc3f3562f349c238f7cabe22b4609da762df9dc44151e9fb": { + "signature": "1c87b45a6044d205dc3f3562f349c238f7cabe22b4609da762df9dc44151e9fb", + "alternativeSignatures": [ + "9feaec8a73b72e0d212c0e18d863e4fe16ff010c5d33cf8d47d8b0f465cc4c5e" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to find first set bit function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "a6639098c4785509a4215c9e2fc10f82c06fce461915dc11a00227ddec558845": { + "signature": "a6639098c4785509a4215c9e2fc10f82c06fce461915dc11a00227ddec558845", + "alternativeSignatures": [ + "9feaec8a73b72e0d212c0e18d863e4fe16ff010c5d33cf8d47d8b0f465cc4c5e" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to find first set bit function.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "f94ede7b396cb54934db2084f0879cd31a17ce2584eb01e0bfcd35324a724c31": { + "signature": "f94ede7b396cb54934db2084f0879cd31a17ce2584eb01e0bfcd35324a724c31", + "alternativeSignatures": [ + "9feaec8a73b72e0d212c0e18d863e4fe16ff010c5d33cf8d47d8b0f465cc4c5e" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to find first set bit function.", + "createdDate": "2024-02-22 21:40:38Z" + }, + "b34b42aa41018376a31460c142f2ae910704725d9e9a4470f92b587df682369b": { + "signature": "b34b42aa41018376a31460c142f2ae910704725d9e9a4470f92b587df682369b", + "alternativeSignatures": [ + "3901d031f3ac168bb1a84d06bb234355af514c59a0ed9da325b11a8861ff0b05" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to output from an external tool.", + "createdDate": "2023-02-22 23:55:29Z" + }, + "243e199c7aec22377e0363bdca82384278cc36b0674f35697935fde6c45cfd0e": { + "signature": "243e199c7aec22377e0363bdca82384278cc36b0674f35697935fde6c45cfd0e", + "alternativeSignatures": [ + "cf02f44873b25336e01a1fa294bd858d2ea69ae734f08c6db40d4b83d17ccf76" + ], + "memberOf": [ + "default" + ], + "justification": "Reference to a proper name.", + "createdDate": "2023-10-26 21:20:54Z" + } + } +} diff --git a/build-tools/automation/guardian/tsaoptions-v2.json b/.gdn/tsaoptions-v2.json similarity index 100% rename from build-tools/automation/guardian/tsaoptions-v2.json rename to .gdn/tsaoptions-v2.json diff --git a/build-tools/automation/azure-pipelines-nightly.yaml b/build-tools/automation/azure-pipelines-nightly.yaml index 69ac75c87e6..a71b2ac0872 100644 --- a/build-tools/automation/azure-pipelines-nightly.yaml +++ b/build-tools/automation/azure-pipelines-nightly.yaml @@ -31,7 +31,7 @@ parameters: # Global variables variables: -- template: yaml-templates/variables.yaml +- template: /build-tools/automation/yaml-templates/variables.yaml stages: - stage: mac_build @@ -56,16 +56,17 @@ stages: - checkout: self submodules: recursive - - template: yaml-templates/commercial-build.yaml + - template: /build-tools/automation/yaml-templates/commercial-build.yaml parameters: makeMSBuildArgs: /p:EnableNativeAnalyzers=true + use1ESTemplate: false - - template: yaml-templates/upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android artifactName: Build Results - Nightly macOS includeBuildResults: true - + use1ESTemplate: false - stage: test_apk displayName: Test APKs @@ -116,29 +117,26 @@ stages: workspace: clean: all steps: - - template: yaml-templates/setup-test-environment.yaml + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: - installLegacyDotNet: false - restoreNUnitConsole: false - updateMono: false xaprepareScenario: EmulatorTestDependencies jdkTestFolder: $(JAVA_HOME_11_X64) - - template: yaml-templates/run-dotnet-preview.yaml + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml parameters: project: Xamarin.Android.sln arguments: -t:PrepareJavaInterop -c $(XA.Build.Configuration) -m:1 -v:n displayName: prepare java.interop $(XA.Build.Configuration) continueOnError: false - - template: yaml-templates/start-stop-emulator.yaml + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml parameters: specificImage: true avdApiLevel: $(avdApiLevel) avdAbi: $(avdAbi) avdType: $(avdType) - - template: yaml-templates/apk-instrumentation.yaml + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml parameters: configuration: $(XA.Build.Configuration) testName: Mono.Android.NET_Tests-$(XA.Build.Configuration)-$(avdApiLevel) @@ -148,26 +146,27 @@ stages: artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab artifactFolder: Mono.Android-$(XA.Build.Configuration)-$(avdApiLevel) - - template: yaml-templates/upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: configuration: $(XA.Build.Configuration) artifactName: Test Results - Emulator $(avdApiLevel)-$(avdAbi)-$(avdType) - macOS + use1ESTemplate: false - - template: yaml-templates/fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml - - template: yaml-templates/run-emulator-tests.yaml + - template: /build-tools/automation/yaml-templates/run-emulator-tests.yaml parameters: emulatorMSBuildArgs: -p:TestAvdExtraBootArgs=-writable-system jobName: SystemApplicationTests jobTimeout: 120 jdkTestFolder: $HOME/android-toolchain/jdk-17 + use1ESTemplate: false testSteps: - template: run-nunit-tests.yaml parameters: testRunTitle: SystemApplicationTests On Device - macOS testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll dotNetTestExtraArgs: --filter "Name=SystemApplicationTests" - testResultsFile: TestResult-SystemApplicationTests-$(XA.Build.Configuration).xml # TimeZoneInfo test jobs @@ -197,12 +196,9 @@ stages: echo "##vso[task.setvariable variable=JAVA_HOME]$HOME/android-toolchain/jdk-17" displayName: set JAVA_HOME to $HOME/android-toolchain/jdk-17 - - template: yaml-templates/setup-test-environment.yaml + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: installTestSlicer: true - installLegacyDotNet: false - restoreNUnitConsole: false - updateMono: false xaprepareScenario: EmulatorTestDependencies jdkTestFolder: $HOME/android-toolchain/jdk-17 @@ -211,21 +207,22 @@ stages: artifactName: $(TestAssembliesArtifactName) downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - template: yaml-templates/start-stop-emulator.yaml + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml parameters: emulatorMSBuildArgs: -p:TestAvdShowWindow=true - - template: yaml-templates/run-sliced-nunit-tests.yaml + - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml parameters: testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll testFilter: method == CheckTimeZoneInfoIsCorrectWithSlicer testRunTitle: CheckTimeZoneInfoIsCorrectNode On Device - macOS - - template: yaml-templates/upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: artifactName: Test Results - TimeZoneInfoTests With Emulator - macOS-$(System.JobPositionInPhase) + use1ESTemplate: false - - template: yaml-templates/fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml # Localization test jobs @@ -255,12 +252,9 @@ stages: echo "##vso[task.setvariable variable=JAVA_HOME]$HOME/android-toolchain/jdk-17" displayName: set JAVA_HOME to $HOME/android-toolchain/jdk-17 - - template: yaml-templates/setup-test-environment.yaml + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: installTestSlicer: true - installLegacyDotNet: false - restoreNUnitConsole: false - updateMono: false xaprepareScenario: EmulatorTestDependencies jdkTestFolder: $HOME/android-toolchain/jdk-17 @@ -269,21 +263,22 @@ stages: artifactName: $(TestAssembliesArtifactName) downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - template: yaml-templates/start-stop-emulator.yaml + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml parameters: emulatorMSBuildArgs: -p:TestAvdShowWindow=true - - template: yaml-templates/run-sliced-nunit-tests.yaml + - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml parameters: testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll testFilter: method == CheckLocalizationIsCorrectWithSlicer testRunTitle: CheckLocalizationIsCorrect On Device - macOS - - template: yaml-templates/upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: artifactName: Test Results - Localization With Emulator - macOS-$(System.JobPositionInPhase) + use1ESTemplate: false - - template: yaml-templates/fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml - stage: compliance_scan @@ -300,12 +295,9 @@ stages: workspace: clean: all steps: - - template: yaml-templates/setup-test-environment.yaml + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: installApkDiff: false - installLegacyDotNet: false - restoreNUnitConsole: false - updateMono: false - task: DownloadPipelineArtifact@2 displayName: Download binutils pdbs diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 611da9535ef..b54da059e77 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -11,6 +11,10 @@ trigger: # External sources, scripts, tests, and yaml template files. resources: repositories: + - repository: 1esPipelines + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release - repository: yaml-templates type: github name: xamarin/yaml-templates @@ -24,11 +28,7 @@ resources: - repository: monodroid type: github name: xamarin/monodroid - endpoint: xamarin - - repository: release_scripts - type: github - name: xamarin/release-scripts - ref: refs/heads/sign-and-notarized + ref: refs/heads/main endpoint: xamarin - repository: maui type: github @@ -37,12 +37,16 @@ resources: endpoint: xamarin parameters: +- name: pushXAPackagesToMaestro + default: true - name: macTestAgentsUseCleanImages # Test agents we do not need to clean up when finished because they are not reused default: true +- name: Skip1ESComplianceTasks + default: false # Global variables variables: -- template: yaml-templates/variables.yaml +- template: /build-tools/automation/yaml-templates/variables.yaml@self - template: templates/common/vs-release-vars.yml@sdk-insertions - ${{ if eq(variables['Build.DefinitionName'], 'Xamarin.Android-Private') }}: - group: AzureDevOps-Artifact-Feeds-Pats @@ -52,665 +56,597 @@ variables: - ${{ if ne(variables['Build.DefinitionName'], 'Xamarin.Android-Private') }}: - name: DotNetFeedCredential value: dnceng-dotnet9 -- ${{ if and(or(eq(variables['Build.DefinitionName'], 'Xamarin.Android'), eq(variables['Build.DefinitionName'], 'Xamarin.Android-Private')), ne(variables['Build.Reason'], 'PullRequest')) }}: - - name: MicroBuildSignType +- name: MicroBuildSignType + ${{ if and(or(eq(variables['Build.DefinitionName'], 'Xamarin.Android'), eq(variables['Build.DefinitionName'], 'Xamarin.Android-Private')), ne(variables['Build.Reason'], 'PullRequest')) }}: value: Real - - name: MacBuildPoolName - value: Azure Pipelines - - name: MacBuildPoolImage - value: internal-macos12 - - name: LinuxBuildPoolName - value: android-devdiv-ubuntu-vmss - - name: LinuxBuildPoolImage - value: '' -- ${{ if or(and(ne(variables['Build.DefinitionName'],'Xamarin.Android'), ne(variables['Build.DefinitionName'], 'Xamarin.Android-Private')), eq(variables['Build.Reason'], 'PullRequest')) }}: - - name: MicroBuildSignType + ${{ else }}: value: Test - - name: MacBuildPoolName - value: VSEng-Xamarin-RedmondMac-Android-Untrusted - - name: MacBuildPoolImage - value: '' - - name: LinuxBuildPoolName - value: android-devdiv-ubuntu-vmss-pr - - name: LinuxBuildPoolImage - value: '' - - name: DisablePipelineConfigDetector - value: true - -# Stage and Job "display names" are shortened because they are combined to form the name of the corresponding GitHub check. -stages: -- template: yaml-templates/build-macos.yaml - -- template: yaml-templates/build-windows.yaml - -# Check - "Xamarin.Android (Linux > Build)" -- template: yaml-templates/build-linux.yaml - -- stage: smoke_tests - displayName: Package Tests - dependsOn: mac_build - jobs: - # Check - "Xamarin.Android (macOS > Tests > APKs .NET)" - - job: mac_apk_tests_net - displayName: macOS > Tests > APKs .NET - pool: - vmImage: $(HostedMacImage) - timeoutInMinutes: 180 - workspace: - clean: all - steps: - - template: yaml-templates/setup-test-environment.yaml - parameters: - provisionClassic: false - installLegacyDotNet: false - restoreNUnitConsole: false - updateMono: false - xaprepareScenario: EmulatorTestDependencies - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(TestAssembliesArtifactName) - downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - # Set up dependencies to run tests in both debug and release configurations - - task: DotNetCoreCLI@2 - displayName: build Xamarin.Android.Tools.BootstrapTasks.csproj - inputs: - projects: $(System.DefaultWorkingDirectory)/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj - arguments: -c Debug -bl:$(System.DefaultWorkingDirectory)/bin/TestDebug/BootstrapTasks.binlog - - - template: yaml-templates/run-dotnet-preview.yaml - parameters: - project: Xamarin.Android.sln - arguments: >- - -t:PrepareJavaInterop -c Debug --no-restore - -p:DotNetPreviewTool=$(System.DefaultWorkingDirectory)/bin/$(XA.Build.Configuration)/dotnet/dotnet - displayName: prepare java.interop Debug - continueOnError: false - - - template: yaml-templates/run-dotnet-preview.yaml - parameters: - project: Xamarin.Android.sln - arguments: -t:PrepareJavaInterop -c $(XA.Build.Configuration) --no-restore - displayName: prepare java.interop $(XA.Build.Configuration) - continueOnError: false - - template: yaml-templates/start-stop-emulator.yaml +extends: + ${{ if eq(variables['MicroBuildSignType'], 'Real') }}: + template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines + ${{ else }}: + template: v1/1ES.Unofficial.PipelineTemplate.yml@1esPipelines + parameters: + sdl: + ${{ if eq('${{ parameters.Skip1ESComplianceTasks }}', 'true') }}: + enableAllTools: false + binskim: + scanOutputDirectoryOnly: true + codeql: + runSourceLanguagesInSourceAnalysis: true + policheck: + enabled: false + justification: Built in task does not support multi-language scanning + spotBugs: + enabled: false + justification: 'Failing with "Could not successfully find the java tool launcher"' + sourceAnalysisPool: + name: AzurePipelines-EO + image: $(WindowsPoolImage1ESPT) + os: windows + sourceRepositoriesToScan: + include: + - repository: monodroid + exclude: + - repository: yaml-templates + - repository: maui + suppression: + suppressionFile: $(Build.SourcesDirectory)\.gdn\.gdnsuppress + stages: + - template: /build-tools/automation/yaml-templates/build-macos.yaml@self + + - template: /build-tools/automation/yaml-templates/build-windows.yaml@self + + - template: /build-tools/automation/yaml-templates/build-linux.yaml@self + + - stage: smoke_tests + displayName: Package Tests + dependsOn: mac_build + jobs: + # Check - "Xamarin.Android (Package Tests macOS > Tests > APKs .NET)" + - job: mac_apk_tests_net + displayName: macOS > Tests > APKs .NET + pool: + name: Azure Pipelines + vmImage: $(HostedMacImage) + os: macOS + timeoutInMinutes: 180 + workspace: + clean: all + steps: + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self + parameters: + xaprepareScenario: EmulatorTestDependencies - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-$(XA.Build.Configuration) - project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj - testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration).xml - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-$(XA.Build.Configuration) - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - buildConfiguration: $(XA.Build.Configuration) - configuration: Debug - testName: Mono.Android.NET_Tests-Debug - project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj - testResultsFiles: TestResult-Mono.Android.NET_Tests-Debug.xml - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.apk - artifactFolder: $(DotNetTargetFramework)-Debug - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-NoAab - project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj - testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)NoAab.xml - extraBuildArgs: -p:TestsFlavor=NoAab -p:AndroidPackageFormat=apk - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.apk - artifactFolder: $(DotNetTargetFramework)-NoAab - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-Interpreter - project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj - testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)Interpreter.xml - extraBuildArgs: -p:TestsFlavor=Interpreter -p:UseInterpreter=True - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-Interpreter - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-NoAot - project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj - testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)NoAot.xml - extraBuildArgs: -p:TestsFlavor=NoAot -p:RunAOTCompilation=false - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-NoAot - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Mono.Android.NET_Tests-AotLlvm - project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj - testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)AotLlvm.xml - extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLLVM=true -p:AndroidEnableProfiledAot=false - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab - artifactFolder: $(DotNetTargetFramework)-AotLlvm - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Xamarin.Android.JcwGen_Tests - project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests-$(XA.Build.Configuration).xml - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Xamarin.Android.JcwGen_Tests-Signed.apk - artifactFolder: $(DotNetTargetFramework)-Default - - - template: yaml-templates/apk-instrumentation.yaml - parameters: - configuration: $(XA.Build.Configuration) - testName: Xamarin.Android.JcwGen_Tests_FastDev - project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj - testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests-$(XA.Build.Configuration).xml - artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Xamarin.Android.JcwGen_Tests-Signed.apk - artifactFolder: $(DotNetTargetFramework)-FastDev_Assemblies_Dexes - extraBuildArgs: /p:AndroidFastDeploymentType=Assemblies:Dexes - - - template: yaml-templates/run-nunit-tests.yaml - parameters: - testRunTitle: Xamarin.Android.Tools.Aidl-Tests - macOS - testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Tools.Aidl-Tests.dll - testResultsFile: TestResult-Aidl-Tests-macOS-$(XA.Build.Configuration).xml - - - task: ShellScript@2 - displayName: Test dotnet-local.sh - inputs: - scriptPath: dotnet-local.sh - args: build samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj - - - ${{ if ne(parameters.macTestAgentsUseCleanImages, true) }}: - - template: yaml-templates/start-stop-emulator.yaml - parameters: - command: stop + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(TestAssembliesArtifactName) + downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - template: yaml-templates/upload-results.yaml - parameters: - artifactName: Test Results - APKs .NET $(XA.Build.Configuration) - macOS + # Set up dependencies to run tests in both debug and release configurations + - task: DotNetCoreCLI@2 + displayName: build Xamarin.Android.Tools.BootstrapTasks.csproj + inputs: + projects: $(System.DefaultWorkingDirectory)/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj + arguments: -c Debug -bl:$(System.DefaultWorkingDirectory)/bin/TestDebug/BootstrapTasks.binlog + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + project: Xamarin.Android.sln + arguments: >- + -t:PrepareJavaInterop -c Debug --no-restore + -p:DotNetPreviewTool=$(System.DefaultWorkingDirectory)/bin/$(XA.Build.Configuration)/dotnet/dotnet + displayName: prepare java.interop Debug + continueOnError: false + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + project: Xamarin.Android.sln + arguments: -t:PrepareJavaInterop -c $(XA.Build.Configuration) --no-restore + displayName: prepare java.interop $(XA.Build.Configuration) + continueOnError: false + + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self + + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self + parameters: + configuration: $(XA.Build.Configuration) + testName: Mono.Android.NET_Tests-$(XA.Build.Configuration) + project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj + testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration).xml + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab + artifactFolder: $(DotNetTargetFramework)-$(XA.Build.Configuration) + + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self + parameters: + buildConfiguration: $(XA.Build.Configuration) + configuration: Debug + testName: Mono.Android.NET_Tests-Debug + project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj + testResultsFiles: TestResult-Mono.Android.NET_Tests-Debug.xml + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.apk + artifactFolder: $(DotNetTargetFramework)-Debug + + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self + parameters: + configuration: $(XA.Build.Configuration) + testName: Mono.Android.NET_Tests-NoAab + project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj + testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)NoAab.xml + extraBuildArgs: -p:TestsFlavor=NoAab -p:AndroidPackageFormat=apk + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.apk + artifactFolder: $(DotNetTargetFramework)-NoAab + + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self + parameters: + configuration: $(XA.Build.Configuration) + testName: Mono.Android.NET_Tests-Interpreter + project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj + testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)Interpreter.xml + extraBuildArgs: -p:TestsFlavor=Interpreter -p:UseInterpreter=True + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab + artifactFolder: $(DotNetTargetFramework)-Interpreter + + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self + parameters: + configuration: $(XA.Build.Configuration) + testName: Mono.Android.NET_Tests-NoAot + project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj + testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)NoAot.xml + extraBuildArgs: -p:TestsFlavor=NoAot -p:RunAOTCompilation=false + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab + artifactFolder: $(DotNetTargetFramework)-NoAot + + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self + parameters: + configuration: $(XA.Build.Configuration) + testName: Mono.Android.NET_Tests-AotLlvm + project: tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj + testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)AotLlvm.xml + extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLLVM=true -p:AndroidEnableProfiledAot=false + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab + artifactFolder: $(DotNetTargetFramework)-AotLlvm + + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self + parameters: + configuration: $(XA.Build.Configuration) + testName: Xamarin.Android.JcwGen_Tests + project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj + testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests-$(XA.Build.Configuration).xml + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Xamarin.Android.JcwGen_Tests-Signed.apk + artifactFolder: $(DotNetTargetFramework)-Default + + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml@self + parameters: + configuration: $(XA.Build.Configuration) + testName: Xamarin.Android.JcwGen_Tests_FastDev + project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj + testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests-$(XA.Build.Configuration).xml + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Xamarin.Android.JcwGen_Tests-Signed.apk + artifactFolder: $(DotNetTargetFramework)-FastDev_Assemblies_Dexes + extraBuildArgs: /p:AndroidFastDeploymentType=Assemblies:Dexes + + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self + parameters: + testRunTitle: Xamarin.Android.Tools.Aidl-Tests - macOS + testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Tools.Aidl-Tests.dll + + - task: ShellScript@2 + displayName: Test dotnet-local.sh + inputs: + scriptPath: dotnet-local.sh + args: build samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj + + - ${{ if ne(parameters.macTestAgentsUseCleanImages, true) }}: + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self + parameters: + command: stop + + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + parameters: + artifactName: Test Results - APKs .NET $(XA.Build.Configuration) - macOS + + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + parameters: + artifactName: Test Results - APKs .NET Debug - macOS + configuration: Debug + + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + + - stage: linux_tests + displayName: Linux Tests + dependsOn: + - mac_build + - linux_build + jobs: + # Check - "Xamarin.Android (Linux Tests Linux > Tests > MSBuild)" + - job: linux_tests_smoke + displayName: Linux > Tests > MSBuild + pool: + name: MAUI-1ESPT + image: $(LinuxPoolImage1ESPT) + os: linux + timeoutInMinutes: 180 + workspace: + clean: all + steps: + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self - - template: yaml-templates/upload-results.yaml - parameters: - artifactName: Test Results - APKs .NET Debug - macOS - configuration: Debug - - - template: yaml-templates/fail-on-issue.yaml - -- stage: linux_tests - displayName: Linux Tests - dependsOn: - - mac_build - - linux_build - jobs: - # Check - "Xamarin.Android (Linux > Tests > MSBuild)" - - job: linux_tests_smoke - displayName: Linux > Tests > MSBuild - pool: - name: android-devdiv-ubuntu-vmss-pr - timeoutInMinutes: 180 - workspace: - clean: all - steps: - - template: yaml-templates/setup-ubuntu.yaml - - - template: yaml-templates/setup-test-environment.yaml - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(TestAssembliesArtifactName) - downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - - template: yaml-templates/run-nunit-tests.yaml - parameters: - testRunTitle: Xamarin.Android.Build.Tests - Linux BuildTest - testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll - dotNetTestExtraArgs: --filter "Name = BuildTest" - testResultsFile: TestResult-BuildTest-Linux-$(XA.Build.Configuration).xml + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(TestAssembliesArtifactName) + downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) + + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self + parameters: + testRunTitle: Xamarin.Android.Build.Tests - Linux BuildTest + testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll + dotNetTestExtraArgs: --filter "Name = BuildTest" + + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self + parameters: + testRunTitle: Xamarin.Android.Build.Tests - Linux PackagingTest + testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll + dotNetTestExtraArgs: --filter "Name = PackagingTest" + + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self + parameters: + testRunTitle: Xamarin.Android.Build.Tests - Linux XASdkTests + testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll + dotNetTestExtraArgs: --filter "Name = XASdkTests & Name != XamarinLegacySdk" + + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self + parameters: + testRunTitle: Xamarin.Android.Build.Tests - Linux AndroidDependenciesTests + testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll + dotNetTestExtraArgs: --filter "Name = AndroidDependenciesTests" + + - task: ShellScript@2 + displayName: Test dotnet-local.sh + inputs: + scriptPath: dotnet-local.sh + args: build samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj - - template: yaml-templates/run-nunit-tests.yaml - parameters: - testRunTitle: Xamarin.Android.Build.Tests - Linux PackagingTest - testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll - dotNetTestExtraArgs: --filter "Name = PackagingTest" - testResultsFile: TestResult-PackagingTest-Linux-$(XA.Build.Configuration).xml + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + parameters: + configuration: $(XA.Build.Configuration) + artifactName: Test Results - MSBuild - Linux - - template: yaml-templates/run-nunit-tests.yaml - parameters: - testRunTitle: Xamarin.Android.Build.Tests - Linux XASdkTests - testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll - dotNetTestExtraArgs: --filter "Name = XASdkTests & Name != XamarinLegacySdk" - testResultsFile: TestResult-XASdkTests-Linux-$(XA.Build.Configuration).xml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self - - template: yaml-templates/run-nunit-tests.yaml - parameters: - testRunTitle: Xamarin.Android.Build.Tests - Linux AndroidDependenciesTests - testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll - dotNetTestExtraArgs: --filter "Name = AndroidDependenciesTests" - testResultsFile: TestResult-AndroidDependenciesTests-Linux-$(XA.Build.Configuration).xml - - - task: ShellScript@2 - displayName: Test dotnet-local.sh - inputs: - scriptPath: dotnet-local.sh - args: build samples/HelloWorld/HelloWorld/HelloWorld.DotNet.csproj - - - template: yaml-templates/upload-results.yaml + - template: /build-tools/automation/yaml-templates/stage-msbuild-tests.yaml@self + + - template: /build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml@self parameters: - configuration: $(XA.Build.Configuration) - artifactName: Test Results - MSBuild - Linux + usesCleanImages: ${{ parameters.macTestAgentsUseCleanImages }} + + - stage: maui_tests + displayName: MAUI Tests + dependsOn: mac_build + condition: and(eq(dependencies.mac_build.result, 'Succeeded'), eq(variables['RunMAUITestJob'], 'true')) + jobs: + # Check - "Xamarin.Android (MAUI Tests MAUI Integration)" + - job: maui_tests_integration + displayName: MAUI Integration + pool: + name: MAUI-1ESPT + image: $(WindowsPoolImage1ESPT) + os: windows + timeoutInMinutes: 180 + workspace: + clean: all + variables: + BuildVersion: $(Build.BuildId) + steps: + - checkout: maui + clean: true + submodules: recursive + path: s/maui + persistCredentials: true + + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self + parameters: + xaSourcePath: $(Build.SourcesDirectory)/xamarin-android + androidSdkPlatforms: $(DefaultTestSdkPlatforms) + + - task: NuGetAuthenticate@1 + displayName: authenticate with azure artifacts + inputs: + forceReinstallCredentialProvider: true - - template: yaml-templates/fail-on-issue.yaml + - script: | + echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_17_X64% + echo ##vso[task.setvariable variable=JAVA_HOME]%JAVA_HOME_17_X64% + displayName: set JI_JAVA_HOME, JAVA_HOME to $(JAVA_HOME_17_X64) -- template: yaml-templates/stage-msbuild-tests.yaml + - script: echo "##vso[task.prependpath]C:\Windows\System32\WindowsPowerShell\v1.0\" + displayName: add powershell to path -- template: yaml-templates/stage-msbuild-emulator-tests.yaml - parameters: - usesCleanImages: ${{ parameters.macTestAgentsUseCleanImages }} - -- stage: maui_tests - displayName: MAUI Tests - dependsOn: mac_build - condition: and(eq(dependencies.mac_build.result, 'Succeeded'), eq(variables['RunMAUITestJob'], 'true')) - jobs: - # Check - "Xamarin.Android (MAUI Tests MAUI Integration)" - - job: maui_tests_integration - displayName: MAUI Integration - pool: $(1ESWindowsPool) - timeoutInMinutes: 180 - workspace: - clean: all - variables: - BuildVersion: $(Build.BuildId) - steps: - - checkout: maui - clean: true - submodules: recursive - path: s/maui - persistCredentials: true - - - template: yaml-templates/setup-test-environment.yaml - parameters: - xaSourcePath: $(Build.SourcesDirectory)/xamarin-android - provisionClassic: false - installLegacyDotNet: false - restoreNUnitConsole: false - updateMono: false - androidSdkPlatforms: $(DefaultTestSdkPlatforms) - - - task: NuGetAuthenticate@1 - displayName: authenticate with azure artifacts - inputs: - forceReinstallCredentialProvider: true - - - script: | - echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_17_X64% - echo ##vso[task.setvariable variable=JAVA_HOME]%JAVA_HOME_17_X64% - displayName: set JI_JAVA_HOME, JAVA_HOME to $(JAVA_HOME_17_X64) - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(NuGetArtifactName) - downloadPath: $(Build.StagingDirectory)/android-packs - - - pwsh: | - $searchPath = Join-Path $(Build.StagingDirectory) android-packs - $wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1 - $dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)" - Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest - $wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json" - $json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable - Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])" - Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])" - displayName: Set ANDROID_PACK_VERSION - - - pwsh: >- - $(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1 - -xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props" - -androidVersion $(ANDROID_PACK_VERSION) - displayName: Update MAUI's Android dependency - - - task: DotNetCoreCLI@2 - displayName: Update Android SDK band in Workloads.csproj - inputs: - projects: $(Build.SourcesDirectory)/xamarin-android/Xamarin.Android.sln - arguments: -t:UpdateMauiWorkloadsProj -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/update-maui-workloadsproj.binlog - - - pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic - displayName: Install .NET - retryCountOnTaskFailure: 3 - workingDirectory: $(Build.SourcesDirectory)/maui - - - pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic - displayName: Pack .NET Maui - workingDirectory: $(Build.SourcesDirectory)/maui - - - task: DotNetCoreCLI@2 - displayName: Install MAUI workload packs - retryCountOnTaskFailure: 3 - inputs: - projects: $(Build.SourcesDirectory)/xamarin-android/Xamarin.Android.sln - arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog - - - template: yaml-templates/run-dotnet-preview.yaml - parameters: - command: new - arguments: maui -o $(Build.StagingDirectory)/MauiTestProj - xaSourcePath: $(Build.SourcesDirectory)/xamarin-android - displayName: Create MAUI template - continueOnError: false - - - powershell: | - $project = '$(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj' - [xml] $xml = Get-Content $project - $node = $xml.SelectSingleNode('/Project/PropertyGroup/TargetFrameworks') - $node.InnerText = '$(DotNetTargetFramework)-android' - $xml.Save($project) - displayName: set TargetFrameworks to Android-only - - - template: yaml-templates/run-dotnet-preview.yaml - parameters: - project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj - arguments: >- - -f $(DotNetTargetFramework)-android -c Debug - --configfile $(Build.SourcesDirectory)/maui/NuGet.config - -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog - xaSourcePath: $(Build.SourcesDirectory)/xamarin-android - displayName: Build MAUI template - Debug - - - template: yaml-templates/run-dotnet-preview.yaml - parameters: - project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj - arguments: >- - -f $(DotNetTargetFramework)-android -c Release - --configfile $(Build.SourcesDirectory)/maui/NuGet.config - -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog - xaSourcePath: $(Build.SourcesDirectory)/xamarin-android - displayName: Build MAUI template - Release - - - task: CopyFiles@2 - displayName: copy build logs - condition: always() - inputs: - Contents: | - $(Build.SourcesDirectory)/maui/artifacts/logs/** - TargetFolder: $(Build.StagingDirectory)/logs - flattenFolders: true - - - template: yaml-templates/publish-artifact.yaml - parameters: - displayName: upload build and test results - artifactName: Test Results - MAUI Integration - targetPath: $(Build.StagingDirectory)/logs - condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true')) - - - template: yaml-templates/fail-on-issue.yaml - - -- stage: dotnet_prepare_release - displayName: Prepare .NET Release - dependsOn: - - mac_build - - linux_build - condition: and(eq(dependencies.mac_build.result, 'Succeeded'), eq(dependencies.linux_build.result, 'Succeeded'), eq(variables['MicroBuildSignType'], 'Real')) - jobs: - # Check - "Xamarin.Android (Prepare .NET Release Sign Archives)" - - template: sign-artifacts/jobs/v2.yml@yaml-templates - parameters: - name: sign_net_mac_win - poolName: $(VSEngMicroBuildPool) - artifactName: $(NuGetArtifactName) - signType: $(MicroBuildSignType) - signedArtifactName: nuget-signed - usePipelineArtifactTasks: true - - # Check - "Xamarin.Android (Prepare .NET Release Sign Linux Archive)" - - template: sign-artifacts/jobs/v2.yml@yaml-templates - parameters: - name: sign_net_linux - displayName: Sign Linux Archive - poolName: $(VSEngMicroBuildPool) - artifactName: $(LinuxNuGetArtifactName) - signType: $(MicroBuildSignType) - signedArtifactName: nuget-linux-signed - usePipelineArtifactTasks: true - - # Check - "Xamarin.Android (Prepare .NET Release Convert NuGet to MSI)" - - template: nuget-msi-convert/job/v3.yml@yaml-templates - parameters: - yamlResourceName: yaml-templates - dependsOn: sign_net_mac_win - artifactName: nuget-signed - artifactPatterns: | - !*Darwin* - propsArtifactName: $(NuGetArtifactName) - signType: $(MicroBuildSignType) - postConvertSteps: - - task: DownloadPipelineArtifact@2 - inputs: + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(NuGetArtifactName) + downloadPath: $(Build.StagingDirectory)/android-packs + + - pwsh: | + $searchPath = Join-Path $(Build.StagingDirectory) android-packs + $wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1 + $dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)" + Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest + $wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json" + $json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable + Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])" + Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])" + displayName: Set ANDROID_PACK_VERSION + + - pwsh: >- + $(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1 + -xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props" + -androidVersion $(ANDROID_PACK_VERSION) + displayName: Update MAUI's Android dependency + + - task: DotNetCoreCLI@2 + displayName: Update Android SDK band in Workloads.csproj + inputs: + projects: $(Build.SourcesDirectory)/xamarin-android/Xamarin.Android.sln + arguments: -t:UpdateMauiWorkloadsProj -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/update-maui-workloadsproj.binlog + + - pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic + displayName: Install .NET + retryCountOnTaskFailure: 3 + workingDirectory: $(Build.SourcesDirectory)/maui + + - pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic + displayName: Pack .NET Maui + workingDirectory: $(Build.SourcesDirectory)/maui + + - task: DotNetCoreCLI@2 + displayName: Install MAUI workload packs + retryCountOnTaskFailure: 3 + inputs: + projects: $(Build.SourcesDirectory)/xamarin-android/Xamarin.Android.sln + arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + command: new + arguments: maui -o $(Build.StagingDirectory)/MauiTestProj + xaSourcePath: $(Build.SourcesDirectory)/xamarin-android + displayName: Create MAUI template + continueOnError: false + + - powershell: | + $project = '$(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj' + [xml] $xml = Get-Content $project + $node = $xml.SelectSingleNode('/Project/PropertyGroup/TargetFrameworks') + $node.InnerText = '$(DotNetTargetFramework)-android' + $xml.Save($project) + displayName: set TargetFrameworks to Android-only + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj + arguments: >- + -f $(DotNetTargetFramework)-android -c Debug + --configfile $(Build.SourcesDirectory)/maui/NuGet.config + -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog + xaSourcePath: $(Build.SourcesDirectory)/xamarin-android + displayName: Build MAUI template - Debug + + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj + arguments: >- + -f $(DotNetTargetFramework)-android -c Release + --configfile $(Build.SourcesDirectory)/maui/NuGet.config + -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog + xaSourcePath: $(Build.SourcesDirectory)/xamarin-android + displayName: Build MAUI template - Release + + - task: CopyFiles@2 + displayName: copy build logs + condition: always() + inputs: + Contents: | + $(Build.SourcesDirectory)/maui/artifacts/logs/** + TargetFolder: $(Build.StagingDirectory)/logs + flattenFolders: true + + - template: /build-tools/automation/yaml-templates/publish-artifact.yaml@self + parameters: + displayName: upload build and test results + artifactName: Test Results - MAUI Integration + targetPath: $(Build.StagingDirectory)/logs + condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true')) + + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + + + - stage: dotnet_prepare_release + displayName: Prepare .NET Release + dependsOn: + - mac_build + - linux_build + condition: and(eq(dependencies.mac_build.result, 'Succeeded'), eq(dependencies.linux_build.result, 'Succeeded'), eq(variables['MicroBuildSignType'], 'Real')) + jobs: + # Check - "Xamarin.Android (Prepare .NET Release Sign Archives)" + - template: sign-artifacts/jobs/v2.yml@yaml-templates + parameters: + name: sign_net_mac_win + poolName: $(VSEngMicroBuildPool) artifactName: $(NuGetArtifactName) - downloadPath: $(Build.StagingDirectory)\sign-verify - patterns: | - **/SignVerifyIgnore.txt - - - task: MicroBuildCodesignVerify@3 - displayName: verify signed msi content - inputs: - TargetFolders: | - $(Build.ArtifactStagingDirectory)\bin\manifests - $(Build.ArtifactStagingDirectory)\bin\manifests-multitarget - ExcludeSNVerify: true - ApprovalListPathForCerts: $(Build.StagingDirectory)\sign-verify\SignVerifyIgnore.txt - - # Check - "Xamarin.Android (Prepare .NET Release Push Internal)" - - job: push_signed_nugets - displayName: Push Internal - dependsOn: - - nuget_convert - - sign_net_linux - condition: and(eq(dependencies.nuget_convert.result, 'Succeeded'), eq(dependencies.sign_net_linux.result, 'Succeeded')) - timeoutInMinutes: 60 - pool: $(VSEngMicroBuildPool) - workspace: - clean: all - variables: - - ${{ if eq(variables['MicroBuildSignType'], 'Real') }}: - - group: Publish-Build-Assets - steps: - - checkout: self - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: nuget-signed - downloadPath: $(Build.StagingDirectory)\nuget-signed - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: nuget-linux-signed - downloadPath: $(Build.StagingDirectory)\nuget-signed - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: vs-msi-nugets - downloadPath: $(Build.StagingDirectory)\nuget-signed - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(WindowsToolchainPdbArtifactName) - downloadPath: $(Build.StagingDirectory)\nuget-signed - - - task: NuGetCommand@2 - displayName: push nupkgs - inputs: - command: push - packagesToPush: $(Build.StagingDirectory)\nuget-signed\*.nupkg - nuGetFeedType: external - publishFeedCredentials: $(DotNetFeedCredential) - condition: and(succeeded(), eq(variables['PushXAPackages'], 'true')) - - - template: templates\common\upload-vs-insertion-artifacts.yml@sdk-insertions - parameters: - githubToken: $(GitHub.Token) - githubContext: $(NupkgCommitStatusName) - blobName: $(NupkgCommitStatusName) - packagePrefix: xamarin-android - artifactsPath: $(Build.StagingDirectory)\nuget-signed - yamlResourceName: yaml-templates - - - template: templates\common\upload-vs-insertion-artifacts.yml@sdk-insertions - parameters: - githubToken: $(GitHub.Token) - githubContext: $(VSDropCommitStatusName) - blobName: $(VSDropCommitStatusName) - packagePrefix: xamarin-android - artifactsPath: $(Build.StagingDirectory)\$(VSDropCommitStatusName) - yamlResourceName: yaml-templates - downloadSteps: + signType: $(MicroBuildSignType) + signedArtifactName: nuget-signed + usePipelineArtifactTasks: true + use1ESTemplate: true + + # Check - "Xamarin.Android (Prepare .NET Release Sign Linux Archive)" + - template: sign-artifacts/jobs/v2.yml@yaml-templates + parameters: + name: sign_net_linux + displayName: Sign Linux Archive + poolName: $(VSEngMicroBuildPool) + artifactName: $(LinuxNuGetArtifactName) + signType: $(MicroBuildSignType) + signedArtifactName: nuget-linux-signed + usePipelineArtifactTasks: true + use1ESTemplate: true + + # Check - "Xamarin.Android (Prepare .NET Release Convert NuGet to MSI)" + - template: nuget-msi-convert/job/v3.yml@yaml-templates + parameters: + yamlResourceName: yaml-templates + dependsOn: sign_net_mac_win + artifactName: nuget-signed + artifactPatterns: | + !*Darwin* + propsArtifactName: $(NuGetArtifactName) + signType: $(MicroBuildSignType) + use1ESTemplate: true + postConvertSteps: + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(NuGetArtifactName) + downloadPath: $(Build.StagingDirectory)\sign-verify + patterns: | + **/SignVerifyIgnore.txt + + - task: MicroBuildCodesignVerify@3 + displayName: verify signed msi content + inputs: + TargetFolders: | + $(Build.ArtifactStagingDirectory)\bin\manifests + $(Build.ArtifactStagingDirectory)\bin\manifests-multitarget + ExcludeSNVerify: true + ApprovalListPathForCerts: $(Build.StagingDirectory)\sign-verify\SignVerifyIgnore.txt + + # Check - "Xamarin.Android (Prepare .NET Release Push Internal)" + - job: push_signed_nugets + displayName: Push Internal + dependsOn: + - nuget_convert + - sign_net_linux + condition: and(eq(dependencies.nuget_convert.result, 'Succeeded'), eq(dependencies.sign_net_linux.result, 'Succeeded')) + timeoutInMinutes: 60 + pool: $(VSEngMicroBuildPool) + workspace: + clean: all + variables: + - ${{ if eq(variables['MicroBuildSignType'], 'Real') }}: + - group: Publish-Build-Assets + templateContext: + outputs: + - output: nuget + condition: and(succeeded(), eq('${{ parameters.pushXAPackagesToMaestro }}', 'true')) + useDotNetTask: false # The default is false to use the NuGetCommand task. Set to true to use the DotNetCoreCLI task to publish packages. + packagesToPush: $(Build.StagingDirectory)\nuget-signed\*.nupkg + packageParentPath: $(Build.StagingDirectory)\nuget-signed + nuGetFeedType: external + publishFeedCredentials: $(DotNetFeedCredential) + steps: + - checkout: self + - task: DownloadPipelineArtifact@2 inputs: - artifactName: vsdrop-signed - downloadPath: $(Build.StagingDirectory)\$(VSDropCommitStatusName) + artifactName: nuget-signed + downloadPath: $(Build.StagingDirectory)\nuget-signed - - template: templates\common\upload-vs-insertion-artifacts.yml@sdk-insertions - parameters: - githubToken: $(GitHub.Token) - githubContext: $(MultiTargetVSDropCommitStatusName) - blobName: $(MultiTargetVSDropCommitStatusName) - packagePrefix: xamarin-android - artifactsPath: $(Build.StagingDirectory)\$(MultiTargetVSDropCommitStatusName) - yamlResourceName: yaml-templates - downloadSteps: - task: DownloadPipelineArtifact@2 inputs: - artifactName: vsdrop-multitarget-signed - downloadPath: $(Build.StagingDirectory)\$(MultiTargetVSDropCommitStatusName) - - - powershell: >- - & dotnet build -v:n -c $(XA.Build.Configuration) - -t:PushManifestToBuildAssetRegistry - -p:BuildAssetRegistryToken=$(MaestroAccessToken) - -p:OutputPath=$(Build.StagingDirectory)\nuget-signed\ - $(System.DefaultWorkingDirectory)\build-tools\create-packs\Microsoft.Android.Sdk.proj - -bl:$(System.DefaultWorkingDirectory)\bin\Build$(XA.Build.Configuration)\push-bar-manifest.binlog - displayName: generate and publish BAR manifest - condition: and(succeeded(), eq(variables['PushXAPackageInfoToMaestro'], 'true')) - - - powershell: | - $versionEndpoint = 'https://maestro-prod.westus2.cloudapp.azure.com/api/assets/darc-version?api-version=2019-01-16' - $darcVersion = $(Invoke-WebRequest -Uri $versionEndpoint -UseBasicParsing).Content - $arcadeServicesSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' - & dotnet tool update microsoft.dotnet.darc --version "$darcVersion" --add-source "$arcadeServicesSource" --tool-path $(Agent.ToolsDirectory)\darc -v n - & $(Agent.ToolsDirectory)\darc\darc add-build-to-channel --default-channels --id $(BARBuildId) --publishing-infra-version 3 --skip-assets-publishing --password $(MaestroAccessToken) --azdev-pat $(publishing-dnceng-devdiv-code-r-build-re) - displayName: add build to default darc channel - condition: and(succeeded(), eq(variables['PushXAPackageInfoToMaestro'], 'true')) - - - template: yaml-templates\upload-results.yaml - parameters: - xaSourcePath: $(System.DefaultWorkingDirectory) - artifactName: Prepare Release - Push Internal - includeBuildResults: true - - -- stage: post_build - displayName: Post Build - dependsOn: - - dotnet_prepare_release - condition: and(eq(variables['MicroBuildSignType'], 'Real'), eq(dependencies.dotnet_prepare_release.result, 'Succeeded')) - jobs: - - job: sbom - displayName: Generate SBOM - timeoutInMinutes: 60 - pool: - name: AzurePipelines-EO - demands: - - ImageOverride -equals AzurePipelinesWindows2022compliant - variables: - Packaging.EnableSBOMSigning: true - workspace: - clean: all - steps: - - checkout: self - submodules: recursive - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: nuget-signed - downloadPath: $(Build.StagingDirectory)\packages - patterns: '*.nupkg' - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: nuget-linux-signed - downloadPath: $(Build.StagingDirectory)\packages - patterns: '*.nupkg' - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(WindowsToolchainPdbArtifactName) - downloadPath: $(Build.StagingDirectory)\packages - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: vs-msi-nugets - downloadPath: $(Build.StagingDirectory)\packages - patterns: '*.nupkg' - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: vsdrop-signed - downloadPath: $(Build.StagingDirectory)\packages - patterns: '*.msi' - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: vsdrop-multitarget-signed - downloadPath: $(Build.StagingDirectory)\packages - patterns: '*.msi' - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: sbom-components-macos - downloadPath: $(Build.StagingDirectory)\sbom\components-macos - - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: sbom-components-linux - downloadPath: $(Build.StagingDirectory)\sbom\components-linux - - - template: compliance/sbom/scan.v1.yml@yaml-templates + artifactName: nuget-linux-signed + downloadPath: $(Build.StagingDirectory)\nuget-signed + + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: vs-msi-nugets + downloadPath: $(Build.StagingDirectory)\nuget-signed + + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(WindowsToolchainPdbArtifactName) + downloadPath: $(Build.StagingDirectory)\nuget-signed + + - template: templates\common\upload-vs-insertion-artifacts.yml@sdk-insertions + parameters: + githubToken: $(GitHub.Token) + githubContext: $(NupkgCommitStatusName) + blobName: $(NupkgCommitStatusName) + packagePrefix: xamarin-android + artifactsPath: $(Build.StagingDirectory)\nuget-signed + yamlResourceName: yaml-templates + + - template: templates\common\upload-vs-insertion-artifacts.yml@sdk-insertions + parameters: + githubToken: $(GitHub.Token) + githubContext: $(VSDropCommitStatusName) + blobName: $(VSDropCommitStatusName) + packagePrefix: xamarin-android + artifactsPath: $(Build.StagingDirectory)\$(VSDropCommitStatusName) + yamlResourceName: yaml-templates + downloadSteps: + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: vsdrop-signed + downloadPath: $(Build.StagingDirectory)\$(VSDropCommitStatusName) + + - template: templates\common\upload-vs-insertion-artifacts.yml@sdk-insertions + parameters: + githubToken: $(GitHub.Token) + githubContext: $(MultiTargetVSDropCommitStatusName) + blobName: $(MultiTargetVSDropCommitStatusName) + packagePrefix: xamarin-android + artifactsPath: $(Build.StagingDirectory)\$(MultiTargetVSDropCommitStatusName) + yamlResourceName: yaml-templates + downloadSteps: + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: vsdrop-multitarget-signed + downloadPath: $(Build.StagingDirectory)\$(MultiTargetVSDropCommitStatusName) + + - powershell: >- + & dotnet build -v:n -c $(XA.Build.Configuration) + -t:PushManifestToBuildAssetRegistry + -p:BuildAssetRegistryToken=$(MaestroAccessToken) + -p:OutputPath=$(Build.StagingDirectory)\nuget-signed\ + $(System.DefaultWorkingDirectory)\build-tools\create-packs\Microsoft.Android.Sdk.proj + -bl:$(System.DefaultWorkingDirectory)\bin\Build$(XA.Build.Configuration)\push-bar-manifest.binlog + displayName: generate and publish BAR manifest + condition: and(succeeded(), eq('${{ parameters.pushXAPackagesToMaestro }}', 'true')) + + - powershell: | + $versionEndpoint = 'https://maestro-prod.westus2.cloudapp.azure.com/api/assets/darc-version?api-version=2019-01-16' + $darcVersion = $(Invoke-WebRequest -Uri $versionEndpoint -UseBasicParsing).Content + $arcadeServicesSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' + & dotnet tool update microsoft.dotnet.darc --version "$darcVersion" --add-source "$arcadeServicesSource" --tool-path $(Agent.ToolsDirectory)\darc -v n + & $(Agent.ToolsDirectory)\darc\darc add-build-to-channel --default-channels --id $(BARBuildId) --publishing-infra-version 3 --skip-assets-publishing --password $(MaestroAccessToken) --azdev-pat $(publishing-dnceng-devdiv-code-r-build-re) + displayName: add build to default darc channel + condition: and(succeeded(), eq('${{ parameters.pushXAPackagesToMaestro }}', 'true')) + + - template: build-tools\automation\yaml-templates\upload-results.yaml@self + parameters: + xaSourcePath: $(System.DefaultWorkingDirectory) + artifactName: Prepare Release - Push Internal + includeBuildResults: true + + # Check - "Xamarin.Android (PoliCheck PoliCheck $(Language))" + - template: security/policheck/v3.yml@yaml-templates parameters: - dropDirectory: $(Build.StagingDirectory)\packages - componentsDirectory: $(Build.StagingDirectory)\sbom - manifestDirectory: $(Build.StagingDirectory)\sbom - packageName: .NET Android - packageVersionRegex: '(?i)^Microsoft.*\.(?\d+\.\d+\.\d+(-.*)?\.\d+).nupkg$' - -# Check - "Xamarin.Android (Compliance)" -- template: security/full/v0.yml@yaml-templates - parameters: - stageDependsOn: [] - credScanSuppressionFile: $(Build.SourcesDirectory)\build-tools\automation\guardian\CredScanSuppressions.json - sourceGdnSuppressionFile: $(Build.SourcesDirectory)\build-tools\automation\guardian\source.gdnsuppress - tsaConfigFile: $(Build.SourcesDirectory)\build-tools\automation\guardian\tsaoptions-v2.json - policheckLocScanEnabled: true - policheckExclusionFilesFolder: $(Build.SourcesDirectory)\build-tools\automation\guardian - policheckGdnSuppressionFilesFolder: $(Build.SourcesDirectory)\build-tools\automation\guardian - policheckChsScanFolder: $(Build.SourcesDirectory)\Localize\loc\zh-Hans - policheckChtScanFolder: $(Build.SourcesDirectory)\Localize\loc\zh-Hant - policheckCsyScanFolder: $(Build.SourcesDirectory)\Localize\loc\cs - policheckDeuScanFolder: $(Build.SourcesDirectory)\Localize\loc\de - policheckEsnScanFolder: $(Build.SourcesDirectory)\Localize\loc\es - policheckFraScanFolder: $(Build.SourcesDirectory)\Localize\loc\fr - policheckItaScanFolder: $(Build.SourcesDirectory)\Localize\loc\it - policheckJpnScanFolder: $(Build.SourcesDirectory)\Localize\loc\ja - policheckKorScanFolder: $(Build.SourcesDirectory)\Localize\loc\ko - policheckPlkScanFolder: $(Build.SourcesDirectory)\Localize\loc\pl - policheckPtbScanFolder: $(Build.SourcesDirectory)\Localize\loc\pt-BR - policheckRusScanFolder: $(Build.SourcesDirectory)\Localize\loc\ru - policheckTrkScanFolder: $(Build.SourcesDirectory)\Localize\loc\tr + windowsImageOverride: $(WindowsPoolImage1ESPT) + stageDependsOn: [] + tsaConfigFile: $(Build.SourcesDirectory)\.gdn\tsaoptions-v2.json + policheckLocScanEnabled: true + policheckExclusionFilesFolder: $(Build.SourcesDirectory)\.gdn\policheck + policheckGdnSuppressionFilesFolder: $(Build.SourcesDirectory)\.gdn\policheck + policheckChsScanFolder: $(Build.SourcesDirectory)\Localize\loc\zh-Hans + policheckChtScanFolder: $(Build.SourcesDirectory)\Localize\loc\zh-Hant + policheckCsyScanFolder: $(Build.SourcesDirectory)\Localize\loc\cs + policheckDeuScanFolder: $(Build.SourcesDirectory)\Localize\loc\de + policheckEsnScanFolder: $(Build.SourcesDirectory)\Localize\loc\es + policheckFraScanFolder: $(Build.SourcesDirectory)\Localize\loc\fr + policheckItaScanFolder: $(Build.SourcesDirectory)\Localize\loc\it + policheckJpnScanFolder: $(Build.SourcesDirectory)\Localize\loc\ja + policheckKorScanFolder: $(Build.SourcesDirectory)\Localize\loc\ko + policheckPlkScanFolder: $(Build.SourcesDirectory)\Localize\loc\pl + policheckPtbScanFolder: $(Build.SourcesDirectory)\Localize\loc\pt-BR + policheckRusScanFolder: $(Build.SourcesDirectory)\Localize\loc\ru + policheckTrkScanFolder: $(Build.SourcesDirectory)\Localize\loc\tr diff --git a/build-tools/automation/guardian/CHT.gdnsuppress b/build-tools/automation/guardian/CHT.gdnsuppress deleted file mode 100644 index 4396a9a378a..00000000000 --- a/build-tools/automation/guardian/CHT.gdnsuppress +++ /dev/null @@ -1,26 +0,0 @@ -{ - "version": "latest", - "suppressionSets": { - "default": { - "name": "default", - "createdDate": "2023-02-24 00:05:39Z", - "lastUpdatedDate": "2023-02-24 00:05:39Z" - } - }, - "results": { - "04910d714a13bf4523ffa77350f654f52114fa4fa3d760c9f63186d41716c019": { - "signature": "04910d714a13bf4523ffa77350f654f52114fa4fa3d760c9f63186d41716c019", - "alternativeSignatures": [], - "target": "Localize/loc/zh-Hant/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx.lcl", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "64550", - "justification": "Reference to the Android package format APK.", - "createdDate": "2023-02-24 00:05:39Z", - "expirationDate": null, - "type": null - } - } -} diff --git a/build-tools/automation/guardian/CredScanSuppressions.json b/build-tools/automation/guardian/CredScanSuppressions.json deleted file mode 100644 index d484f12ded2..00000000000 --- a/build-tools/automation/guardian/CredScanSuppressions.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "tool": "Credential Scanner", - "suppressions": [ - { - "file": "\\src\\Xamarin.Android.Build.Tasks\\Tests\\Xamarin.ProjectTools\\Resources\\Base\\test.keystore", - "_justification": "Dummy keystore file used for testing." - }, - { - "file": "tests\\MSBuildDeviceIntegration\\Tests\\InstallTests.cs", - "_justification": "Password of the dummy keystore file used only for testing." - }, - { - "file": "external\\android-api-docs\\docs\\Mono.Android\\en\\Android.Webkit\\HttpAuthHandler.xml", - "_justification": "Android API documentation, does not contain a password." - }, - { - "file": "external\\android-api-docs\\docs\\Mono.Android\\en\\Android.Webkit\\WebViewDatabase.xml", - "_justification": "Android API documentation, does not contain a password." - }, - { - "file": "external\\android-api-docs\\docs\\Mono.Android\\en\\Java.Security\\KeyStore+PasswordProtection.xml", - "_justification": "Android API documentation, does not contain a password." - }, - { - "file": "external\\android-api-docs\\docs\\Mono.Android\\en\\Javax.Security.Auth.Callback\\PasswordCallback.xml", - "_justification": "Android API documentation, does not contain a password." - }, - { - "file": "external\\android-api-docs\\docs\\Mono.Android\\en\\Javax.Crypto\\ISecretKey.xml", - "_justification": "Android API documentation, does not contain a password." - }, - { - "file": "external\\android-api-docs\\docs\\Mono.Android\\en\\Javax.Crypto\\KeyAgreementSpi.xml", - "_justification": "Android API documentation, does not contain a password." - }, - { - "file": "external\\android-api-docs\\docs\\Mono.Android\\en\\Javax.Crypto.Interfaces\\IPBEKey.xml", - "_justification": "Android API documentation, does not contain a password." - } - ] -} diff --git a/build-tools/automation/guardian/source.gdnsuppress b/build-tools/automation/guardian/source.gdnsuppress deleted file mode 100644 index d0a4455d7c6..00000000000 --- a/build-tools/automation/guardian/source.gdnsuppress +++ /dev/null @@ -1,250 +0,0 @@ -{ - "version": "latest", - "suppressionSets": { - "default": { - "name": "default", - "createdDate": "2023-02-22 23:55:29Z", - "lastUpdatedDate": "2023-05-04 13:54:18Z" - } - }, - "results": { - "5a0a8690d8a06dfdbf6002c67fa64a60a94f3fc77a594034cce20382e88002aa": { - "signature": "5a0a8690d8a06dfdbf6002c67fa64a60a94f3fc77a594034cce20382e88002aa", - "alternativeSignatures": [], - "target": "src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "79459", - "justification": "Reference to an external source file.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "1b319055b8e507b220d0dab341e67e20f49632fd1844a08a4fcc6d4493930ac5": { - "signature": "1b319055b8e507b220d0dab341e67e20f49632fd1844a08a4fcc6d4493930ac5", - "alternativeSignatures": [], - "target": "src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "79459", - "justification": "Reference to an external source file.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "6789cab1bdc97b0cc3ad057b7fdd21d63cdf8bc2679391923803fa240ef81292": { - "signature": "6789cab1bdc97b0cc3ad057b7fdd21d63cdf8bc2679391923803fa240ef81292", - "alternativeSignatures": [], - "target": "Documentation/guides/building-apps/build-properties.md", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "185843", - "justification": "Reference to an ISCII term.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "bbaf5f946cb72748567e41f0df5f1bae05550f4ba7381e21ec6b26d6c3ecec9f": { - "signature": "bbaf5f946cb72748567e41f0df5f1bae05550f4ba7381e21ec6b26d6c3ecec9f", - "alternativeSignatures": [], - "target": "Documentation/guides/building-apps/build-properties.md", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "185837", - "justification": "Reference to an ISCII term.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "db8916a0f0cdca4082c540921dd362e09a9ff413862ab826308411b76ee35789": { - "signature": "db8916a0f0cdca4082c540921dd362e09a9ff413862ab826308411b76ee35789", - "alternativeSignatures": [], - "target": "src/Mono.Android/Android.Util/Log.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "80418", - "justification": "Reference to an Android logging function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "6d1fb3a483eb491710d6a09ed0b4bab47f13942d0c6fc744e6683614a66604ab": { - "signature": "6d1fb3a483eb491710d6a09ed0b4bab47f13942d0c6fc744e6683614a66604ab", - "alternativeSignatures": [], - "target": "src/Mono.Android/Android.Util/Log.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "80418", - "justification": "Reference to an Android logging function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "b07e75fc8a506b94690dbd06877da06c1228e40e7deda3967f6b882b842f726d": { - "signature": "b07e75fc8a506b94690dbd06877da06c1228e40e7deda3967f6b882b842f726d", - "alternativeSignatures": [], - "target": "src/Mono.Android/Android.Util/Log.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "80418", - "justification": "Reference to an Android logging function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "87d8313310c2dd42021844b95bdcb9121bf10036fea5b212b945e0732a456e5a": { - "signature": "87d8313310c2dd42021844b95bdcb9121bf10036fea5b212b945e0732a456e5a", - "alternativeSignatures": [], - "target": "src/Mono.Android/Android.Util/Log.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "80418", - "justification": "Reference to an Android logging function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "8e5400e0233c8d887ad48bd8a48e8a7be5a579f9eefad521419b6df0828bbfac": { - "signature": "8e5400e0233c8d887ad48bd8a48e8a7be5a579f9eefad521419b6df0828bbfac", - "alternativeSignatures": [], - "target": "src/Mono.Android/Android.Util/Log.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "80418", - "justification": "Reference to an Android logging function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "1b38e026fae90da4ae2fe9151c9c1ebd73c8b3c2c5f072ceae390a3ceec2fb97": { - "signature": "1b38e026fae90da4ae2fe9151c9c1ebd73c8b3c2c5f072ceae390a3ceec2fb97", - "alternativeSignatures": [], - "target": "src/Mono.Android/Android.Util/Log.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "80418", - "justification": "Reference to an Android logging function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "a2b4d032c59a9d1211d218c3cd550cf8febb369941d70284d07d03ebee855bc0": { - "signature": "a2b4d032c59a9d1211d218c3cd550cf8febb369941d70284d07d03ebee855bc0", - "alternativeSignatures": [], - "target": "src/monodroid/jni/logger.cc", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "79668", - "justification": "Reference to find first set bit function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "1c87b45a6044d205dc3f3562f349c238f7cabe22b4609da762df9dc44151e9fb": { - "signature": "1c87b45a6044d205dc3f3562f349c238f7cabe22b4609da762df9dc44151e9fb", - "alternativeSignatures": [], - "target": "src/monodroid/jni/logger.cc", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "79668", - "justification": "Reference to find first set bit function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "a6639098c4785509a4215c9e2fc10f82c06fce461915dc11a00227ddec558845": { - "signature": "a6639098c4785509a4215c9e2fc10f82c06fce461915dc11a00227ddec558845", - "alternativeSignatures": [], - "target": "src/monodroid/jni/logger.cc", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "79668", - "justification": "Reference to find first set bit function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "d6b3df0b1d35cb4acec6a954acc145c9ec22041cd463b94ff080682c65a9bd62": { - "signature": "d6b3df0b1d35cb4acec6a954acc145c9ec22041cd463b94ff080682c65a9bd62", - "alternativeSignatures": [], - "target": "src/monodroid/jni/logger.cc", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "79668", - "justification": "Reference to find first set bit function.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "b34b42aa41018376a31460c142f2ae910704725d9e9a4470f92b587df682369b": { - "signature": "b34b42aa41018376a31460c142f2ae910704725d9e9a4470f92b587df682369b", - "alternativeSignatures": [], - "target": "src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "80411", - "justification": "Reference to output from an external tool.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "75474fa652dbbf8f96826100a5fe37ba686a032ca07d61ef68a79c8e4412c150": { - "signature": "75474fa652dbbf8f96826100a5fe37ba686a032ca07d61ef68a79c8e4412c150", - "alternativeSignatures": [], - "target": "src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/Linker.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "79459", - "justification": "Reference to an external source file.", - "createdDate": "2023-02-22 23:55:29Z", - "expirationDate": null, - "type": null - }, - "243e199c7aec22377e0363bdca82384278cc36b0674f35697935fde6c45cfd0e": { - "signature": "243e199c7aec22377e0363bdca82384278cc36b0674f35697935fde6c45cfd0e", - "alternativeSignatures": [], - "target": "build-tools/xaprepare/xaprepare/ThirdPartyNotices/MavenNet.cs", - "memberOf": [ - "default" - ], - "tool": "policheck", - "ruleId": "79607", - "justification": "Reference to a proper name.", - "createdDate": "2023-10-26 21:20:54Z", - "expirationDate": null, - "type": null - } - } -} diff --git a/build-tools/automation/yaml-templates/apk-instrumentation.yaml b/build-tools/automation/yaml-templates/apk-instrumentation.yaml index 7f8b03133bf..0eac8e12dd8 100644 --- a/build-tools/automation/yaml-templates/apk-instrumentation.yaml +++ b/build-tools/automation/yaml-templates/apk-instrumentation.yaml @@ -9,41 +9,24 @@ parameters: testResultsFormat: NUnit artifactSource: "" artifactFolder: "" - useDotNet: true condition: succeeded() retryCountOnTaskFailure: 1 steps: -- ${{ if eq(parameters.useDotNet, false) }}: - - task: MSBuild@1 +- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + parameters: + configuration: ${{ parameters.buildConfiguration }} + xaSourcePath: ${{ parameters.xaSourcePath }} displayName: run ${{ parameters.testName }} - inputs: - solution: ${{ parameters.project }} - configuration: ${{ parameters.configuration }} - msbuildArguments: >- - /restore - /t:RunTestApp - /bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/run-${{ parameters.testName }}.binlog - ${{ parameters.extraBuildArgs }} + project: ${{ parameters.project }} + arguments: >- + -t:RunTestApp + -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/run-${{ parameters.testName }}.binlog + -v:n -c ${{ parameters.configuration }} ${{ parameters.extraBuildArgs }} condition: ${{ parameters.condition }} continueOnError: true retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }} -- ${{ if eq(parameters.useDotNet, true) }}: - - template: run-dotnet-preview.yaml - parameters: - configuration: ${{ parameters.buildConfiguration }} - xaSourcePath: ${{ parameters.xaSourcePath }} - displayName: run ${{ parameters.testName }} - project: ${{ parameters.project }} - arguments: >- - -t:RunTestApp - -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/run-${{ parameters.testName }}.binlog - -v:n -c ${{ parameters.configuration }} ${{ parameters.extraBuildArgs }} - condition: ${{ parameters.condition }} - continueOnError: true - retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }} - - script: > DEST="$(Build.StagingDirectory)/Test${{ parameters.configuration }}/${{ parameters.artifactFolder }}/" && mkdir -p "$DEST" && diff --git a/build-tools/automation/yaml-templates/build-linux.yaml b/build-tools/automation/yaml-templates/build-linux.yaml index ba399bdfd3b..673270ca735 100644 --- a/build-tools/automation/yaml-templates/build-linux.yaml +++ b/build-tools/automation/yaml-templates/build-linux.yaml @@ -1,6 +1,4 @@ parameters: - buildPoolName: $(LinuxBuildPoolName) - buildPoolImage: $(LinuxBuildPoolImage) buildResultArtifactName: Build Results - Linux checkoutCommit: '' checkoutPath: 's/xamarin-android' @@ -13,6 +11,7 @@ parameters: repositoryAlias: self stageName: linux_build stageDisplayName: Linux + use1ESTemplate: true stages: - stage: ${{ parameters.stageName }} @@ -21,17 +20,26 @@ stages: ${{ if and(ne(parameters.dependsOn, ''), ne(parameters.dependsOnResult, '')) }}: condition: eq(dependencies.${{ parameters.dependsOn }}.result, '${{ parameters.dependsOnResult }}') jobs: + # Check - "Xamarin.Android (Linux Linux > Build)" - job: ${{ parameters.jobName }} displayName: ${{ parameters.jobDisplayName }} pool: - name: ${{ parameters.buildPoolName }} - vmImage: ${{ parameters.buildPoolImage }} - timeoutInMinutes: 180 + name: MAUI-1ESPT + image: $(LinuxPoolImage1ESPT) + os: linux + timeoutInMinutes: 240 workspace: clean: all variables: CXX: g++-10 CC: gcc-10 + ${{ if eq(parameters.use1ESTemplate, true) }}: + templateContext: + outputs: + - output: pipelineArtifact + displayName: upload linux sdk + artifactName: ${{ parameters.nugetArtifactName }} + targetPath: $(System.DefaultWorkingDirectory)/xamarin-android/bin/Build$(XA.Build.Configuration)/nuget-linux steps: - template: sdk-unified/steps/checkout/v1.yml@yaml-templates parameters: @@ -44,8 +52,6 @@ stages: # https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#checkout-path - checkout: maui - - template: setup-ubuntu.yaml - - ${{ if ne(variables['System.PullRequest.IsFork'], 'True') }}: - checkout: monodroid clean: true @@ -84,39 +90,18 @@ stages: workingDirectory: $(System.DefaultWorkingDirectory)/xamarin-android displayName: copy linux sdk - - task: PublishPipelineArtifact@1 - displayName: upload linux sdk - inputs: - artifactName: ${{ parameters.nugetArtifactName }} - targetPath: $(System.DefaultWorkingDirectory)/xamarin-android/bin/Build$(XA.Build.Configuration)/nuget-linux - - - powershell: | - [IO.Directory]::CreateDirectory("$(Build.StagingDirectory)/empty") - [IO.Directory]::CreateDirectory("$(Build.StagingDirectory)/sbom-components") - displayName: create SBOM directories - condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) - - - task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 - displayName: generate components SBOM - condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) - inputs: - BuildDropPath: $(Build.StagingDirectory)/empty - BuildComponentPath: $(System.DefaultWorkingDirectory)/xamarin-android - ManifestDirPath: $(Build.StagingDirectory)/sbom-components - PackageName: .NET Android - Verbosity: Verbose - - - task: PublishBuildArtifacts@1 - displayName: publish components SBOM - condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) - inputs: - artifactName: sbom-components-linux - pathToPublish: $(Build.StagingDirectory)/sbom-components + - ${{ if ne(parameters.use1ESTemplate, true) }}: + - task: PublishPipelineArtifact@1 + displayName: upload linux sdk + inputs: + artifactName: ${{ parameters.nugetArtifactName }} + targetPath: $(System.DefaultWorkingDirectory)/xamarin-android/bin/Build$(XA.Build.Configuration)/nuget-linux - - template: upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self parameters: xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android artifactName: ${{ parameters.buildResultArtifactName }} includeBuildResults: true + use1ESTemplate: ${{ parameters.use1ESTemplate }} - - template: fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self diff --git a/build-tools/automation/yaml-templates/build-macos.yaml b/build-tools/automation/yaml-templates/build-macos.yaml index abdb0103a09..2d12c21573a 100644 --- a/build-tools/automation/yaml-templates/build-macos.yaml +++ b/build-tools/automation/yaml-templates/build-macos.yaml @@ -1,9 +1,8 @@ parameters: - buildPoolName: $(MacBuildPoolName) - buildPoolImage: $(MacBuildPoolImage) buildResultArtifactName: Build Results - macOS checkoutCommit: '' checkoutPath: 's/xamarin-android' + xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android checkoutPersistCredentials: false dependsOn: '' dependsOnResult: '' @@ -16,6 +15,7 @@ parameters: stageDisplayName: Mac testAssembliesArtifactName: $(TestAssembliesArtifactName) windowsToolchainPdbArtifactName: $(WindowsToolchainPdbArtifactName) + use1ESTemplate: true stages: - stage: ${{ parameters.stageName }} @@ -24,18 +24,43 @@ stages: ${{ if and(ne(parameters.dependsOn, ''), ne(parameters.dependsOnResult, '')) }}: condition: eq(dependencies.${{ parameters.dependsOn }}.result, '${{ parameters.dependsOnResult }}') jobs: - # Check - "Xamarin.Android (macOS > Build)" + # Check - "Xamarin.Android (Mac macOS > Build)" - job: ${{ parameters.jobName }} displayName: ${{ parameters.jobDisplayName }} pool: - name: ${{ parameters.buildPoolName }} - vmImage: ${{ parameters.buildPoolImage }} - ${{ if or(and(ne(variables['Build.DefinitionName'],'Xamarin.Android'), ne(variables['Build.DefinitionName'], 'Xamarin.Android-Private'), ne(variables['Build.DefinitionName'], 'xamarin.megapipeline')), eq(variables['Build.Reason'], 'PullRequest')) }}: + ${{ if or(eq(variables['Build.DefinitionName'], 'Xamarin.Android-PR'), eq(variables['Build.DefinitionName'], 'Xamarin.Android Nightly')) }}: + name: VSEng-Xamarin-RedmondMac-Android-Untrusted demands: macOS.Name -equals Monterey + ${{ else }}: + name: Azure Pipelines + vmImage: $(HostedMacImage) + os: macOS timeoutInMinutes: 240 cancelTimeoutInMinutes: 5 workspace: clean: all + ${{ if eq(parameters.use1ESTemplate, true) }}: + templateContext: + outputParentDirectory: ${{ parameters.xaSourcePath }}/bin + outputs: + - output: pipelineArtifact + displayName: upload nupkgs + artifactName: ${{ parameters.nugetArtifactName }} + targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-unsigned + - output: pipelineArtifact + displayName: upload Windows toolchain pdb files + artifactName: ${{ parameters.windowsToolchainPdbArtifactName }} + targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/windows-toolchain-pdb + - output: pipelineArtifact + displayName: upload test assemblies + artifactName: ${{ parameters.testAssembliesArtifactName }} + targetPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) + sbomEnabled: false + - output: pipelineArtifact + displayName: upload build tools inventory + artifactName: AndroidBuildToolsInventory + targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/buildtoolsinventory.csv + sbomEnabled: false steps: - template: sdk-unified/steps/checkout/v1.yml@yaml-templates parameters: @@ -44,38 +69,18 @@ stages: path: ${{ parameters.checkoutPath }} persistCredentials: ${{ parameters.checkoutPersistCredentials }} - - template: commercial-build.yaml + - template: /build-tools/automation/yaml-templates/commercial-build.yaml@self parameters: + xaSourcePath: ${{ parameters.xaSourcePath }} installerArtifactName: ${{ parameters.installerArtifactName }} nugetArtifactName: ${{ parameters.nugetArtifactName }} testAssembliesArtifactName: ${{ parameters.testAssembliesArtifactName }} windowsToolchainPdbArtifactName: ${{ parameters.windowsToolchainPdbArtifactName }} + use1ESTemplate: ${{ parameters.use1ESTemplate }} - - powershell: | - [IO.Directory]::CreateDirectory("$(Build.StagingDirectory)/empty") - [IO.Directory]::CreateDirectory("$(Build.StagingDirectory)/sbom-components") - displayName: create SBOM directories - condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) - - - task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 - displayName: generate components SBOM - condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) - inputs: - BuildDropPath: $(Build.StagingDirectory)/empty - BuildComponentPath: $(System.DefaultWorkingDirectory)/xamarin-android - ManifestDirPath: $(Build.StagingDirectory)/sbom-components - PackageName: .NET Android - Verbosity: Verbose - - - task: PublishBuildArtifacts@1 - displayName: publish components SBOM - condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) - inputs: - artifactName: sbom-components-macos - pathToPublish: $(Build.StagingDirectory)/sbom-components - - - template: upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self parameters: - xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android + xaSourcePath: ${{ parameters.xaSourcePath }} artifactName: ${{ parameters.buildResultArtifactName }} includeBuildResults: true + use1ESTemplate: ${{ parameters.use1ESTemplate }} diff --git a/build-tools/automation/yaml-templates/build-windows.yaml b/build-tools/automation/yaml-templates/build-windows.yaml index a2c03bfcb79..e3867113a22 100644 --- a/build-tools/automation/yaml-templates/build-windows.yaml +++ b/build-tools/automation/yaml-templates/build-windows.yaml @@ -1,5 +1,4 @@ parameters: - buildPool: $(1ESWindowsPool) buildResultArtifactName: Build Results - Windows checkoutCommit: '' checkoutPath: '' @@ -20,11 +19,14 @@ stages: ${{ if and(ne(parameters.dependsOn, ''), ne(parameters.dependsOnResult, '')) }}: condition: eq(dependencies.${{ parameters.dependsOn }}.result, '${{ parameters.dependsOnResult }}') jobs: - # Check - "Xamarin.Android (Windows > Build & Smoke Test)" + # Check - "Xamarin.Android (Windows Windows > Build & Smoke Test)" - job: ${{ parameters.jobName }} displayName: ${{ parameters.jobDisplayName }} - pool: ${{ parameters.buildPool }} - timeoutInMinutes: 360 + pool: + name: MAUI-1ESPT + image: $(WindowsPoolImage1ESPT) + os: windows + timeoutInMinutes: 240 steps: - template: sdk-unified/steps/checkout/v1.yml@yaml-templates parameters: @@ -33,15 +35,15 @@ stages: path: ${{ parameters.checkoutPath }} persistCredentials: ${{ parameters.checkoutPersistCredentials }} - - template: kill-processes.yaml + - template: /build-tools/automation/yaml-templates/kill-processes.yaml@self - - template: clean.yaml + - template: /build-tools/automation/yaml-templates/clean.yaml@self - script: | echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_17_X64% displayName: set JI_JAVA_HOME to $(JAVA_HOME_17_X64) - - template: use-dot-net.yaml + - template: /build-tools/automation/yaml-templates/use-dot-net.yaml@self parameters: remove_dotnet: true @@ -52,7 +54,7 @@ stages: arguments: '-c $(XA.Build.Configuration) -t:Prepare --no-restore -p:AutoProvision=true -bl:$(System.DefaultWorkingDirectory)\bin\Build$(XA.Build.Configuration)\dotnet-build-prepare.binlog' # Build, pack .nupkgs, and extract workload packs to dotnet preview test directory - - template: run-dotnet-preview.yaml + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self parameters: project: Xamarin.Android.sln arguments: >- @@ -61,16 +63,15 @@ stages: displayName: Build Solution continueOnError: false - - template: install-global-tool.yaml + - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml@self parameters: toolName: apkdiff version: $(ApkDiffToolVersion) - - template: run-nunit-tests.yaml + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self parameters: testRunTitle: Smoke MSBuild Tests - Windows Dotnet Build testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\$(DotNetStableTargetFramework)\Xamarin.Android.Build.Tests.dll - testResultsFile: TestResult-SmokeMSBuildTests-WinDotnetBuild-$(XA.Build.Configuration).xml dotNetTestExtraArgs: --filter "TestCategory = SmokeTests" - task: BatchScript@1 @@ -79,9 +80,9 @@ stages: filename: dotnet-local.cmd arguments: build samples\HelloWorld\HelloWorld\HelloWorld.DotNet.csproj - - template: upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self parameters: artifactName: ${{ parameters.buildResultArtifactName }} includeBuildResults: true - - template: fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self diff --git a/build-tools/automation/yaml-templates/commercial-build.yaml b/build-tools/automation/yaml-templates/commercial-build.yaml index b2713654661..7024dbd6dc5 100644 --- a/build-tools/automation/yaml-templates/commercial-build.yaml +++ b/build-tools/automation/yaml-templates/commercial-build.yaml @@ -5,12 +5,13 @@ parameters: nugetArtifactName: $(NuGetArtifactName) testAssembliesArtifactName: $(TestAssembliesArtifactName) windowsToolchainPdbArtifactName: $(WindowsToolchainPdbArtifactName) + use1ESTemplate: true steps: - script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/android-toolchain/jdk-17" displayName: set JI_JAVA_HOME -- template: use-dot-net.yaml +- template: /build-tools/automation/yaml-templates/use-dot-net.yaml@self parameters: remove_dotnet: true @@ -27,13 +28,6 @@ steps: # https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#checkout-path - checkout: maui -- script: > - ls -l /Applications && - sudo xcode-select --switch /Applications/Xcode_14.2.app && - xcode-select --print-path - displayName: Use Xcode 14.2 - condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) - - ${{ if ne(variables['System.PullRequest.IsFork'], 'True') }}: # Clone 'monodroid' without submodules - checkout: monodroid @@ -72,7 +66,7 @@ steps: displayName: CodeQL 3000 Finalize condition: and(succeededOrFailed(), eq(variables['Codeql.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) -- template: install-microbuild-tooling.yaml +- template: /build-tools/automation/yaml-templates/install-microbuild-tooling.yaml@self parameters: condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) @@ -121,7 +115,7 @@ steps: /p:MicroBuildOverridePluginDirectory=$(Build.StagingDirectory)/MicroBuild/Plugins /bl:${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/sign-bu-ex.binlog -- template: remove-microbuild-tooling.yaml +- template: /build-tools/automation/yaml-templates/remove-microbuild-tooling.yaml@self parameters: condition: and(succeededOrFailed(), eq(variables['MicroBuildSignType'], 'Real')) @@ -129,18 +123,6 @@ steps: workingDirectory: ${{ parameters.xaSourcePath }} displayName: make create-installers -- task: PublishPipelineArtifact@1 - displayName: upload nupkgs - inputs: - artifactName: ${{ parameters.nugetArtifactName }} - targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-unsigned - -- task: PublishPipelineArtifact@1 - displayName: upload test assemblies - inputs: - artifactName: ${{ parameters.testAssembliesArtifactName }} - targetPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) - - script: > mkdir -p ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/windows-toolchain-pdb && cd ${{ parameters.xaSourcePath }}/bin/$(XA.Build.Configuration)/lib/packs/Microsoft.Android.Sdk.Darwin/*/tools/binutils/windows-toolchain-pdb && @@ -148,14 +130,27 @@ steps: workingDirectory: ${{ parameters.xaSourcePath }} displayName: zip Windows toolchain pdb files -- task: PublishPipelineArtifact@1 - displayName: upload Windows toolchain pdb files - inputs: - artifactName: ${{ parameters.windowsToolchainPdbArtifactName }} - targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/windows-toolchain-pdb - -- task: PublishPipelineArtifact@1 - displayName: upload build tools inventory - inputs: - artifactName: AndroidBuildToolsInventory - targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/buildtoolsinventory.csv +- ${{ if ne(parameters.use1ESTemplate, true) }}: + - task: PublishPipelineArtifact@1 + displayName: upload nupkgs + inputs: + artifactName: ${{ parameters.nugetArtifactName }} + targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/nuget-unsigned + + - task: PublishPipelineArtifact@1 + displayName: upload test assemblies + inputs: + artifactName: ${{ parameters.testAssembliesArtifactName }} + targetPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) + + - task: PublishPipelineArtifact@1 + displayName: upload Windows toolchain pdb files + inputs: + artifactName: ${{ parameters.windowsToolchainPdbArtifactName }} + targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/windows-toolchain-pdb + + - task: PublishPipelineArtifact@1 + displayName: upload build tools inventory + inputs: + artifactName: AndroidBuildToolsInventory + targetPath: ${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/buildtoolsinventory.csv diff --git a/build-tools/automation/yaml-templates/install-global-tool.yaml b/build-tools/automation/yaml-templates/install-dotnet-tool.yaml similarity index 75% rename from build-tools/automation/yaml-templates/install-global-tool.yaml rename to build-tools/automation/yaml-templates/install-dotnet-tool.yaml index 69ac8c28583..65e9cf02243 100644 --- a/build-tools/automation/yaml-templates/install-global-tool.yaml +++ b/build-tools/automation/yaml-templates/install-dotnet-tool.yaml @@ -18,6 +18,10 @@ steps: command: custom custom: tool arguments: >- - update ${{ parameters.toolName }} -g + update ${{ parameters.toolName }} -v:diag + --tool-path $(Agent.ToolsDirectory) --version ${{ parameters.version }} --add-source "https://api.nuget.org/v3/index.json" + +- script: echo "##vso[task.prependpath]$(Agent.ToolsDirectory)" + displayName: add $(Agent.ToolsDirectory) to path diff --git a/build-tools/automation/yaml-templates/plots-to-appinsights.yaml b/build-tools/automation/yaml-templates/plots-to-appinsights.yaml deleted file mode 100644 index b141919bc1a..00000000000 --- a/build-tools/automation/yaml-templates/plots-to-appinsights.yaml +++ /dev/null @@ -1,62 +0,0 @@ -parameters: - configuration: '' - environment: Production - buildSystem: Azure DevOps - buildRepo: $(Build.Repository.Name) - buildReason: $(Build.Reason) - buildPipelineName: $(Build.DefinitionName) - buildId: $(Build.BuildId) - buildNumber: $(Build.BuildNumber) - buildUrl: $(Build.BuildUri) - buildCommit: $(Build.SourceVersion) - plotGroup: '' - plotTitle: '' - plotPathAndFilename: '' - appInsightsTelemetryKey: $(XA.Plots.AppInsightsTelemetryKey) # Defined as a hidden variable on the Xamarin.Android CI build definition: https://devdiv.visualstudio.com/DevDiv/_apps/hub/ms.vss-ciworkflow.build-ci-hub?_a=edit-build-definition&id=11410&view=Tab_Variables - condition: succeeded() - -steps: -- powershell: | - Write-Host "Current directory" - Get-Location - - Write-Host "Input parameters:" - Write-Host " configuration ${{ parameters.configuration }}" - Write-Host " environment ${{ parameters.environment }}" - Write-Host " buildSystem ${{ parameters.buildSystem }}" - Write-Host " buildRepo ${{ parameters.buildRepo }}" - Write-Host " buildReason ${{ parameters.buildReason }}" - Write-Host " buildPipelineName ${{ parameters.buildPipelineName }}" - Write-Host " buildId ${{ parameters.buildId }}" - Write-Host " buildNumber ${{ parameters.buildNumber }}" - Write-Host " buildUrl ${{ parameters.buildUrl }}" - Write-Host " buildCommit ${{ parameters.buildCommit }}" - Write-Host " plotGroup ${{ parameters.plotGroup }}" - Write-Host " plotTitle ${{ parameters.plotTitle }}" - Write-Host " plotPathAndFilename ${{ parameters.plotPathAndFilename }}" - - $buildReason = "${{ parameters.buildReason }}" - - # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#build-variables - $buildType = [string]::Empty - switch ($buildReason) { - 'Manual' { $buildType = 'Manual' } - 'IndividualCI' { $buildType = 'CI' } - 'PullRequest' { $buildType = 'PR' } - default { $buildType = 'Unknown' } - } - - if ($buildType -eq 'CI' -Or $buildType -eq 'Manual') { - $azureTimestampFormatUtc = 'yyyy-MM-ddTHH:mm:ss.fffffffZ' - $buildTime = [DateTime]::UtcNow.ToString($azureTimestampFormatUtc) - Write-Host $buildTime - Write-Host "Sending plot telemtry" - mono "$(System.DefaultWorkingDirectory)/build-tools/plots-to-appinsights/bin/${{ parameters.configuration }}/ProcessPlotCSVFile.exe" -d:"${buildTime}" -e:"${{ parameters.environment }}" -r:"${{ parameters.buildRepo }}" -t:"${buildType}" -p:"${{ parameters.buildPipelineName }}" -c:${{ parameters.buildCommit }} -i:${{ parameters.buildId }} -n:"${{ parameters.buildNumber }}" -u:"${{ parameters.buildUrl }}" -pg:"${{ parameters.plotGroup }}" -pt:"${{ parameters.plotTitle }}" -k:"${{ parameters.appInsightsTelemetryKey }}" "${{ parameters.plotPathAndFilename }}" - } else { - Write-Host "WARNING: Plot telmemetry not sent. Plot telemetry is only sent for continuous integration (CI) or manual builds. buildType: ${buildType}" - } - errorActionPreference: silentlyContinue - continueOnError: true - ignoreLASTEXITCODE: true - displayName: 'Plots to AppInsights: ${{ parameters.plotTitle }}' - condition: ${{ parameters.condition }} \ No newline at end of file diff --git a/build-tools/automation/yaml-templates/publish-artifact.yaml b/build-tools/automation/yaml-templates/publish-artifact.yaml index 5bfb098624e..50c7824282d 100644 --- a/build-tools/automation/yaml-templates/publish-artifact.yaml +++ b/build-tools/automation/yaml-templates/publish-artifact.yaml @@ -3,6 +3,7 @@ parameters: artifactName: artifact targetPath: $(Build.ArtifactStagingDirectory) condition: always() + use1ESTemplate: true steps: # Add the "(Attempt X)" for retries, but leave the initial run blank @@ -12,9 +13,17 @@ steps: displayName: Set upload artifact name condition: ${{ parameters.condition }} -- task: PublishPipelineArtifact@1 - displayName: ${{ parameters.displayName }} - inputs: - artifactName: ${{ parameters.artifactName }} $(UploadAttemptSuffix) - targetPath: ${{ parameters.targetPath }} - condition: ${{ parameters.condition }} +- ${{ if eq(parameters.use1ESTemplate, true) }}: + - task: 1ES.PublishPipelineArtifact@1 + displayName: ${{ parameters.displayName }} + inputs: + artifactName: ${{ parameters.artifactName }} $(UploadAttemptSuffix) + targetPath: ${{ parameters.targetPath }} + condition: ${{ parameters.condition }} +- ${{ else }}: + - task: PublishPipelineArtifact@1 + displayName: ${{ parameters.displayName }} + inputs: + artifactName: ${{ parameters.artifactName }} $(UploadAttemptSuffix) + targetPath: ${{ parameters.targetPath }} + condition: ${{ parameters.condition }} diff --git a/build-tools/automation/yaml-templates/run-designer-tests.yml b/build-tools/automation/yaml-templates/run-designer-tests.yml deleted file mode 100644 index f6a63f5adc6..00000000000 --- a/build-tools/automation/yaml-templates/run-designer-tests.yml +++ /dev/null @@ -1,79 +0,0 @@ -parameters: - designerSourcePath: $(System.DefaultWorkingDirectory) - nunitConsoleVersion: '3.9.0' - runAddinTests: true - testResultArtifactName: Test Results - Designer - Windows - -steps: -- task: DeleteFiles@1 - displayName: Delete Test Outputs - inputs: - SourceFolder: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests - Contents: | - CustomControlsOutput - AndroidCustomControlsClass/obj - AndroidCustomControlsBinding/obj - AndroidCustomControls/obj - AndroidCustomControlsClass/bin - AndroidCustomControlsBinding/bin - AndroidCustomControls/bin - -- task: NuGetCommand@2 - displayName: Install NUnit.Console ${{ parameters.nunitConsoleVersion }} - inputs: - command: custom - arguments: install NUnit.Console -version ${{ parameters.nunitConsoleVersion }} -OutputDirectory ${{ parameters.designerSourcePath }}/packages - -- powershell: | - $nunitConsole = [IO.Path]::Combine("${{ parameters.designerSourcePath }}", "packages", "NUnit.ConsoleRunner.${{ parameters.nunitConsoleVersion }}", "tools", "nunit3-console.exe") - if ([Environment]::OSVersion.Platform -eq "Unix") - { - mono64 "$nunitConsole" "-labels=All" "-result=TestResult_AndroidDesignerUnitTests.xml" "Xamarin.AndroidDesigner.UnitTests.dll" - } - else - { - ."$nunitConsole" "-labels=All" "-result=TestResult_AndroidDesignerUnitTests.xml" "Xamarin.AndroidDesigner.UnitTests.dll" - } - displayName: Run Unit Tests - workingDirectory: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/bin-tests/Debug - -- powershell: | - if ([Environment]::OSVersion.Platform -eq "Unix") - { - mono64 "--debug" "GuiUnit.exe" "-labels=All" "-result=TestResult_AndroidDesigner.xml" "Xamarin.AndroidDesigner.Tests.dll" - } - else - { - .\GuiUnit.exe "-labels=All" "-result=TestResult_AndroidDesigner.xml" "Xamarin.AndroidDesigner.Tests.dll" - } - displayName: Run GUI Tests - workingDirectory: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/bin/Debug - condition: false # https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1583237 - -- task: PublishTestResults@2 - displayName: Publish Core Unit Test Results - inputs: - testResultsFormat: NUnit - testResultsFiles: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android/Xamarin.AndroidDesigner.Tests/**/TestResult_*.xml - testRunTitle: Xamarin.AndroidDesigner.Tests - condition: succeededOrFailed() - -- task: CopyFiles@2 - displayName: 'Copy binlogs' - inputs: - sourceFolder: ${{ parameters.designerSourcePath }}/Xamarin.Designer.Android - contents: | - **/*.binlog - **/hs*.log - **/hs*.mdmp - targetFolder: $(Build.ArtifactStagingDirectory)/designer-binlogs - overWrite: true - flattenFolders: true - condition: ne(variables['Agent.JobStatus'], 'Succeeded') - -- template: publish-artifact.yaml - parameters: - displayName: upload designer binlogs - artifactName: ${{ parameters.testResultArtifactName }} - targetPath: $(Build.ArtifactStagingDirectory)/designer-binlogs - condition: ne(variables['Agent.JobStatus'], 'Succeeded') diff --git a/build-tools/automation/yaml-templates/run-emulator-tests.yaml b/build-tools/automation/yaml-templates/run-emulator-tests.yaml index e3484dd5c5b..bbf7e212943 100644 --- a/build-tools/automation/yaml-templates/run-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/run-emulator-tests.yaml @@ -6,6 +6,7 @@ parameters: jobTimeout: 360 jdkTestFolder: $(JAVA_HOME_17_X64) testSteps: [] + use1ESTemplate: true jobs: - job: mac_${{ parameters.jobName }}_tests @@ -25,11 +26,8 @@ jobs: echo "##vso[task.setvariable variable=JAVA_HOME]${{ parameters.jdkTestFolder }}" displayName: set JAVA_HOME to ${{ parameters.jdkTestFolder }} - - template: setup-test-environment.yaml + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self parameters: - installLegacyDotNet: false - restoreNUnitConsole: false - updateMono: false xaprepareScenario: EmulatorTestDependencies jdkTestFolder: ${{ parameters.jdkTestFolder }} @@ -38,14 +36,15 @@ jobs: artifactName: $(TestAssembliesArtifactName) downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - template: start-stop-emulator.yaml + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self parameters: emulatorMSBuildArgs: ${{ parameters.emulatorMSBuildArgs }} - ${{ parameters.testSteps }} - - template: upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self parameters: artifactName: Test Results - ${{ parameters.jobName }} With Emulator - macOS + use1ESTemplate: ${{ parameters.use1ESTemplate }} - - template: fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self diff --git a/build-tools/automation/yaml-templates/run-installer.yaml b/build-tools/automation/yaml-templates/run-installer.yaml deleted file mode 100644 index b66b0209ada..00000000000 --- a/build-tools/automation/yaml-templates/run-installer.yaml +++ /dev/null @@ -1,40 +0,0 @@ -parameters: - provisionExtraArgs: -vv -f - -steps: -- task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(InstallerArtifactName) - downloadPath: $(System.DefaultWorkingDirectory) - patterns: xamarin.android*.pkg - condition: and(succeeded(), eq(variables['agent.os'], 'Darwin')) - -- task: DownloadPipelineArtifact@2 - inputs: - artifactName: $(InstallerArtifactName) - downloadPath: $(System.DefaultWorkingDirectory) - patterns: Xamarin.Android*.vsix - condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT')) - -- powershell: | - $itemPattern = "*.vsix" - if ([Environment]::OSVersion.Platform -eq "Unix") { - $itemPattern = "*.pkg" - } - $searchDir = [System.IO.Path]::Combine("$(System.DefaultWorkingDirectory)", "*") - $installer = Get-ChildItem -Path "$searchDir" -Include "$itemPattern" -File - if (![System.IO.File]::Exists($installer)) { - throw [System.IO.FileNotFoundException] "Installer not found in $artifactDirectory." - } - Write-Host "##vso[task.setvariable variable=XA.Provisionator.Args]$installer" - displayName: find installer and set provisionator variable - condition: and(succeeded(), ne(variables['agent.os'], 'Linux')) - -- task: provisionator@2 - inputs: - provisionator_uri: $(provisionator-uri) - github_token: $(GitHub.Token) - provisioning_script: $(XA.Provisionator.Args) - provisioning_extra_args: ${{ parameters.provisionExtraArgs }} - # Disabled on Windows on .NET release branches - condition: and(succeeded(), ne(variables['System.PullRequest.IsFork'], 'True'), ne(variables['agent.os'], 'Linux'), or(eq(variables.IsRelOrTargetingRel, 'False'), eq(variables['agent.os'], 'Darwin'))) diff --git a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml index 6d5193a5f87..62be739a9a9 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml @@ -15,27 +15,29 @@ jobs: parallel: ${{ parameters.agentCount }} displayName: ${{ parameters.jobDisplayName }} ${{ if eq(parameters.testOS, 'Windows') }}: - pool: $(1ESWindowsPool) + pool: + name: MAUI-1ESPT + image: $(WindowsPoolImage1ESPT) + os: windows ${{ if eq(parameters.testOS, 'macOS') }}: pool: + name: Azure Pipelines vmImage: $(HostedMacImage) - timeoutInMinutes: 180 + os: macOS + timeoutInMinutes: 240 cancelTimeoutInMinutes: 5 steps: - ${{ if eq(parameters.testOS, 'Windows') }}: - script: netsh int ipv4 set global sourceroutingbehavior=drop - - template: kill-processes.yaml + - template: /build-tools/automation/yaml-templates/kill-processes.yaml@self - - template: clean.yaml + - template: /build-tools/automation/yaml-templates/clean.yaml@self - - template: setup-test-environment.yaml + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self parameters: installTestSlicer: true - installLegacyDotNet: false installLegacyXamarinAndroid: true - restoreNUnitConsole: false - updateMono: false xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} @@ -45,7 +47,7 @@ jobs: artifactName: $(TestAssembliesArtifactName) downloadPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) - - template: run-sliced-nunit-tests.yaml + - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml@self parameters: testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll testFilter: ${{ parameters.testFilter }} @@ -53,11 +55,11 @@ jobs: retryFailedTests: false xaSourcePath: ${{ parameters.xaSourcePath }} - - template: upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self parameters: artifactName: Test Results - MSBuild - ${{ parameters.testOS }}-$(System.JobPositionInPhase) xaSourcePath: ${{ parameters.xaSourcePath }} - - template: fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self parameters: condition: ${{ parameters.shouldFailOnIssue }} diff --git a/build-tools/automation/yaml-templates/run-nunit-tests.yaml b/build-tools/automation/yaml-templates/run-nunit-tests.yaml index 95d49d08506..709a503e477 100644 --- a/build-tools/automation/yaml-templates/run-nunit-tests.yaml +++ b/build-tools/automation/yaml-templates/run-nunit-tests.yaml @@ -1,71 +1,25 @@ parameters: - configuration: $(XA.Build.Configuration) - xaSourcePath: $(System.DefaultWorkingDirectory) testRunTitle: Xamarin Android Tests testAssembly: '' - testResultsFile: TestResult.xml - nunitConsoleExtraArgs: '' dotNetTestExtraArgs: '' - useDotNet: true - useDotNetPreview: false workers: $(NUnit.NumberOfTestWorkers) condition: succeeded() - timeoutInMinutes: 0 + timeoutInMinutes: 180 retryCountOnTaskFailure: 0 steps: -- ${{ if and(eq(parameters.useDotNet, false), eq(parameters.useDotNetPreview, false)) }}: - - powershell: | - Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit' - if ([Environment]::OSVersion.Platform -eq "Unix") { - & ${{ parameters.xaSourcePath }}/build-tools/scripts/nunit3-console ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }} - } else { - & cmd /c '${{ parameters.xaSourcePath }}\build-tools\scripts\nunit3-console.cmd' ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }} - } - if ($LASTEXITCODE -ne 0) { - Write-Host "##vso[task.logissue type=error]Test suite had $LASTEXITCODE failure(s)." - Write-Host "##vso[task.complete result=Failed;]" - exit 0 - } - displayName: run ${{ parameters.testRunTitle }} - condition: ${{ parameters.condition }} - continueOnError: true - -- ${{ if and(eq(parameters.useDotNet, true), eq(parameters.useDotNetPreview, true)) }}: - - powershell: Write-Host '##vso[task.setvariable variable=TestResultsFormat]VSTest' - - template: run-dotnet-preview.yaml - parameters: - configuration: ${{ parameters.configuration }} - xaSourcePath: ${{ parameters.xaSourcePath }} - command: test - project: ${{ parameters.testAssembly }} - useExitCodeForErrors: true - arguments: >- - --results-directory . --logger "trx;LogFileName=${{ parameters.testResultsFile }}" - ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }} - displayName: run ${{ parameters.testRunTitle }} - condition: ${{ parameters.condition }} - -- ${{ if and(eq(parameters.useDotNet, true), eq(parameters.useDotNetPreview, false)) }}: - - task: DotNetCoreCLI@2 - inputs: - command: test - projects: ${{ parameters.testAssembly }} - arguments: >- - ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }} - publishTestResults: true - testRunTitle: ${{ parameters.testRunTitle }} - displayName: run ${{ parameters.testRunTitle }} - condition: ${{ parameters.condition }} - continueOnError: true - timeoutInMinutes: ${{ parameters.timeoutInMinutes }} - retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }} - -- template: kill-processes.yaml - -- task: PublishTestResults@2 +- task: DotNetCoreCLI@2 inputs: - testResultsFormat: $(TestResultsFormat) - testResultsFiles: ${{ parameters.testResultsFile }} + command: test + projects: ${{ parameters.testAssembly }} + arguments: >- + ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }} + publishTestResults: true testRunTitle: ${{ parameters.testRunTitle }} - condition: and(${{ parameters.condition }}, or(ne('${{ parameters.useDotNet }}', 'true'), eq('${{ parameters.useDotNetPreview }}', 'true'))) + displayName: run ${{ parameters.testRunTitle }} + condition: ${{ parameters.condition }} + continueOnError: true + timeoutInMinutes: ${{ parameters.timeoutInMinutes }} + retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }} + +- template: /build-tools/automation/yaml-templates/kill-processes.yaml@self diff --git a/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml b/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml index 5e44373d5dd..b81af9b0943 100644 --- a/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml +++ b/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml @@ -8,7 +8,7 @@ parameters: steps: - ${{if parameters.testFilter}}: - pwsh: >- - dotnet-test-slicer slice + $(Agent.ToolsDirectory)/dotnet-test-slicer slice --test-assembly="${{ parameters.testAssembly }}" --test-filter="${{ parameters.testFilter }}" --slice-number=$(System.JobPositionInPhase) @@ -18,7 +18,7 @@ steps: failOnStderr: true - ${{ else }}: - pwsh: >- - dotnet-test-slicer slice + $(Agent.ToolsDirectory)/dotnet-test-slicer slice --test-assembly="${{ parameters.testAssembly }}" --slice-number=$(System.JobPositionInPhase) --total-slices=$(System.TotalJobsInPhase) @@ -28,7 +28,7 @@ steps: - ${{ if eq(parameters.retryFailedTests, 'false') }}: # If we aren't using auto-retry logic, then this is just a simple template call - - template: run-nunit-tests.yaml + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self parameters: testRunTitle: ${{ parameters.testRunTitle }}-$(System.JobPositionInPhase) testAssembly: ${{ parameters.testAssembly }} @@ -49,7 +49,7 @@ steps: workingDirectory: ${{ parameters.xaSourcePath }} - pwsh: | - dotnet-test-slicer ` + $(Agent.ToolsDirectory)/dotnet-test-slicer ` retry ` --trx="$(Agent.TempDirectory)" ` --outfile="${{ parameters.testAssembly }}.runsettings" @@ -70,7 +70,7 @@ steps: custom: build-server arguments: shutdown - - template: run-nunit-tests.yaml + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self parameters: testRunTitle: ${{ parameters.testRunTitle }}-$(System.JobPositionInPhase) (Auto-Retry) testAssembly: ${{ parameters.testAssembly }} diff --git a/build-tools/automation/yaml-templates/run-xaprepare.yaml b/build-tools/automation/yaml-templates/run-xaprepare.yaml index 1136cbec6e1..209aab8219d 100644 --- a/build-tools/automation/yaml-templates/run-xaprepare.yaml +++ b/build-tools/automation/yaml-templates/run-xaprepare.yaml @@ -3,7 +3,6 @@ parameters: name: configuration: $(XA.Build.Configuration) xaSourcePath: $(System.DefaultWorkingDirectory) - framework: $(DotNetStableTargetFramework) condition: succeeded() arguments: @@ -15,4 +14,4 @@ steps: inputs: command: run projects: ${{ parameters.xaSourcePath }}/build-tools/xaprepare/xaprepare/xaprepare.csproj - arguments: -f ${{ parameters.framework }} -c ${{ parameters.configuration }} -- ${{ parameters.arguments }} --no-emoji --run-mode=CI + arguments: -f $(DotNetStableTargetFramework) -c ${{ parameters.configuration }} -- ${{ parameters.arguments }} --no-emoji --run-mode=CI diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml index bcd91d29145..45901d9770a 100644 --- a/build-tools/automation/yaml-templates/setup-test-environment.yaml +++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml @@ -5,17 +5,15 @@ parameters: remove_dotnet: false installTestSlicer: false installApkDiff: true - installLegacyDotNet: true + installLegacyDotNet: false installLegacyXamarinAndroid: false - restoreNUnitConsole: true - updateMono: true + updateMono: false androidSdkPlatforms: $(DefaultTestSdkPlatforms) repositoryAlias: 'self' commit: '' xaprepareScenario: AndroidTestDependencies # Use 'EmulatorTestDependencies' for agents that need the emulator installed steps: - - template: sdk-unified/steps/checkout/v1.yml@yaml-templates parameters: resource: ${{ parameters.repositoryAlias }} @@ -37,14 +35,14 @@ steps: # Install .NET 6 for legacy tests - ${{ if eq(parameters.installLegacyDotNet, true) }}: - - template: use-dot-net.yaml + - template: /build-tools/automation/yaml-templates/use-dot-net.yaml@self parameters: version: 6.0 quality: GA remove_dotnet: ${{ parameters.remove_dotnet }} # Install latest .NET -- template: use-dot-net.yaml +- template: /build-tools/automation/yaml-templates/use-dot-net.yaml@self - task: DotNetCoreCLI@2 displayName: shut down existing build daemons @@ -54,7 +52,7 @@ steps: arguments: shutdown - ${{ if eq(parameters.updateMono, true) }}: - - template: run-xaprepare.yaml + - template: /build-tools/automation/yaml-templates/run-xaprepare.yaml@self parameters: displayName: run xaprepare-UpdateMono arguments: --s=UpdateMono --auto-provision=yes --auto-provision-uses-sudo=yes @@ -62,29 +60,19 @@ steps: xaSourcePath: ${{ parameters.xaSourcePath }} - ${{ if eq(parameters.installLegacyXamarinAndroid, true) }}: - - template: install-global-tool.yaml + - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml@self parameters: toolName: boots version: $(BootsToolVersion) continueOnError: false - - powershell: boots --stable Xamarin.Android + - pwsh: $(Agent.ToolsDirectory)/boots --stable Xamarin.Android displayName: install Xamarin.Android stable -- template: run-xaprepare.yaml +- template: /build-tools/automation/yaml-templates/run-xaprepare.yaml@self parameters: arguments: --s=${{ parameters.xaprepareScenario }} --android-sdk-platforms="${{ parameters.androidSdkPlatforms }}" xaSourcePath: ${{ parameters.xaSourcePath }} -- ${{ if eq(parameters.restoreNUnitConsole, true) }}: - - task: DotNetCoreCLI@2 - displayName: restore NUnit.Console - inputs: - command: restore - projects: ${{ parameters.xaSourcePath }}/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Xamarin.ProjectTools.csproj - restoreArguments: -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/restore-Xamarin.ProjectTools.binlog - nugetConfigPath: ${{ parameters.xaSourcePath }}/NuGet.config - feedsToUse: config - - task: DotNetCoreCLI@2 displayName: build Xamarin.Android.Tools.BootstrapTasks.csproj inputs: @@ -110,13 +98,13 @@ steps: arguments: -t:ExtractWorkloadPacks -c ${{ parameters.configuration }} -v:n -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/extract-workloads.binlog - ${{ if eq(parameters.installApkDiff, true) }}: - - template: install-global-tool.yaml + - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml@self parameters: toolName: apkdiff version: $(ApkDiffToolVersion) - ${{ if eq(parameters.installTestSlicer, true) }}: - - template: install-global-tool.yaml + - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml@self parameters: toolName: dotnet-test-slicer version: $(TestSlicerToolVersion) diff --git a/build-tools/automation/yaml-templates/setup-ubuntu.yaml b/build-tools/automation/yaml-templates/setup-ubuntu.yaml deleted file mode 100644 index 4dd8d7062b5..00000000000 --- a/build-tools/automation/yaml-templates/setup-ubuntu.yaml +++ /dev/null @@ -1,23 +0,0 @@ -steps: - -- script: sudo rm /etc/apt/sources.list.d/treasure-data.list || true - displayName: remove invalid treasure-data source - -- script: echo "##vso[task.setvariable variable=XDG_CONFIG_HOME]$HOME/.config" - displayName: update XDG_CONFIG_HOME - -- script: > - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && - echo "deb https://download.mono-project.com/repo/ubuntu preview-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-preview.list && - sudo apt update && - sudo apt install -y --no-install-recommends mono-complete nuget msbuild - displayName: install mono preview - -- template: use-dot-net.yaml - parameters: - remove_dotnet: true - -- task: NuGetToolInstaller@1 - displayName: Use NuGet 5.x - inputs: - versionSpec: 5.x diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index 4ad16662861..924d727d285 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -25,19 +25,19 @@ stages: parallel: ${{ parameters.agent_count }} displayName: "macOS > Tests > MSBuild+Emulator" pool: + name: Azure Pipelines vmImage: $(HostedMacImage) + os: macOS timeoutInMinutes: 180 cancelTimeoutInMinutes: 5 workspace: clean: all steps: - - template: setup-test-environment.yaml + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self parameters: installTestSlicer: true installApkDiff: false - installLegacyDotNet: false installLegacyXamarinAndroid: true - restoreNUnitConsole: false updateMono: true xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} @@ -49,29 +49,29 @@ stages: artifactName: $(TestAssembliesArtifactName) downloadPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) - - template: start-stop-emulator.yaml + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self parameters: xaSourcePath: ${{ parameters.xaSourcePath }} startContinueOnError: ${{ parameters.emulatorStartContinueOnError }} - - template: run-sliced-nunit-tests.yaml + - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml@self parameters: testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll testFilter: $(ExcludedNightlyNUnitCategories) testRunTitle: MSBuildDeviceIntegration On Device - macOS - ${{ if ne(parameters.usesCleanImages, true) }}: - - template: start-stop-emulator.yaml + - template: start-stop-emulator.yaml@self parameters: command: stop xaSourcePath: ${{ parameters.xaSourcePath }} - - template: upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self parameters: artifactName: Test Results - MSBuild With Emulator - macOS-$(System.JobPositionInPhase) xaSourcePath: ${{ parameters.xaSourcePath }} - - template: fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self parameters: condition: ${{ parameters.shouldFailOnIssue }} @@ -88,17 +88,16 @@ stages: deviceName: wear_square androidSdkPlatforms: 34 pool: + name: Azure Pipelines vmImage: $(HostedMacImage) + os: macOS workspace: clean: all steps: - - template: setup-test-environment.yaml + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self parameters: installTestSlicer: true installApkDiff: false - installLegacyDotNet: false - restoreNUnitConsole: false - updateMono: false xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} @@ -109,7 +108,7 @@ stages: artifactName: $(TestAssembliesArtifactName) downloadPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) - - template: start-stop-emulator.yaml + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self parameters: specificImage: true deviceName: $(deviceName) @@ -119,7 +118,7 @@ stages: xaSourcePath: ${{ parameters.xaSourcePath }} startContinueOnError: ${{ parameters.emulatorStartContinueOnError }} - - template: run-sliced-nunit-tests.yaml + - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml@self parameters: testRunTitle: WearOS On Device - macOS testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll @@ -127,7 +126,7 @@ stages: xaSourcePath: ${{ parameters.xaSourcePath }} - ${{ if ne(parameters.usesCleanImages, true) }}: - - template: start-stop-emulator.yaml + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self parameters: command: stop specificImage: true @@ -137,12 +136,12 @@ stages: avdType: $(avdType) xaSourcePath: ${{ parameters.xaSourcePath }} - - template: upload-results.yaml + - template: /build-tools/automation/yaml-templates/upload-results.yaml@self parameters: configuration: $(XA.Build.Configuration) artifactName: Test Results - Emulator $(avdApiLevel)-$(avdAbi)-$(avdType) - macOS xaSourcePath: ${{ parameters.xaSourcePath }} - - template: fail-on-issue.yaml + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self parameters: condition: ${{ parameters.shouldFailOnIssue }} diff --git a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml index 9b4745c543c..a9eff7fb75a 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml @@ -16,7 +16,7 @@ stages: dependsOn: ${{ parameters.dependsOn }} condition: ${{ parameters.stageCondition }} jobs: - - template: run-msbuild-tests.yaml + - template: /build-tools/automation/yaml-templates/run-msbuild-tests.yaml@self parameters: testOS: macOS jobName: mac_msbuild_tests @@ -27,7 +27,7 @@ stages: commit: ${{ parameters.commit }} shouldFailOnIssue: ${{ parameters.shouldFailOnIssue }} - - template: run-msbuild-tests.yaml + - template: /build-tools/automation/yaml-templates/run-msbuild-tests.yaml@self parameters: testOS: Windows jobName: win_msbuild_tests diff --git a/build-tools/automation/yaml-templates/upload-results.yaml b/build-tools/automation/yaml-templates/upload-results.yaml index ed782a58d4d..40ce61a07cd 100644 --- a/build-tools/automation/yaml-templates/upload-results.yaml +++ b/build-tools/automation/yaml-templates/upload-results.yaml @@ -4,9 +4,10 @@ parameters: artifactName: results includeBuildResults: false condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true')) + use1ESTemplate: true steps: -- template: run-xaprepare.yaml +- template: /build-tools/automation/yaml-templates/run-xaprepare.yaml@self parameters: configuration: ${{ parameters.configuration }} arguments: --s=CopyExtraResultFilesForCI --verbosity v @@ -15,12 +16,13 @@ steps: condition: ${{ parameters.condition }} - ${{ if eq(parameters.includeBuildResults, false) }}: - - template: publish-artifact.yaml + - template: /build-tools/automation/yaml-templates/publish-artifact.yaml@self parameters: displayName: upload test results artifactName: ${{ parameters.artifactName }} targetPath: $(Build.StagingDirectory)/Test${{ parameters.configuration }} condition: ${{ parameters.condition }} + use1ESTemplate: ${{ parameters.use1ESTemplate }} # Copy Build$(Configuration) folder into test result root and upload single artifact - ${{ if eq(parameters.includeBuildResults, true) }}: @@ -30,9 +32,10 @@ steps: targetFolder: $(Build.StagingDirectory)/Test${{ parameters.configuration }}/Build${{ parameters.configuration }} condition: ${{ parameters.condition }} - - template: publish-artifact.yaml + - template: /build-tools/automation/yaml-templates/publish-artifact.yaml@self parameters: displayName: upload build and test results artifactName: ${{ parameters.artifactName }} targetPath: $(Build.StagingDirectory)/Test${{ parameters.configuration }} condition: ${{ parameters.condition }} + use1ESTemplate: ${{ parameters.use1ESTemplate }} diff --git a/build-tools/automation/yaml-templates/use-dot-net.yaml b/build-tools/automation/yaml-templates/use-dot-net.yaml index 41fdfad874a..7480ddc8176 100644 --- a/build-tools/automation/yaml-templates/use-dot-net.yaml +++ b/build-tools/automation/yaml-templates/use-dot-net.yaml @@ -8,7 +8,6 @@ parameters: retryCountOnTaskFailure: 3 steps: - - pwsh: | $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' diff --git a/build-tools/automation/yaml-templates/variables.yaml b/build-tools/automation/yaml-templates/variables.yaml index 13a1f774a18..e9398268781 100644 --- a/build-tools/automation/yaml-templates/variables.yaml +++ b/build-tools/automation/yaml-templates/variables.yaml @@ -33,8 +33,10 @@ variables: value: macOS-13 - name: HostedWinImage value: windows-2022 -- name: 1ESWindowsPool - value: android-win-2022 +- name: WindowsPoolImage1ESPT + value: 1ESPT-Windows2022 +- name: LinuxPoolImage1ESPT + value: 1ESPT-Ubuntu22.04 - name: VSEngMicroBuildPool value: VSEngSS-MicroBuild2022-1ES - name: TeamName diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs index 8a909c4b752..440c5656f73 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs @@ -108,10 +108,16 @@ protected static (int code, string stdOutput, string stdError) RunApkDiffCommand try { return RunProcessWithExitCode ("apkdiff" + ext, args); } catch (System.ComponentModel.Win32Exception) { - // apkdiff's location might not be in the $PATH, try known location + // apkdiff's location might not be in the $PATH, try known locations var profileDir = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile); - - return RunProcessWithExitCode (Path.Combine (profileDir, ".dotnet", "tools", "apkdiff" + ext), args); + var apkdiffPath = Path.Combine (profileDir, ".dotnet", "tools", "apkdiff" + ext); + if (!File.Exists (apkdiffPath)) { + var agentToolsDir = Environment.GetEnvironmentVariable ("AGENT_TOOLSDIRECTORY"); + if (Directory.Exists (agentToolsDir)) { + apkdiffPath = Path.Combine (agentToolsDir, "apkdiff" + ext); + } + } + return RunProcessWithExitCode (apkdiffPath, args); } } From 5cd9a267e20a19d796d521d67867a00fd67328ba Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 4 Mar 2024 11:28:24 -0800 Subject: [PATCH 3/6] [ci] Do not use @self annotation for templates (#8783) The `@self` yaml template annotation only appears to be needed in the pipeline file, and not in nested templates. This should fix potential issues with other repos that use these templates. --- .../yaml-templates/apk-instrumentation.yaml | 2 +- .../yaml-templates/build-linux.yaml | 4 ++-- .../yaml-templates/build-macos.yaml | 4 ++-- .../yaml-templates/build-windows.yaml | 16 ++++++------- .../yaml-templates/commercial-build.yaml | 6 ++--- .../yaml-templates/run-emulator-tests.yaml | 8 +++---- .../yaml-templates/run-msbuild-tests.yaml | 12 +++++----- .../yaml-templates/run-nunit-tests.yaml | 2 +- .../run-sliced-nunit-tests.yaml | 4 ++-- .../setup-test-environment.yaml | 14 +++++------ .../stage-msbuild-emulator-tests.yaml | 24 +++++++++---------- .../yaml-templates/stage-msbuild-tests.yaml | 4 ++-- .../yaml-templates/upload-results.yaml | 6 ++--- 13 files changed, 53 insertions(+), 53 deletions(-) diff --git a/build-tools/automation/yaml-templates/apk-instrumentation.yaml b/build-tools/automation/yaml-templates/apk-instrumentation.yaml index 0eac8e12dd8..b0958a7017a 100644 --- a/build-tools/automation/yaml-templates/apk-instrumentation.yaml +++ b/build-tools/automation/yaml-templates/apk-instrumentation.yaml @@ -13,7 +13,7 @@ parameters: retryCountOnTaskFailure: 1 steps: -- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self +- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml parameters: configuration: ${{ parameters.buildConfiguration }} xaSourcePath: ${{ parameters.xaSourcePath }} diff --git a/build-tools/automation/yaml-templates/build-linux.yaml b/build-tools/automation/yaml-templates/build-linux.yaml index 673270ca735..f34a25ba776 100644 --- a/build-tools/automation/yaml-templates/build-linux.yaml +++ b/build-tools/automation/yaml-templates/build-linux.yaml @@ -97,11 +97,11 @@ stages: artifactName: ${{ parameters.nugetArtifactName }} targetPath: $(System.DefaultWorkingDirectory)/xamarin-android/bin/Build$(XA.Build.Configuration)/nuget-linux - - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android artifactName: ${{ parameters.buildResultArtifactName }} includeBuildResults: true use1ESTemplate: ${{ parameters.use1ESTemplate }} - - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml diff --git a/build-tools/automation/yaml-templates/build-macos.yaml b/build-tools/automation/yaml-templates/build-macos.yaml index 2d12c21573a..804379f39dc 100644 --- a/build-tools/automation/yaml-templates/build-macos.yaml +++ b/build-tools/automation/yaml-templates/build-macos.yaml @@ -69,7 +69,7 @@ stages: path: ${{ parameters.checkoutPath }} persistCredentials: ${{ parameters.checkoutPersistCredentials }} - - template: /build-tools/automation/yaml-templates/commercial-build.yaml@self + - template: /build-tools/automation/yaml-templates/commercial-build.yaml parameters: xaSourcePath: ${{ parameters.xaSourcePath }} installerArtifactName: ${{ parameters.installerArtifactName }} @@ -78,7 +78,7 @@ stages: windowsToolchainPdbArtifactName: ${{ parameters.windowsToolchainPdbArtifactName }} use1ESTemplate: ${{ parameters.use1ESTemplate }} - - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: xaSourcePath: ${{ parameters.xaSourcePath }} artifactName: ${{ parameters.buildResultArtifactName }} diff --git a/build-tools/automation/yaml-templates/build-windows.yaml b/build-tools/automation/yaml-templates/build-windows.yaml index e3867113a22..067c9d0a4a0 100644 --- a/build-tools/automation/yaml-templates/build-windows.yaml +++ b/build-tools/automation/yaml-templates/build-windows.yaml @@ -35,15 +35,15 @@ stages: path: ${{ parameters.checkoutPath }} persistCredentials: ${{ parameters.checkoutPersistCredentials }} - - template: /build-tools/automation/yaml-templates/kill-processes.yaml@self + - template: /build-tools/automation/yaml-templates/kill-processes.yaml - - template: /build-tools/automation/yaml-templates/clean.yaml@self + - template: /build-tools/automation/yaml-templates/clean.yaml - script: | echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_17_X64% displayName: set JI_JAVA_HOME to $(JAVA_HOME_17_X64) - - template: /build-tools/automation/yaml-templates/use-dot-net.yaml@self + - template: /build-tools/automation/yaml-templates/use-dot-net.yaml parameters: remove_dotnet: true @@ -54,7 +54,7 @@ stages: arguments: '-c $(XA.Build.Configuration) -t:Prepare --no-restore -p:AutoProvision=true -bl:$(System.DefaultWorkingDirectory)\bin\Build$(XA.Build.Configuration)\dotnet-build-prepare.binlog' # Build, pack .nupkgs, and extract workload packs to dotnet preview test directory - - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml@self + - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml parameters: project: Xamarin.Android.sln arguments: >- @@ -63,12 +63,12 @@ stages: displayName: Build Solution continueOnError: false - - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml@self + - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml parameters: toolName: apkdiff version: $(ApkDiffToolVersion) - - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml parameters: testRunTitle: Smoke MSBuild Tests - Windows Dotnet Build testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\$(DotNetStableTargetFramework)\Xamarin.Android.Build.Tests.dll @@ -80,9 +80,9 @@ stages: filename: dotnet-local.cmd arguments: build samples\HelloWorld\HelloWorld\HelloWorld.DotNet.csproj - - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: artifactName: ${{ parameters.buildResultArtifactName }} includeBuildResults: true - - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml diff --git a/build-tools/automation/yaml-templates/commercial-build.yaml b/build-tools/automation/yaml-templates/commercial-build.yaml index 7024dbd6dc5..7a665ea1501 100644 --- a/build-tools/automation/yaml-templates/commercial-build.yaml +++ b/build-tools/automation/yaml-templates/commercial-build.yaml @@ -11,7 +11,7 @@ steps: - script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/android-toolchain/jdk-17" displayName: set JI_JAVA_HOME -- template: /build-tools/automation/yaml-templates/use-dot-net.yaml@self +- template: /build-tools/automation/yaml-templates/use-dot-net.yaml parameters: remove_dotnet: true @@ -66,7 +66,7 @@ steps: displayName: CodeQL 3000 Finalize condition: and(succeededOrFailed(), eq(variables['Codeql.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) -- template: /build-tools/automation/yaml-templates/install-microbuild-tooling.yaml@self +- template: /build-tools/automation/yaml-templates/install-microbuild-tooling.yaml parameters: condition: and(succeeded(), eq(variables['MicroBuildSignType'], 'Real')) @@ -115,7 +115,7 @@ steps: /p:MicroBuildOverridePluginDirectory=$(Build.StagingDirectory)/MicroBuild/Plugins /bl:${{ parameters.xaSourcePath }}/bin/Build$(XA.Build.Configuration)/sign-bu-ex.binlog -- template: /build-tools/automation/yaml-templates/remove-microbuild-tooling.yaml@self +- template: /build-tools/automation/yaml-templates/remove-microbuild-tooling.yaml parameters: condition: and(succeededOrFailed(), eq(variables['MicroBuildSignType'], 'Real')) diff --git a/build-tools/automation/yaml-templates/run-emulator-tests.yaml b/build-tools/automation/yaml-templates/run-emulator-tests.yaml index bbf7e212943..e3bac786ce3 100644 --- a/build-tools/automation/yaml-templates/run-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/run-emulator-tests.yaml @@ -26,7 +26,7 @@ jobs: echo "##vso[task.setvariable variable=JAVA_HOME]${{ parameters.jdkTestFolder }}" displayName: set JAVA_HOME to ${{ parameters.jdkTestFolder }} - - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: xaprepareScenario: EmulatorTestDependencies jdkTestFolder: ${{ parameters.jdkTestFolder }} @@ -36,15 +36,15 @@ jobs: artifactName: $(TestAssembliesArtifactName) downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) - - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml parameters: emulatorMSBuildArgs: ${{ parameters.emulatorMSBuildArgs }} - ${{ parameters.testSteps }} - - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: artifactName: Test Results - ${{ parameters.jobName }} With Emulator - macOS use1ESTemplate: ${{ parameters.use1ESTemplate }} - - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml diff --git a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml index 62be739a9a9..36b50567342 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml @@ -30,11 +30,11 @@ jobs: - ${{ if eq(parameters.testOS, 'Windows') }}: - script: netsh int ipv4 set global sourceroutingbehavior=drop - - template: /build-tools/automation/yaml-templates/kill-processes.yaml@self + - template: /build-tools/automation/yaml-templates/kill-processes.yaml - - template: /build-tools/automation/yaml-templates/clean.yaml@self + - template: /build-tools/automation/yaml-templates/clean.yaml - - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: installTestSlicer: true installLegacyXamarinAndroid: true @@ -47,7 +47,7 @@ jobs: artifactName: $(TestAssembliesArtifactName) downloadPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) - - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml@self + - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml parameters: testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/$(DotNetStableTargetFramework)/Xamarin.Android.Build.Tests.dll testFilter: ${{ parameters.testFilter }} @@ -55,11 +55,11 @@ jobs: retryFailedTests: false xaSourcePath: ${{ parameters.xaSourcePath }} - - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: artifactName: Test Results - MSBuild - ${{ parameters.testOS }}-$(System.JobPositionInPhase) xaSourcePath: ${{ parameters.xaSourcePath }} - - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml parameters: condition: ${{ parameters.shouldFailOnIssue }} diff --git a/build-tools/automation/yaml-templates/run-nunit-tests.yaml b/build-tools/automation/yaml-templates/run-nunit-tests.yaml index 709a503e477..790abf3b7b2 100644 --- a/build-tools/automation/yaml-templates/run-nunit-tests.yaml +++ b/build-tools/automation/yaml-templates/run-nunit-tests.yaml @@ -22,4 +22,4 @@ steps: timeoutInMinutes: ${{ parameters.timeoutInMinutes }} retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }} -- template: /build-tools/automation/yaml-templates/kill-processes.yaml@self +- template: /build-tools/automation/yaml-templates/kill-processes.yaml diff --git a/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml b/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml index b81af9b0943..74313603502 100644 --- a/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml +++ b/build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml @@ -28,7 +28,7 @@ steps: - ${{ if eq(parameters.retryFailedTests, 'false') }}: # If we aren't using auto-retry logic, then this is just a simple template call - - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml parameters: testRunTitle: ${{ parameters.testRunTitle }}-$(System.JobPositionInPhase) testAssembly: ${{ parameters.testAssembly }} @@ -70,7 +70,7 @@ steps: custom: build-server arguments: shutdown - - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml@self + - template: /build-tools/automation/yaml-templates/run-nunit-tests.yaml parameters: testRunTitle: ${{ parameters.testRunTitle }}-$(System.JobPositionInPhase) (Auto-Retry) testAssembly: ${{ parameters.testAssembly }} diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml index 45901d9770a..1d774bb7c04 100644 --- a/build-tools/automation/yaml-templates/setup-test-environment.yaml +++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml @@ -35,14 +35,14 @@ steps: # Install .NET 6 for legacy tests - ${{ if eq(parameters.installLegacyDotNet, true) }}: - - template: /build-tools/automation/yaml-templates/use-dot-net.yaml@self + - template: /build-tools/automation/yaml-templates/use-dot-net.yaml parameters: version: 6.0 quality: GA remove_dotnet: ${{ parameters.remove_dotnet }} # Install latest .NET -- template: /build-tools/automation/yaml-templates/use-dot-net.yaml@self +- template: /build-tools/automation/yaml-templates/use-dot-net.yaml - task: DotNetCoreCLI@2 displayName: shut down existing build daemons @@ -52,7 +52,7 @@ steps: arguments: shutdown - ${{ if eq(parameters.updateMono, true) }}: - - template: /build-tools/automation/yaml-templates/run-xaprepare.yaml@self + - template: /build-tools/automation/yaml-templates/run-xaprepare.yaml parameters: displayName: run xaprepare-UpdateMono arguments: --s=UpdateMono --auto-provision=yes --auto-provision-uses-sudo=yes @@ -60,7 +60,7 @@ steps: xaSourcePath: ${{ parameters.xaSourcePath }} - ${{ if eq(parameters.installLegacyXamarinAndroid, true) }}: - - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml@self + - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml parameters: toolName: boots version: $(BootsToolVersion) @@ -68,7 +68,7 @@ steps: - pwsh: $(Agent.ToolsDirectory)/boots --stable Xamarin.Android displayName: install Xamarin.Android stable -- template: /build-tools/automation/yaml-templates/run-xaprepare.yaml@self +- template: /build-tools/automation/yaml-templates/run-xaprepare.yaml parameters: arguments: --s=${{ parameters.xaprepareScenario }} --android-sdk-platforms="${{ parameters.androidSdkPlatforms }}" xaSourcePath: ${{ parameters.xaSourcePath }} @@ -98,13 +98,13 @@ steps: arguments: -t:ExtractWorkloadPacks -c ${{ parameters.configuration }} -v:n -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/extract-workloads.binlog - ${{ if eq(parameters.installApkDiff, true) }}: - - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml@self + - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml parameters: toolName: apkdiff version: $(ApkDiffToolVersion) - ${{ if eq(parameters.installTestSlicer, true) }}: - - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml@self + - template: /build-tools/automation/yaml-templates/install-dotnet-tool.yaml parameters: toolName: dotnet-test-slicer version: $(TestSlicerToolVersion) diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index 924d727d285..4c38e2fa90e 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -33,7 +33,7 @@ stages: workspace: clean: all steps: - - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: installTestSlicer: true installApkDiff: false @@ -49,29 +49,29 @@ stages: artifactName: $(TestAssembliesArtifactName) downloadPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) - - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml parameters: xaSourcePath: ${{ parameters.xaSourcePath }} startContinueOnError: ${{ parameters.emulatorStartContinueOnError }} - - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml@self + - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml parameters: testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll testFilter: $(ExcludedNightlyNUnitCategories) testRunTitle: MSBuildDeviceIntegration On Device - macOS - ${{ if ne(parameters.usesCleanImages, true) }}: - - template: start-stop-emulator.yaml@self + - template: start-stop-emulator.yaml parameters: command: stop xaSourcePath: ${{ parameters.xaSourcePath }} - - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: artifactName: Test Results - MSBuild With Emulator - macOS-$(System.JobPositionInPhase) xaSourcePath: ${{ parameters.xaSourcePath }} - - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml parameters: condition: ${{ parameters.shouldFailOnIssue }} @@ -94,7 +94,7 @@ stages: workspace: clean: all steps: - - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml@self + - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: installTestSlicer: true installApkDiff: false @@ -108,7 +108,7 @@ stages: artifactName: $(TestAssembliesArtifactName) downloadPath: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration) - - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml parameters: specificImage: true deviceName: $(deviceName) @@ -118,7 +118,7 @@ stages: xaSourcePath: ${{ parameters.xaSourcePath }} startContinueOnError: ${{ parameters.emulatorStartContinueOnError }} - - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml@self + - template: /build-tools/automation/yaml-templates/run-sliced-nunit-tests.yaml parameters: testRunTitle: WearOS On Device - macOS testAssembly: ${{ parameters.xaSourcePath }}/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/$(DotNetStableTargetFramework)/MSBuildDeviceIntegration.dll @@ -126,7 +126,7 @@ stages: xaSourcePath: ${{ parameters.xaSourcePath }} - ${{ if ne(parameters.usesCleanImages, true) }}: - - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml@self + - template: /build-tools/automation/yaml-templates/start-stop-emulator.yaml parameters: command: stop specificImage: true @@ -136,12 +136,12 @@ stages: avdType: $(avdType) xaSourcePath: ${{ parameters.xaSourcePath }} - - template: /build-tools/automation/yaml-templates/upload-results.yaml@self + - template: /build-tools/automation/yaml-templates/upload-results.yaml parameters: configuration: $(XA.Build.Configuration) artifactName: Test Results - Emulator $(avdApiLevel)-$(avdAbi)-$(avdType) - macOS xaSourcePath: ${{ parameters.xaSourcePath }} - - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml@self + - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml parameters: condition: ${{ parameters.shouldFailOnIssue }} diff --git a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml index a9eff7fb75a..66da295516c 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml @@ -16,7 +16,7 @@ stages: dependsOn: ${{ parameters.dependsOn }} condition: ${{ parameters.stageCondition }} jobs: - - template: /build-tools/automation/yaml-templates/run-msbuild-tests.yaml@self + - template: /build-tools/automation/yaml-templates/run-msbuild-tests.yaml parameters: testOS: macOS jobName: mac_msbuild_tests @@ -27,7 +27,7 @@ stages: commit: ${{ parameters.commit }} shouldFailOnIssue: ${{ parameters.shouldFailOnIssue }} - - template: /build-tools/automation/yaml-templates/run-msbuild-tests.yaml@self + - template: /build-tools/automation/yaml-templates/run-msbuild-tests.yaml parameters: testOS: Windows jobName: win_msbuild_tests diff --git a/build-tools/automation/yaml-templates/upload-results.yaml b/build-tools/automation/yaml-templates/upload-results.yaml index 40ce61a07cd..24ebe8007d6 100644 --- a/build-tools/automation/yaml-templates/upload-results.yaml +++ b/build-tools/automation/yaml-templates/upload-results.yaml @@ -7,7 +7,7 @@ parameters: use1ESTemplate: true steps: -- template: /build-tools/automation/yaml-templates/run-xaprepare.yaml@self +- template: /build-tools/automation/yaml-templates/run-xaprepare.yaml parameters: configuration: ${{ parameters.configuration }} arguments: --s=CopyExtraResultFilesForCI --verbosity v @@ -16,7 +16,7 @@ steps: condition: ${{ parameters.condition }} - ${{ if eq(parameters.includeBuildResults, false) }}: - - template: /build-tools/automation/yaml-templates/publish-artifact.yaml@self + - template: /build-tools/automation/yaml-templates/publish-artifact.yaml parameters: displayName: upload test results artifactName: ${{ parameters.artifactName }} @@ -32,7 +32,7 @@ steps: targetFolder: $(Build.StagingDirectory)/Test${{ parameters.configuration }}/Build${{ parameters.configuration }} condition: ${{ parameters.condition }} - - template: /build-tools/automation/yaml-templates/publish-artifact.yaml@self + - template: /build-tools/automation/yaml-templates/publish-artifact.yaml parameters: displayName: upload build and test results artifactName: ${{ parameters.artifactName }} From db49513040199ae673131990844ad893ddca8ce2 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 4 Mar 2024 12:54:06 -0800 Subject: [PATCH 4/6] [ci] Add 1ESPT override to MSBuild test stages (#8784) The mega pipeline extends our msbuild stages and does not yet support using the 1ES pipeline template. --- build-tools/automation/yaml-templates/run-msbuild-tests.yaml | 2 ++ .../yaml-templates/stage-msbuild-emulator-tests.yaml | 3 +++ build-tools/automation/yaml-templates/stage-msbuild-tests.yaml | 3 +++ 3 files changed, 8 insertions(+) diff --git a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml index 36b50567342..e0f2f6be19e 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml @@ -8,6 +8,7 @@ parameters: repositoryAlias: 'self' commit: '' shouldFailOnIssue: true + use1ESTemplate: true jobs: - job: ${{ parameters.jobName }} @@ -59,6 +60,7 @@ jobs: parameters: artifactName: Test Results - MSBuild - ${{ parameters.testOS }}-$(System.JobPositionInPhase) xaSourcePath: ${{ parameters.xaSourcePath }} + use1ESTemplate: ${{ parameters.use1ESTemplate }} - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml parameters: diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index 4c38e2fa90e..fa8296d7771 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -13,6 +13,7 @@ parameters: usesCleanImages: true shouldFailOnIssue: true emulatorStartContinueOnError: false + use1ESTemplate: true stages: - stage: ${{ parameters.stageName }} @@ -70,6 +71,7 @@ stages: parameters: artifactName: Test Results - MSBuild With Emulator - macOS-$(System.JobPositionInPhase) xaSourcePath: ${{ parameters.xaSourcePath }} + use1ESTemplate: ${{ parameters.use1ESTemplate }} - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml parameters: @@ -141,6 +143,7 @@ stages: configuration: $(XA.Build.Configuration) artifactName: Test Results - Emulator $(avdApiLevel)-$(avdAbi)-$(avdType) - macOS xaSourcePath: ${{ parameters.xaSourcePath }} + use1ESTemplate: ${{ parameters.use1ESTemplate }} - template: /build-tools/automation/yaml-templates/fail-on-issue.yaml parameters: diff --git a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml index 66da295516c..d20e1549812 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml @@ -9,6 +9,7 @@ parameters: repositoryAlias: 'self' commit: '' shouldFailOnIssue: true + use1ESTemplate: true stages: - stage: ${{ parameters.stageName }} @@ -26,6 +27,7 @@ stages: repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} shouldFailOnIssue: ${{ parameters.shouldFailOnIssue }} + use1ESTemplate: ${{ parameters.use1ESTemplate }} - template: /build-tools/automation/yaml-templates/run-msbuild-tests.yaml parameters: @@ -37,3 +39,4 @@ stages: repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} shouldFailOnIssue: ${{ parameters.shouldFailOnIssue }} + use1ESTemplate: ${{ parameters.use1ESTemplate }} From aea89e161fb49fe921d9c601abb44360c653787d Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 4 Mar 2024 14:08:43 -0800 Subject: [PATCH 5/6] [ci] Fix SDL Sources Analysis for PRs from forks (#8785) The recent 1ES pipeline template migration added a new source code analysis stage that is failing on PR builds from forks. We should be able to fix this by skipping AzDO build tagging and monodroid scanning for such builds. --- build-tools/automation/azure-pipelines.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index b54da059e77..4cedf139685 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -87,12 +87,15 @@ extends: os: windows sourceRepositoriesToScan: include: - - repository: monodroid + - ${{ if ne(variables['System.PullRequest.IsFork'], 'True') }}: + - repository: monodroid exclude: - repository: yaml-templates - repository: maui suppression: suppressionFile: $(Build.SourcesDirectory)\.gdn\.gdnsuppress + settings: + skipBuildTagsForGitHubPullRequests: true stages: - template: /build-tools/automation/yaml-templates/build-macos.yaml@self From e41a31b9520dd1a4dbfe8162cf49fed7052dc69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Rozs=C3=ADval?= Date: Tue, 5 Mar 2024 14:07:01 +0100 Subject: [PATCH 6/6] [Mono.Android] Fix race condition in AndroidMessageHandler (#8753) Fixes: https://github.com/xamarin/xamarin-android/issues/8740 There is a race condition in `AndroidMessageHandler` (see https://github.com/xamarin/xamarin-android/issues/8740#issuecomment-1960331579 for more information). The solution is fairly simple: we should determine the decompression strategy only during the setup, when `AutomaticDecompression` is set. We don't need to do any more work during the request. To prevent changing the decompression strategy while there are requests mid-flight, the setter will only accept values until the first request is sent. This is exactly what the `SocketsHttpHandler` does. I didn't want to touch any code unrelated to the race condition in this PR so if we want to prevent other properties from being mutated while HTTP requests are being sent, we should do it in a follow-up PR. --- .../AndroidMessageHandler.cs | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs b/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs index 26645e6fdcb..e5218687ae7 100644 --- a/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs +++ b/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs @@ -138,12 +138,14 @@ public void Reset () DecompressionMethods _decompressionMethods; bool disposed; + bool started; // Now all hail Java developers! Get this... HttpURLClient defaults to accepting AND // uncompressing the gzip content encoding UNLESS you set the Accept-Encoding header to ANY // value. So if we set it to 'gzip' below we WILL get gzipped stream but HttpURLClient will NOT // uncompress it any longer, doh. And they don't support 'deflate' so we need to handle it ourselves. - bool decompress_here; + bool decompress_here => _acceptEncoding is not null && _acceptEncoding != IDENTITY_ENCODING; + string? _acceptEncoding; public bool SupportsAutomaticDecompression => true; public bool SupportsProxy => true; @@ -152,7 +154,29 @@ public void Reset () public DecompressionMethods AutomaticDecompression { get => _decompressionMethods; - set => _decompressionMethods = value; + set + { + CheckDisposedOrStarted (); + + _decompressionMethods = value; + _acceptEncoding = null; + + if (value == DecompressionMethods.None) { + _acceptEncoding = IDENTITY_ENCODING; + } else { + if ((value & DecompressionMethods.GZip) != 0) { + _acceptEncoding = GZIP_ENCODING; + } + + if ((value & DecompressionMethods.Deflate) != 0) { + _acceptEncoding = _acceptEncoding is null ? DEFLATE_ENCODING : $"{_acceptEncoding}, {DEFLATE_ENCODING}"; + } + + if ((value & DecompressionMethods.Brotli) != 0) { + _acceptEncoding = _acceptEncoding is null ? BROTLI_ENCODING : $"{_acceptEncoding}, {BROTLI_ENCODING}"; + } + } + } } public CookieContainer CookieContainer @@ -334,7 +358,7 @@ public bool RequestNeedsAuthorization { protected override void Dispose (bool disposing) { - disposed = true; + disposed = true; base.Dispose (disposing); } @@ -346,6 +370,14 @@ protected void AssertSelf () throw new ObjectDisposedException (nameof (AndroidMessageHandler)); } + void CheckDisposedOrStarted () + { + AssertSelf (); + if (started) { + throw new InvalidOperationException ("The handler has already started sending requests"); + } + } + string EncodeUrl (Uri url) { if (url == null) @@ -407,6 +439,7 @@ string EncodeUrl (Uri url) internal async Task DoSendAsync (HttpRequestMessage request, CancellationToken cancellationToken) { + started = true; AssertSelf (); if (request == null) throw new ArgumentNullException (nameof (request)); @@ -1050,15 +1083,6 @@ internal Task SetupRequestInternal (HttpRequestMessage request, HttpURLConnectio internal TrustManagerFactory? ConfigureTrustManagerFactoryInternal (KeyStore? keyStore) => ConfigureTrustManagerFactory (keyStore); - void AppendEncoding (string encoding, ref List ? list) - { - if (list == null) - list = new List (); - if (list.Contains (encoding)) - return; - list.Add (encoding); - } - async Task SetupRequestInternal (HttpRequestMessage request, URLConnection conn) { if (conn == null) @@ -1080,30 +1104,8 @@ void AppendEncoding (string encoding, ref List ? list) AddHeaders (httpConnection, request.Content.Headers); AddHeaders (httpConnection, request.Headers); - List ? accept_encoding = null; - - decompress_here = false; - if (AutomaticDecompression == DecompressionMethods.None) { - AppendEncoding (IDENTITY_ENCODING, ref accept_encoding); // Turns off compression for the Java client - } else { - if ((AutomaticDecompression & DecompressionMethods.GZip) != 0) { - AppendEncoding (GZIP_ENCODING, ref accept_encoding); - decompress_here = true; - } - - if ((AutomaticDecompression & DecompressionMethods.Deflate) != 0) { - AppendEncoding (DEFLATE_ENCODING, ref accept_encoding); - decompress_here = true; - } - - if ((AutomaticDecompression & DecompressionMethods.Brotli) != 0) { - AppendEncoding (BROTLI_ENCODING, ref accept_encoding); - decompress_here = true; - } - } - - if (accept_encoding?.Count > 0) - httpConnection.SetRequestProperty ("Accept-Encoding", String.Join (",", accept_encoding)); + if (_acceptEncoding is not null) + httpConnection.SetRequestProperty ("Accept-Encoding", _acceptEncoding); if (UseCookies && CookieContainer != null && request.RequestUri is not null) { string cookieHeaderValue = CookieContainer.GetCookieHeader (request.RequestUri);