// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java
// public class Constants {
//     public static final String USE_VAR = "dot_trace";
//     public static final String PATH_VAR = "dot_trace_path";
//     public static final String THRESHOLDS_VAR = "dot_trace_thresholds";
//     public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type";
//     public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes";
//     public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters";
//     public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path";
// }


import com.intellij.openapi.util.text.StringUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import jetbrains.buildServer.dotNet.buildRunner.agent.*;
import jetbrains.buildServer.dotTrace.Constants;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
  private final RunnerAssertions myAssertions;

  public DotTraceSetupBuilder(
    @NotNull final ResourceGenerator<Context> projectGenerator,
    @NotNull final ResourceGenerator<Context> patternGenerator,
    @NotNull final ResourceGenerator<Context> cmdGenerator,
    @NotNull final ResourcePublisher beforeBuildPublisher,
    @NotNull final ResourcePublisher dotTraceBuildPublisher,
    @NotNull final ResourcePublisher dotTraceSnapshotsPublisher,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService,
    @NotNull final RunnerAssertions assertions) {
    myProjectGenerator = projectGenerator;
    myPatternGenerator = patternGenerator;
    myCmdGenerator = cmdGenerator;
    myBeforeBuildPublisher = beforeBuildPublisher;
    myDotTraceBuildPublisher = dotTraceBuildPublisher;
    myDotTraceSnapshotsPublisher = dotTraceSnapshotsPublisher;
    myParametersService = parametersService;
    myFileService = fileService;
    myAssertions = assertions;
  }

  @Override
  @NotNull
  public Iterable<CommandLineSetup> build(@NotNull final CommandLineSetup baseSetup) {
    if(myAssertions.contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED)) {
      return Collections.singleton(baseSetup);
    }

// Path: dotTrace-common/src/main/java/jetbrains/buildServer/dotTrace/Constants.java
// public class Constants {
//     public static final String USE_VAR = "dot_trace";
//     public static final String PATH_VAR = "dot_trace_path";
//     public static final String THRESHOLDS_VAR = "dot_trace_thresholds";
//     public static final String MEASURE_TYPE_VAR = "dot_trace_measure_type";
//     public static final String PROFILE_CHILD_PROCESSES_VAR = "dot_trace_profile_child_processes";
//     public static final String PROCESS_FILTERS_VAR = "dot_trace_process_filters";
//     public static final String SNAPSHOTS_PATH_VAR = "dot_trace_snapshots_path";
// }


// Path: dotTrace-agent/src/main/java/jetbrains/buildServer/dotTrace/agent/DotTraceSetupBuilder.java
import com.intellij.openapi.util.text.StringUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import jetbrains.buildServer.dotNet.buildRunner.agent.*;
import jetbrains.buildServer.dotTrace.Constants;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;

  private final RunnerAssertions myAssertions;

  public DotTraceSetupBuilder(
    @NotNull final ResourceGenerator<Context> projectGenerator,
    @NotNull final ResourceGenerator<Context> patternGenerator,
    @NotNull final ResourceGenerator<Context> cmdGenerator,
    @NotNull final ResourcePublisher beforeBuildPublisher,
    @NotNull final ResourcePublisher dotTraceBuildPublisher,
    @NotNull final ResourcePublisher dotTraceSnapshotsPublisher,
    @NotNull final RunnerParametersService parametersService,
    @NotNull final FileService fileService,
    @NotNull final RunnerAssertions assertions) {
    myProjectGenerator = projectGenerator;
    myPatternGenerator = patternGenerator;
    myCmdGenerator = cmdGenerator;
    myBeforeBuildPublisher = beforeBuildPublisher;
    myDotTraceBuildPublisher = dotTraceBuildPublisher;
    myDotTraceSnapshotsPublisher = dotTraceSnapshotsPublisher;
    myParametersService = parametersService;
    myFileService = fileService;
    myAssertions = assertions;
  }

  @Override
  @NotNull
  public Iterable<CommandLineSetup> build(@NotNull final CommandLineSetup baseSetup) {
    if(myAssertions.contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED)) {
      return Collections.singleton(baseSetup);
    }

    final String dotTraceTool = myParametersService.tryGetRunnerParameter(Constants.USE_VAR);