Question: I'm trying to run a cypress test in an azure pipeline. In order to do that I need to run 'dotnet run' before I run the test. I have a pipeline task that successfully runs the 'dotnet run' command but because it never exits, the pipeline never gets to the next task. Is there a way using YAML to make the pipeline job go to the next step while keeping the 'dotnet run' command running?

If that isn't possible is there a way to run 'dotnet run' in the background while running a cypress test in an Azure pipeline?

Here's part of my YAML code:

```
- task: DotNetCoreCLI@2
  displayName: 'dotnet run'
  inputs:
        command: run
        projects: Api/Api.csproj
        arguments: '--configuration Release --verbosity normal'

- script: 'npx cypress verify' // pipeline job never gets to this step
    displayName: 'Verify Cypress Can Run'
    failOnStderr: true

```

Answer: 
I came up with a solution. I put 'dotnet run' in a powershell script that runs as a background process.

The powershell script:

```
Start-Process powershell -ArgumentList "-NoProfile", "-NonInteractive", "-NoExit", {
    dotnet run
}

```

Then I run the powershell script in a powershell build step:

```
- task: PowerShell@2
    inputs:
      targetType: 'filePath' # Optional. Options: filePath, inline
      filePath: $(Build.SourcesDirectory)\Api\dotnetrun.ps1
      errorActionPreference: 'stop'
      failOnStderr: false # Optional
      workingDirectory: ./Api
      displayName: 'Run dotnet run as background process'

```

The build step runs and goes to the next step as desired.
Azure Devops task won't navigate to next task unless the current task has completed its job.

Since the `dotnet run` task is running one xx.exe/api/... that keeps running and won't stop, it's expected behavior that your task will hang there.

> 
> Is there a way using YAML to make the pipeline job go to the next step
> while keeping the 'dotnet run' command running?
> 
> 
> 

As a workaround you can use cmd task to run the command. Instead of calling the command directly in CMD task, we should call the CMD task to open **new session** to run the `dotnet run` command. So that the job will go to next job and the `dotnet run` command can keep running in the background.

```
trigger:
- master

pool:
  name: default

steps:
- script: 'start cmd.exe /c dotnet run WpfCore.csproj'
  displayName: 'Open new Session to run dotnet run'

- script: 'TaskList'
  displayName: 'List running tasks to check if the WpfCore.exe keeps running'

```

[![enter image description here](https://i.stack.imgur.com/tAAzX.png)](https://i.stack.imgur.com/tAAzX.png)

**Note:**

Since the project I used for test is a Wpf app with one timer, I have to use a self-hosted agent with [interactive mode](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops#choose-interactive-or-service-mode). If the workaround above can't work for you when you're using microsoft hosted agent, you may need to consider using self-hosted agent with appropriate mode. (interactive or service mode)