steps:
- task: UseDotNet@2
  displayName: 'Install .NET Core 8 SDK'
  inputs:
    version: 8.x
    performMultiLevelLookup: true
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
  displayName: Setup build environment
- script: |
    conda config --set always_yes yes --set changeps1 no
    conda info -a
    conda install -n base conda-libmamba-solver
    conda config --set solver libmamba
    conda create --name rdkit_build -c conda-forge --override-channels  ^
        cmake=3.26 ^
        libboost=$(boost_version) ^
        libboost-devel=$(boost_version) ^
        cairo eigen swig=4.2
    call activate rdkit_build
    conda config --env --add channels conda-forge
    conda config --env --set channel_priority strict
  displayName: Install dependencies
- script: |
    set Boost_ROOT=
    mkdir build && cd build
    call activate rdkit_build
    cmake .. ^
    -G "Visual Studio 17 2022" ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DRDK_INSTALL_INTREE=ON ^
    -DRDK_INSTALL_STATIC_LIBS=OFF ^
    -DRDK_BUILD_CPP_TESTS=OFF ^
    -DRDK_BUILD_PYTHON_WRAPPERS=OFF ^
    -DRDK_BUILD_COORDGEN_SUPPORT=ON ^
    -DRDK_BUILD_MAEPARSER_SUPPORT=ON ^
    -DRDK_OPTIMIZE_POPCNT=ON ^
    -DRDK_BUILD_TEST_GZIP=OFF ^
    -DRDK_BUILD_FREESASA_SUPPORT=OFF ^
    -DRDK_BUILD_AVALON_SUPPORT=ON ^
    -DRDK_BUILD_INCHI_SUPPORT=ON ^
    -DRDK_BUILD_YAEHMOP_SUPPORT=ON ^
    -DRDK_BUILD_XYZ2MOL_SUPPORT=ON ^
    -DRDK_BUILD_CAIRO_SUPPORT=ON ^
    -DRDK_BUILD_THREADSAFE_SSS=ON ^
    -DRDK_BUILD_SWIG_WRAPPERS=ON ^
    -DRDK_BUILD_SWIG_JAVA_WRAPPER=OFF ^
    -DRDK_BUILD_SWIG_CSHARP_WRAPPER=ON ^
    -DRDK_BUILD_CFFI_LIB=OFF ^
    -DRDK_SWIG_STATIC=ON ^
    -DRDK_TEST_MULTITHREADED=ON
  displayName: Configure build (Run CMake)
- script: |
    call activate rdkit_build
    cd build
    cmake --build . --config Release --target install -j $(number_of_cores)
  displayName: Build
- script: |
    call activate rdkit_build
    set RDBASE=%cd%
    set PYTHONPATH=%RDBASE%;%PYTHONPATH%
    set PATH=%RDBASE%\lib;%PATH%
    cd build
    ctest -R CSharpTests -C Release -T test --output-on-failure --verbose
  displayName: Run tests
- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'CTest'
    testResultsFiles: 'build/Testing/*/Test.xml'
    testRunTitle: $(system.phasedisplayname)  CTest Test Run