代码拉取完成,页面将自动刷新
同步操作将从 magicodes/Magicodes.IE 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# 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: '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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。