From c5cc152d8aa3e7da6b41e0f1c83c306625a7ca39 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 30 Oct 2025 13:36:42 +0000
Subject: [PATCH 1/9] Initial plan
From 3688d32c7fc32aa7f95cc22cf4070af37a3c0d12 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 30 Oct 2025 13:47:34 +0000
Subject: [PATCH 2/9] Add retry extension sample with flaky test demonstration
Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
---
.../RetryExtensionSample/FlakySampleTests.cs | 49 +++++++++
.../RetryExtensionSample/Program.cs | 17 +++
.../RetryExtensionSample/README.md | 104 ++++++++++++++++++
.../RetryExtensionSample.csproj | 39 +++++++
4 files changed, 209 insertions(+)
create mode 100644 samples/public/mstest-runner/RetryExtensionSample/FlakySampleTests.cs
create mode 100644 samples/public/mstest-runner/RetryExtensionSample/Program.cs
create mode 100644 samples/public/mstest-runner/RetryExtensionSample/README.md
create mode 100644 samples/public/mstest-runner/RetryExtensionSample/RetryExtensionSample.csproj
diff --git a/samples/public/mstest-runner/RetryExtensionSample/FlakySampleTests.cs b/samples/public/mstest-runner/RetryExtensionSample/FlakySampleTests.cs
new file mode 100644
index 0000000000..e2c35b2448
--- /dev/null
+++ b/samples/public/mstest-runner/RetryExtensionSample/FlakySampleTests.cs
@@ -0,0 +1,49 @@
+namespace RetryExtensionSample;
+
+///
+/// This sample demonstrates how to use the Microsoft.Testing.Extensions.Retry
+/// extension to retry failed tests. The test will fail on the first attempt
+/// and pass on the retry.
+///
+[TestClass]
+public class FlakySampleTests
+{
+ // Static field to track test execution count
+ private static int _executionCount = 0;
+
+ ///
+ /// This test simulates a flaky test that fails on the first run
+ /// and passes on subsequent runs. This pattern can occur in real-world
+ /// scenarios like:
+ /// - Network requests that might timeout
+ /// - Database connections that might be temporarily unavailable
+ /// - File system operations that might be locked
+ /// - Race conditions in concurrent code
+ ///
+ [TestMethod]
+ public void FlakyTest_FailsFirstTime_PassesOnRetry()
+ {
+ _executionCount++;
+
+ Console.WriteLine($"Test execution count: {_executionCount}");
+
+ // Fail on the first execution, pass on subsequent executions
+ if (_executionCount == 1)
+ {
+ Console.WriteLine("First execution - simulating failure");
+ Assert.Fail("Simulated failure on first execution");
+ }
+
+ Console.WriteLine("Test passed on retry!");
+ }
+
+ ///
+ /// This test always passes to show normal test behavior.
+ ///
+ [TestMethod]
+ public void NormalTest_AlwaysPasses()
+ {
+ Console.WriteLine("This test always passes");
+ Assert.IsTrue(true);
+ }
+}
diff --git a/samples/public/mstest-runner/RetryExtensionSample/Program.cs b/samples/public/mstest-runner/RetryExtensionSample/Program.cs
new file mode 100644
index 0000000000..8e888e0463
--- /dev/null
+++ b/samples/public/mstest-runner/RetryExtensionSample/Program.cs
@@ -0,0 +1,17 @@
+using System.Reflection;
+using Microsoft.Testing.Extensions;
+using Microsoft.Testing.Platform.Builder;
+
+// Create the test application builder
+ITestApplicationBuilder builder = await TestApplication.CreateBuilderAsync(args);
+
+// Register MSTest as the test framework
+builder.AddMSTest(() => [Assembly.GetExecutingAssembly()]);
+
+// Add the retry extension to enable retry functionality
+// This must be called to use the --retry-failed-tests command-line option
+builder.AddRetryProvider();
+
+// Build and run the test application
+using ITestApplication app = await builder.BuildAsync();
+return await app.RunAsync();
diff --git a/samples/public/mstest-runner/RetryExtensionSample/README.md b/samples/public/mstest-runner/RetryExtensionSample/README.md
new file mode 100644
index 0000000000..80401e58f7
--- /dev/null
+++ b/samples/public/mstest-runner/RetryExtensionSample/README.md
@@ -0,0 +1,104 @@
+# Microsoft.Testing.Extensions.Retry Sample
+
+This sample demonstrates how to use the `Microsoft.Testing.Extensions.Retry` extension to automatically retry failed tests. This is useful for handling flaky tests that might fail intermittently due to timing issues, network conditions, or other transient failures.
+
+## What is Microsoft.Testing.Extensions.Retry?
+
+The Retry extension is a testing platform-level feature that allows you to automatically retry tests that fail. When enabled, if a test fails, the entire test suite will be re-run up to a specified number of times until all tests pass or the maximum retry count is reached.
+
+## Key Features
+
+- Automatically retries failed tests
+- Configurable retry count
+- Failure threshold policies (max percentage, max tests count)
+- Works at the test suite level
+
+## How to Use
+
+### 1. Add the Package Reference
+
+Add the `Microsoft.Testing.Extensions.Retry` package to your project:
+
+```xml
+
+```
+
+### 2. Register the Retry Provider
+
+In your `Program.cs`, add the retry provider:
+
+```csharp
+using Microsoft.Testing.Extensions;
+using Microsoft.Testing.Platform.Builder;
+
+ITestApplicationBuilder builder = await TestApplication.CreateBuilderAsync(args);
+builder.AddMSTest(() => [typeof(Program).Assembly]);
+
+// Add the retry extension
+builder.AddRetryProvider();
+
+using ITestApplication app = await builder.BuildAsync();
+return await app.RunAsync();
+```
+
+### 3. Run Tests with Retry Enabled
+
+Run your tests with the `--retry-failed-tests` command-line option:
+
+```bash
+dotnet run --project RetryExtensionSample.csproj -- --retry-failed-tests 3
+```
+
+This will retry failed tests up to 3 times.
+
+## Sample Output
+
+When you run the sample, you'll see output similar to:
+
+```
+Test execution count: 1
+First execution - simulating failure
+Tests suite failed, total failed tests: 1, exit code: 2, attempt: 1/4
+
+Test execution count: 2
+Test passed on retry!
+Tests suite completed successfully in 2 attempts
+```
+
+## Command-Line Options
+
+- `--retry-failed-tests `: Sets the maximum number of retry attempts (default: 0, disabled)
+- `--retry-failed-tests-max-percentage `: Sets the maximum percentage of tests that can fail before retries are disabled (default: 100)
+- `--retry-failed-tests-max-tests `: Sets the maximum number of tests that can fail before retries are disabled
+
+## Example Commands
+
+Retry up to 3 times:
+```bash
+dotnet run -- --retry-failed-tests 3
+```
+
+Retry up to 3 times, but only if less than 50% of tests fail:
+```bash
+dotnet run -- --retry-failed-tests 3 --retry-failed-tests-max-percentage 50
+```
+
+Retry up to 3 times, but only if less than 5 tests fail:
+```bash
+dotnet run -- --retry-failed-tests 3 --retry-failed-tests-max-tests 5
+```
+
+## When to Use
+
+The retry extension is useful for:
+- Handling intermittent network failures
+- Dealing with timing-sensitive tests
+- Managing tests that depend on external resources
+- Working around environmental issues in CI/CD pipelines
+
+## Important Notes
+
+- The retry extension retries the **entire test suite**, not individual tests
+- If you need per-test retry logic, consider using the `[Retry]` attribute from MSTest instead
+- Set appropriate failure thresholds to avoid masking real issues
+- Review retry patterns to identify and fix the root causes of flaky tests
diff --git a/samples/public/mstest-runner/RetryExtensionSample/RetryExtensionSample.csproj b/samples/public/mstest-runner/RetryExtensionSample/RetryExtensionSample.csproj
new file mode 100644
index 0000000000..d45c93dac4
--- /dev/null
+++ b/samples/public/mstest-runner/RetryExtensionSample/RetryExtensionSample.csproj
@@ -0,0 +1,39 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+ false
+
+
+ true
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 112339cc6bd829db16eccd82d7dfc98832bea4cc Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 30 Oct 2025 13:50:02 +0000
Subject: [PATCH 3/9] Improve README with distinction between retry mechanisms
Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
---
.../mstest-runner/RetryExtensionSample/README.md | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/samples/public/mstest-runner/RetryExtensionSample/README.md b/samples/public/mstest-runner/RetryExtensionSample/README.md
index 80401e58f7..bfbafacfb5 100644
--- a/samples/public/mstest-runner/RetryExtensionSample/README.md
+++ b/samples/public/mstest-runner/RetryExtensionSample/README.md
@@ -6,6 +6,16 @@ This sample demonstrates how to use the `Microsoft.Testing.Extensions.Retry` ext
The Retry extension is a testing platform-level feature that allows you to automatically retry tests that fail. When enabled, if a test fails, the entire test suite will be re-run up to a specified number of times until all tests pass or the maximum retry count is reached.
+### Important: Difference from [Retry] Attribute
+
+There are **two different retry mechanisms** in the MSTest ecosystem:
+
+1. **`Microsoft.Testing.Extensions.Retry`** (this sample): A **platform-level** extension that retries the **entire test suite** when any test fails. Activated via `--retry-failed-tests` command-line option.
+
+2. **`[Retry]` attribute**: A **framework-level** attribute that retries individual test methods. Applied directly to test methods like `[TestMethod]` and `[Retry(3)]`.
+
+Use the platform-level retry extension when you want to handle environment-level failures that affect multiple tests. Use the `[Retry]` attribute when specific test methods are known to be flaky.
+
## Key Features
- Automatically retries failed tests
From 3a56018cf246672c23e2ee785818a5efb384969b Mon Sep 17 00:00:00 2001
From: Youssef Victor
Date: Thu, 30 Oct 2025 14:53:14 +0100
Subject: [PATCH 4/9] Fix
---
.../RetryExtensionSample/FlakySampleTests.cs | 34 ++-----------------
1 file changed, 2 insertions(+), 32 deletions(-)
diff --git a/samples/public/mstest-runner/RetryExtensionSample/FlakySampleTests.cs b/samples/public/mstest-runner/RetryExtensionSample/FlakySampleTests.cs
index e2c35b2448..a3921d0525 100644
--- a/samples/public/mstest-runner/RetryExtensionSample/FlakySampleTests.cs
+++ b/samples/public/mstest-runner/RetryExtensionSample/FlakySampleTests.cs
@@ -1,49 +1,19 @@
namespace RetryExtensionSample;
-///
-/// This sample demonstrates how to use the Microsoft.Testing.Extensions.Retry
-/// extension to retry failed tests. The test will fail on the first attempt
-/// and pass on the retry.
-///
[TestClass]
public class FlakySampleTests
{
- // Static field to track test execution count
- private static int _executionCount = 0;
-
- ///
- /// This test simulates a flaky test that fails on the first run
- /// and passes on subsequent runs. This pattern can occur in real-world
- /// scenarios like:
- /// - Network requests that might timeout
- /// - Database connections that might be temporarily unavailable
- /// - File system operations that might be locked
- /// - Race conditions in concurrent code
- ///
[TestMethod]
public void FlakyTest_FailsFirstTime_PassesOnRetry()
{
- _executionCount++;
-
- Console.WriteLine($"Test execution count: {_executionCount}");
-
- // Fail on the first execution, pass on subsequent executions
- if (_executionCount == 1)
+ if (Environment.GetCommandLineArgs().Any(arg => arg.Contains("Retries") && !arg.EndsWith("2")))
{
- Console.WriteLine("First execution - simulating failure");
Assert.Fail("Simulated failure on first execution");
}
-
- Console.WriteLine("Test passed on retry!");
}
-
- ///
- /// This test always passes to show normal test behavior.
- ///
+
[TestMethod]
public void NormalTest_AlwaysPasses()
{
- Console.WriteLine("This test always passes");
- Assert.IsTrue(true);
}
}
From 7e9369e7c915bd017f277aca9d2b790631b653d6 Mon Sep 17 00:00:00 2001
From: Youssef Victor
Date: Thu, 30 Oct 2025 14:55:56 +0100
Subject: [PATCH 5/9] Simplify csproj
---
.../RetryExtensionSample.csproj | 33 ++-----------------
1 file changed, 2 insertions(+), 31 deletions(-)
diff --git a/samples/public/mstest-runner/RetryExtensionSample/RetryExtensionSample.csproj b/samples/public/mstest-runner/RetryExtensionSample/RetryExtensionSample.csproj
index d45c93dac4..6e4bb8958b 100644
--- a/samples/public/mstest-runner/RetryExtensionSample/RetryExtensionSample.csproj
+++ b/samples/public/mstest-runner/RetryExtensionSample/RetryExtensionSample.csproj
@@ -1,39 +1,10 @@
-
+
- Exe
net8.0
enable
enable
- false
-
-
- true
-
-
- false
+ true
-
-
-
-
-
-
-
-
-
-
-
-
From 81b2897a2ef3a2a0b692d5a4236af380b49275fa Mon Sep 17 00:00:00 2001
From: Youssef Victor
Date: Thu, 30 Oct 2025 14:56:10 +0100
Subject: [PATCH 6/9] Delete
samples/public/mstest-runner/RetryExtensionSample/Program.cs
---
.../RetryExtensionSample/Program.cs | 17 -----------------
1 file changed, 17 deletions(-)
delete mode 100644 samples/public/mstest-runner/RetryExtensionSample/Program.cs
diff --git a/samples/public/mstest-runner/RetryExtensionSample/Program.cs b/samples/public/mstest-runner/RetryExtensionSample/Program.cs
deleted file mode 100644
index 8e888e0463..0000000000
--- a/samples/public/mstest-runner/RetryExtensionSample/Program.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.Reflection;
-using Microsoft.Testing.Extensions;
-using Microsoft.Testing.Platform.Builder;
-
-// Create the test application builder
-ITestApplicationBuilder builder = await TestApplication.CreateBuilderAsync(args);
-
-// Register MSTest as the test framework
-builder.AddMSTest(() => [Assembly.GetExecutingAssembly()]);
-
-// Add the retry extension to enable retry functionality
-// This must be called to use the --retry-failed-tests command-line option
-builder.AddRetryProvider();
-
-// Build and run the test application
-using ITestApplication app = await builder.BuildAsync();
-return await app.RunAsync();
From f055df72892b45cefa29b7cc4fd6e8ca23ff4377 Mon Sep 17 00:00:00 2001
From: Youssef Victor
Date: Thu, 30 Oct 2025 14:59:23 +0100
Subject: [PATCH 7/9] Update README.md
---
.../RetryExtensionSample/README.md | 85 ++-----------------
1 file changed, 6 insertions(+), 79 deletions(-)
diff --git a/samples/public/mstest-runner/RetryExtensionSample/README.md b/samples/public/mstest-runner/RetryExtensionSample/README.md
index bfbafacfb5..5baf907f86 100644
--- a/samples/public/mstest-runner/RetryExtensionSample/README.md
+++ b/samples/public/mstest-runner/RetryExtensionSample/README.md
@@ -4,15 +4,12 @@ This sample demonstrates how to use the `Microsoft.Testing.Extensions.Retry` ext
## What is Microsoft.Testing.Extensions.Retry?
-The Retry extension is a testing platform-level feature that allows you to automatically retry tests that fail. When enabled, if a test fails, the entire test suite will be re-run up to a specified number of times until all tests pass or the maximum retry count is reached.
+The Retry extension is a testing platform-level feature that allows you to automatically retry tests that fail. When enabled, if a test fails, the entire test suite will be re-run up to a specified number of times until all tests pass or the maximum retry count is reached. This extension is compatible with any test framework that supports Microsoft.Testing.Platform, and is not specific to MSTest.
-### Important: Difference from [Retry] Attribute
-
-There are **two different retry mechanisms** in the MSTest ecosystem:
+### Important: Difference from `[Retry]` Attribute
1. **`Microsoft.Testing.Extensions.Retry`** (this sample): A **platform-level** extension that retries the **entire test suite** when any test fails. Activated via `--retry-failed-tests` command-line option.
-
-2. **`[Retry]` attribute**: A **framework-level** attribute that retries individual test methods. Applied directly to test methods like `[TestMethod]` and `[Retry(3)]`.
+2. **`[Retry]` attribute**: A **framework-level** attribute that retries individual test methods. Applied directly to test methods like `[TestMethod]` and `[Retry(3)]`. This is specific to MSTest.
Use the platform-level retry extension when you want to handle environment-level failures that affect multiple tests. Use the `[Retry]` attribute when specific test methods are known to be flaky.
@@ -30,85 +27,15 @@ Use the platform-level retry extension when you want to handle environment-level
Add the `Microsoft.Testing.Extensions.Retry` package to your project:
```xml
-
-```
-
-### 2. Register the Retry Provider
-
-In your `Program.cs`, add the retry provider:
-
-```csharp
-using Microsoft.Testing.Extensions;
-using Microsoft.Testing.Platform.Builder;
-
-ITestApplicationBuilder builder = await TestApplication.CreateBuilderAsync(args);
-builder.AddMSTest(() => [typeof(Program).Assembly]);
-
-// Add the retry extension
-builder.AddRetryProvider();
-
-using ITestApplication app = await builder.BuildAsync();
-return await app.RunAsync();
+
```
-### 3. Run Tests with Retry Enabled
+### 2. Run Tests with Retry Enabled
Run your tests with the `--retry-failed-tests` command-line option:
```bash
-dotnet run --project RetryExtensionSample.csproj -- --retry-failed-tests 3
+dotnet test --project RetryExtensionSample.csproj --retry-failed-tests 3
```
This will retry failed tests up to 3 times.
-
-## Sample Output
-
-When you run the sample, you'll see output similar to:
-
-```
-Test execution count: 1
-First execution - simulating failure
-Tests suite failed, total failed tests: 1, exit code: 2, attempt: 1/4
-
-Test execution count: 2
-Test passed on retry!
-Tests suite completed successfully in 2 attempts
-```
-
-## Command-Line Options
-
-- `--retry-failed-tests `: Sets the maximum number of retry attempts (default: 0, disabled)
-- `--retry-failed-tests-max-percentage `: Sets the maximum percentage of tests that can fail before retries are disabled (default: 100)
-- `--retry-failed-tests-max-tests `: Sets the maximum number of tests that can fail before retries are disabled
-
-## Example Commands
-
-Retry up to 3 times:
-```bash
-dotnet run -- --retry-failed-tests 3
-```
-
-Retry up to 3 times, but only if less than 50% of tests fail:
-```bash
-dotnet run -- --retry-failed-tests 3 --retry-failed-tests-max-percentage 50
-```
-
-Retry up to 3 times, but only if less than 5 tests fail:
-```bash
-dotnet run -- --retry-failed-tests 3 --retry-failed-tests-max-tests 5
-```
-
-## When to Use
-
-The retry extension is useful for:
-- Handling intermittent network failures
-- Dealing with timing-sensitive tests
-- Managing tests that depend on external resources
-- Working around environmental issues in CI/CD pipelines
-
-## Important Notes
-
-- The retry extension retries the **entire test suite**, not individual tests
-- If you need per-test retry logic, consider using the `[Retry]` attribute from MSTest instead
-- Set appropriate failure thresholds to avoid masking real issues
-- Review retry patterns to identify and fix the root causes of flaky tests
From e326e9cb0d43c4a3d6b8e1042cdbe446da138c6a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 30 Oct 2025 14:22:11 +0000
Subject: [PATCH 8/9] Add Azure Pipeline for RetryExtensionSample
Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
---
azure-pipelines-retry-sample.yml | 151 +++++++++++++++++++++++++++++++
1 file changed, 151 insertions(+)
create mode 100644 azure-pipelines-retry-sample.yml
diff --git a/azure-pipelines-retry-sample.yml b/azure-pipelines-retry-sample.yml
new file mode 100644
index 0000000000..2bfba5abed
--- /dev/null
+++ b/azure-pipelines-retry-sample.yml
@@ -0,0 +1,151 @@
+# Azure Pipeline for testing the RetryExtensionSample
+# This pipeline builds and runs the RetryExtensionSample to verify it works correctly
+
+trigger:
+ branches:
+ include:
+ - main
+ - rel/*
+ paths:
+ include:
+ - samples/public/mstest-runner/RetryExtensionSample/*
+
+pr:
+ branches:
+ include:
+ - main
+ - rel/*
+ paths:
+ include:
+ - samples/public/mstest-runner/RetryExtensionSample/*
+
+variables:
+ - name: _TeamName
+ value: MSTest
+ - name: SampleProjectPath
+ value: samples/public/mstest-runner/RetryExtensionSample
+
+stages:
+- stage: TestRetrySample
+ displayName: Test Retry Extension Sample
+ jobs:
+ - job: Windows
+ displayName: Windows
+ pool:
+ name: NetCore-Public
+ demands: ImageOverride -equals windows.vs2022preview.amd64.open
+ steps:
+ - task: UseDotNet@2
+ displayName: 'Install .NET SDK'
+ inputs:
+ packageType: sdk
+ useGlobalJson: true
+ workingDirectory: $(Build.SourcesDirectory)
+
+ - task: DotNetCoreCLI@2
+ displayName: 'Restore sample project'
+ inputs:
+ command: restore
+ projects: '$(SampleProjectPath)/RetryExtensionSample.csproj'
+ feedsToUse: config
+ nugetConfigPath: '$(SampleProjectPath)/../../NuGet.config'
+
+ - task: DotNetCoreCLI@2
+ displayName: 'Build sample project'
+ inputs:
+ command: build
+ projects: '$(SampleProjectPath)/RetryExtensionSample.csproj'
+ arguments: '--configuration Release --no-restore'
+
+ - task: PowerShell@2
+ displayName: 'Run sample without retry (expect failure)'
+ inputs:
+ targetType: 'inline'
+ script: |
+ cd $(SampleProjectPath)
+ $output = dotnet run --configuration Release --no-build 2>&1 | Out-String
+ Write-Host $output
+ # We expect this to fail, so we don't fail the pipeline here
+ Write-Host "Sample run without retry completed (expected to fail)"
+ workingDirectory: $(Build.SourcesDirectory)
+ continueOnError: true
+
+ - task: PowerShell@2
+ displayName: 'Run sample with retry (expect success)'
+ inputs:
+ targetType: 'inline'
+ script: |
+ cd $(SampleProjectPath)
+ dotnet run --configuration Release --no-build -- --retry-failed-tests 3
+ workingDirectory: $(Build.SourcesDirectory)
+ failOnStderr: false
+
+ - task: PublishTestResults@2
+ displayName: 'Publish Test Results'
+ inputs:
+ testResultsFormat: 'VSTest'
+ testResultsFiles: '**/TestResults/**/*.trx'
+ searchFolder: '$(Build.SourcesDirectory)/$(SampleProjectPath)'
+ mergeTestResults: true
+ failTaskOnFailedTests: false
+ testRunTitle: 'Retry Extension Sample Tests'
+ condition: always()
+
+ - job: Linux
+ displayName: Linux
+ pool:
+ name: NetCore-Public
+ demands: ImageOverride -equals build.ubuntu.2004.amd64.open
+ steps:
+ - task: UseDotNet@2
+ displayName: 'Install .NET SDK'
+ inputs:
+ packageType: sdk
+ useGlobalJson: true
+ workingDirectory: $(Build.SourcesDirectory)
+
+ - task: DotNetCoreCLI@2
+ displayName: 'Restore sample project'
+ inputs:
+ command: restore
+ projects: '$(SampleProjectPath)/RetryExtensionSample.csproj'
+ feedsToUse: config
+ nugetConfigPath: '$(SampleProjectPath)/../../NuGet.config'
+
+ - task: DotNetCoreCLI@2
+ displayName: 'Build sample project'
+ inputs:
+ command: build
+ projects: '$(SampleProjectPath)/RetryExtensionSample.csproj'
+ arguments: '--configuration Release --no-restore'
+
+ - task: Bash@3
+ displayName: 'Run sample without retry (expect failure)'
+ inputs:
+ targetType: 'inline'
+ script: |
+ cd $(SampleProjectPath)
+ dotnet run --configuration Release --no-build || true
+ echo "Sample run without retry completed (expected to fail)"
+ workingDirectory: $(Build.SourcesDirectory)
+ continueOnError: true
+
+ - task: Bash@3
+ displayName: 'Run sample with retry (expect success)'
+ inputs:
+ targetType: 'inline'
+ script: |
+ cd $(SampleProjectPath)
+ dotnet run --configuration Release --no-build -- --retry-failed-tests 3
+ workingDirectory: $(Build.SourcesDirectory)
+
+ - task: PublishTestResults@2
+ displayName: 'Publish Test Results'
+ inputs:
+ testResultsFormat: 'VSTest'
+ testResultsFiles: '**/TestResults/**/*.trx'
+ searchFolder: '$(Build.SourcesDirectory)/$(SampleProjectPath)'
+ mergeTestResults: true
+ failTaskOnFailedTests: false
+ testRunTitle: 'Retry Extension Sample Tests - Linux'
+ condition: always()
From 87138f091a5ddaa839cc6a2c3d3d681bf7409917 Mon Sep 17 00:00:00 2001
From: Youssef Victor
Date: Thu, 30 Oct 2025 15:30:04 +0100
Subject: [PATCH 9/9] Update azure-pipelines-retry-sample.yml
Removed Linux job and related tasks from the pipeline.
---
azure-pipelines-retry-sample.yml | 83 +-------------------------------
1 file changed, 2 insertions(+), 81 deletions(-)
diff --git a/azure-pipelines-retry-sample.yml b/azure-pipelines-retry-sample.yml
index 2bfba5abed..dc697da481 100644
--- a/azure-pipelines-retry-sample.yml
+++ b/azure-pipelines-retry-sample.yml
@@ -3,21 +3,14 @@
trigger:
branches:
- include:
- - main
- - rel/*
- paths:
- include:
- - samples/public/mstest-runner/RetryExtensionSample/*
+ exclude:
+ - *
pr:
branches:
include:
- main
- rel/*
- paths:
- include:
- - samples/public/mstest-runner/RetryExtensionSample/*
variables:
- name: _TeamName
@@ -57,19 +50,6 @@ stages:
projects: '$(SampleProjectPath)/RetryExtensionSample.csproj'
arguments: '--configuration Release --no-restore'
- - task: PowerShell@2
- displayName: 'Run sample without retry (expect failure)'
- inputs:
- targetType: 'inline'
- script: |
- cd $(SampleProjectPath)
- $output = dotnet run --configuration Release --no-build 2>&1 | Out-String
- Write-Host $output
- # We expect this to fail, so we don't fail the pipeline here
- Write-Host "Sample run without retry completed (expected to fail)"
- workingDirectory: $(Build.SourcesDirectory)
- continueOnError: true
-
- task: PowerShell@2
displayName: 'Run sample with retry (expect success)'
inputs:
@@ -90,62 +70,3 @@ stages:
failTaskOnFailedTests: false
testRunTitle: 'Retry Extension Sample Tests'
condition: always()
-
- - job: Linux
- displayName: Linux
- pool:
- name: NetCore-Public
- demands: ImageOverride -equals build.ubuntu.2004.amd64.open
- steps:
- - task: UseDotNet@2
- displayName: 'Install .NET SDK'
- inputs:
- packageType: sdk
- useGlobalJson: true
- workingDirectory: $(Build.SourcesDirectory)
-
- - task: DotNetCoreCLI@2
- displayName: 'Restore sample project'
- inputs:
- command: restore
- projects: '$(SampleProjectPath)/RetryExtensionSample.csproj'
- feedsToUse: config
- nugetConfigPath: '$(SampleProjectPath)/../../NuGet.config'
-
- - task: DotNetCoreCLI@2
- displayName: 'Build sample project'
- inputs:
- command: build
- projects: '$(SampleProjectPath)/RetryExtensionSample.csproj'
- arguments: '--configuration Release --no-restore'
-
- - task: Bash@3
- displayName: 'Run sample without retry (expect failure)'
- inputs:
- targetType: 'inline'
- script: |
- cd $(SampleProjectPath)
- dotnet run --configuration Release --no-build || true
- echo "Sample run without retry completed (expected to fail)"
- workingDirectory: $(Build.SourcesDirectory)
- continueOnError: true
-
- - task: Bash@3
- displayName: 'Run sample with retry (expect success)'
- inputs:
- targetType: 'inline'
- script: |
- cd $(SampleProjectPath)
- dotnet run --configuration Release --no-build -- --retry-failed-tests 3
- workingDirectory: $(Build.SourcesDirectory)
-
- - task: PublishTestResults@2
- displayName: 'Publish Test Results'
- inputs:
- testResultsFormat: 'VSTest'
- testResultsFiles: '**/TestResults/**/*.trx'
- searchFolder: '$(Build.SourcesDirectory)/$(SampleProjectPath)'
- mergeTestResults: true
- failTaskOnFailedTests: false
- testRunTitle: 'Retry Extension Sample Tests - Linux'
- condition: always()