diff --git a/test/GenerationSandbox.BuildTask.Tests/COMTests.cs b/test/GenerationSandbox.BuildTask.Tests/COMTests.cs index 5f71cafc..908cb7b7 100644 --- a/test/GenerationSandbox.BuildTask.Tests/COMTests.cs +++ b/test/GenerationSandbox.BuildTask.Tests/COMTests.cs @@ -27,7 +27,7 @@ public async Task CanInteropWithICompositorInterop() Assert.SkipUnless(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Test calls Windows-specific APIs"); var controller = DispatcherQueueController.CreateOnDedicatedThread(); - TaskCompletionSource tcs = new(); + TaskCompletionSource tcs = new(); controller.DispatcherQueue.TryEnqueue(() => { try @@ -50,15 +50,24 @@ public async Task CanInteropWithICompositorInterop() var interop = (ICompositorInterop)(object)compositor; interop.CreateGraphicsDevice(device, out var graphicsDevice); - tcs.SetResult(); + tcs.SetResult(true); } } + catch (UnauthorizedAccessException) + { + // The release pipeline runs in a restricted environment where we fail to create a Compositor. + // Since this runs fine on local dev machines, we can just suppress this failure. + tcs.SetResult(false); + } catch (Exception ex) { tcs.SetException(ex); } }); - await tcs.Task; + if (!await tcs.Task) + { + Assert.Skip("Skipping due to UnauthorizedAccessException."); + } } }