1 Star 0 Fork 96

john159357/Magicodes.IE

forked from magicodes/Magicodes.IE 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
azure-pipelines.yml 5.07 KB
一键复制 编辑 原始数据 按行查看 历史
HueiFeng 提交于 2024-01-10 23:53 . Update azure-pipelines.yml
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
# 代码覆盖率参考:https://docs.microsoft.com/zh-cn/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops#collect-code-coverage
# https://www.meziantou.net/computing-code-coverage-for-a-dotnet-core-project-with-azure-devops-and-coverlet.htm
# trigger
# https://docs.microsoft.com/zh-cn/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml
# ReportGenerator,将Coverlet,OpenCover,dotCover,Visual Studio,NCover,Cobertura,JaCoCo,Clover,gcov或lcov生成的覆盖率报告转换为各种格式的可读报告:
# https://github.com/danielpalme/ReportGenerator
# https://danielpalme.github.io/ReportGenerator/usage.html
# specific path build
trigger:
branches:
include:
- master
- develop
- release/*
paths:
include:
- src/*
exclude:
- src/*.md
pr:
- master
- develop
pool:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
disable.coverage.autogenerate: 'true'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '6.x'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '7.x'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '8.x'
# 不再进行多框架全面测试
#- task: UseDotNet@2
# inputs:
# packageType: 'sdk'
# version: '5.x'
#- task: UseDotNet@2
# inputs:
# packageType: 'sdk'
# version: '3.1.x'
#- task: UseDotNet@2
# inputs:
# packageType: 'sdk'
# version: '2.2.x'
# - task: DotNetCoreCLI@2
# inputs:
# command: 'build'
# configuration: $(BuildConfiguration)
# vstsFeed: xinlaiopencode/xinlaiopencode
# includeNuGetOrg: true
# - task: DotNetCoreCLI@2
# inputs:
# command: 'test'
# configuration: $(BuildConfiguration)
# arguments: '--logger trx --collect "XPlat Code Coverage"'
- task: PowerShell@2
displayName: Run Tests and ReportGenerator
inputs:
targetType: 'inline'
script: |
#执行单元测试
dotnet test --logger:trx --collect:"XPlat Code Coverage" --configuration $(BuildConfiguration)
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator "-reports:**\TestResults\*\coverage.cobertura.xml;**\TestResults\cobertura-coverage.xml" "-targetdir:$(System.DefaultWorkingDirectory)\coveragereport" "-reporttypes:HtmlInline_AzurePipelines_Dark;Cobertura;Badges" "-assemblyfilters:-Dapper*;-Dommel*;-Magicodes.ExporterAndImporter.AspNetCore*;-Magicodes.IE.EPPlus*;-MagicodesWebSite*"
ls coveragereport
ls TestResults
failOnStderr: true
continueOnError: true
# - task: PowerShell@2
# displayName: Run Tests and ReportGenerator
# inputs:
# targetType: 'inline'
# script: |
# ls TestResults
# dotnet tool install -g dotnet-reportgenerator-globaltool
# reportgenerator "-reports:**\TestResults\*\coverage.cobertura.xml;**\TestResults\cobertura-coverage.xml" "-targetdir:$(System.DefaultWorkingDirectory)\coveragereport" "-reporttypes:HtmlInline_AzurePipelines_Dark;Cobertura;Badges" "-assemblyfilters:-Dapper*;-Dommel*;-Magicodes.ExporterAndImporter.AspNetCore*;-MagicodesWebSite*"
# failOnStderr: true
# continueOnError: false
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: 'VSTest' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/TestResults/*.trx'
testRunTitle: API.Tests
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage report'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)\coveragereport\Cobertura.xml'
reportDirectory: '$(System.DefaultWorkingDirectory)\coveragereport'
- task: PowerShell@2
displayName: 'Package Push'
condition: eq(variables['Build.SourceBranchName'], 'master')
env:
NUGET_API_KEY: ${nugetapikey}
GITHUB_API_KEY: ${githubapikey}
inputs:
targetType: 'inline'
script: |
# 打包
Get-ChildItem -Path ./ -Recurse |
Where-Object { $_.Name.EndsWith(".csproj") -and !$_.Name.Contains("Test") } |
ForEach-Object -Process {
Write-Host $_.Name
dotnet pack $_.FullName -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --include-source --output $(Build.ArtifactStagingDirectory) -c $(BuildConfiguration)
}
ls $(Build.ArtifactStagingDirectory)
#推包
dotnet nuget push $(Build.ArtifactStagingDirectory)\*.nupkg -k $env:NUGET_API_KEY --skip-duplicate -s https://api.nuget.org/v3/index.json
#使用gpr工具推送到GitHub
dotnet tool install -g gpr --no-cache -v q
gpr push --api-key $env:GITHUB_API_KEY $(Build.ArtifactStagingDirectory)\*.nupkg
failOnStderr: true
showWarnings: true
ignoreLASTEXITCODE: true
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/john159357/Magicodes.IE.git
git@gitee.com:john159357/Magicodes.IE.git
john159357
Magicodes.IE
Magicodes.IE
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385