|
| 1 | +pool: |
| 2 | + vmImage: 'vs2017-win2016' |
| 3 | + |
| 4 | +variables: |
| 5 | + Prerelease: 'ci' |
| 6 | + buildType: 'azure-pipelines-ci' |
| 7 | + buildId: "1$(Build.BuildId)" |
| 8 | + buildProjects: '**/src/**/+(System.Linq.Dynamic.Core|EntityFramework.DynamicLinq|Microsoft.EntityFrameworkCore.DynamicLinq).csproj' |
| 9 | + |
| 10 | +steps: |
| 11 | +# Print buildId |
| 12 | +- script: | |
| 13 | + echo "BuildId = $(buildId)" |
| 14 | + displayName: 'Print buildId' |
| 15 | + |
| 16 | +# Install SonarScanner |
| 17 | +- script: | |
| 18 | + dotnet tool install --global dotnet-sonarscanner |
| 19 | + displayName: Install SonarScanner |
| 20 | + |
| 21 | +# Begin SonarScanner |
| 22 | +# See also |
| 23 | +# - https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools, else you get this error: `Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed.` |
| 24 | +# - https://github.com/dotnet/cli/issues/8368 |
| 25 | +# - https://github.com/Microsoft/vsts-tasks/issues/8291 |
| 26 | +# |
| 27 | +- script: | |
| 28 | + %USERPROFILE%\.dotnet\tools\dotnet-sonarscanner begin /k:"system.linq.dynamic.core" /d:sonar.organization="stefh-github" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$(SONAR_TOKEN)" /v:"$(buildId)" /d:sonar.cs.opencover.reportsPaths="**\coverage.opencover.xml" |
| 29 | + displayName: Begin SonarScanner |
| 30 | + |
| 31 | +- task: DotNetCoreCLI@2 |
| 32 | + displayName: Build Projects in Debug configuration |
| 33 | + inputs: |
| 34 | + command: 'build' |
| 35 | + arguments: /p:Configuration=Debug # https://github.com/MicrosoftDocs/vsts-docs/issues/1976 |
| 36 | + projects: $(buildProjects) |
| 37 | + |
| 38 | + |
| 39 | +# Build tests and run tests for net452 and netcoreapp2.1 (with coverage) |
| 40 | +- script: | |
| 41 | + dotnet test ./test/System.Linq.Dynamic.Core.Tests/System.Linq.Dynamic.Core.Tests.csproj --configuration Debug --framework net452 |
| 42 | + dotnet test ./test/System.Linq.Dynamic.Core.Tests/System.Linq.Dynamic.Core.Tests.csproj --configuration Debug --framework netcoreapp2.1 --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover |
| 43 | + displayName: 'Build tests and run tests for net452 and netcoreapp2.1 (with coverage)' |
| 44 | + |
| 45 | +# End SonarScanner |
| 46 | +- script: | |
| 47 | + %USERPROFILE%\.dotnet\tools\dotnet-sonarscanner end /d:sonar.login="$(SONAR_TOKEN)" |
| 48 | + displayName: End SonarScanner |
| 49 | + |
| 50 | +- task: PublishTestResults@2 |
| 51 | + inputs: |
| 52 | + testRunner: VSTest |
| 53 | + testResultsFiles: '**/*.trx' |
| 54 | + |
| 55 | +# Based on https://whereslou.com/2018/09/versioning-and-publishing-nuget-packages-automatically-using-azure-devops-pipelines/ |
| 56 | +- task: DotNetCoreCLI@2 |
| 57 | + displayName: Build Projects in Release configuration |
| 58 | + inputs: |
| 59 | + command: 'build' |
| 60 | + arguments: /p:Configuration=Release # https://github.com/MicrosoftDocs/vsts-docs/issues/1976 |
| 61 | + projects: $(buildProjects) |
| 62 | + |
| 63 | +- task: DotNetCoreCLI@2 |
| 64 | + displayName: Pack |
| 65 | + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests |
| 66 | + inputs: |
| 67 | + command: pack |
| 68 | + configuration: 'Release' |
| 69 | + packagesToPack: $(buildProjects) |
| 70 | + nobuild: true |
| 71 | + packDirectory: '$(Build.ArtifactStagingDirectory)/packages' |
| 72 | + verbosityPack: 'normal' |
| 73 | + |
| 74 | +- task: PublishBuildArtifacts@1 |
| 75 | + displayName: Publish Artifacts |
| 76 | + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests |
| 77 | + inputs: |
| 78 | + PathtoPublish: '$(Build.ArtifactStagingDirectory)' |
| 79 | + |
| 80 | +- task: DotNetCoreCLI@2 |
| 81 | + displayName: Push to MyGet |
| 82 | + condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests |
| 83 | + inputs: |
| 84 | + command: custom |
| 85 | + custom: nuget |
| 86 | + arguments: push $(Build.ArtifactStagingDirectory)\packages\*.nupkg --source https://www.myget.org/F/system-linq-dynamic-core/api/v3/index.json --no-service-endpoint --api-key $(MyGetKey) |
0 commit comments