1- # ASP.NET Core (.NET Framework)
2- # Build and test ASP.NET Core projects targeting the full .NET Framework.
3- # Add steps that publish symbols, save build artifacts, and more:
4- # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
1+ # ASP.NET Core 8.0
2+ # Build and test ASP.NET Core projects targeting .NET 8 on Linux.
3+ # https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core
54
5+ # Trigger pipeline on commits to master and pull requests (equivalent to GitHub Actions 'on: [push, pull_request]')
66trigger :
7- - master
7+ - master
8+ - feature/*
89
10+ pr :
11+ - master
12+
13+ # Agent pool configuration (equivalent to GitHub Actions 'runs-on: ubuntu-latest')
914pool :
10- vmImage : ' windows -latest'
15+ vmImage : " ubuntu -latest"
1116
17+ # Environment variables (equivalent to GitHub Actions 'env:')
1218variables :
13- solution : ' **/*.sln '
14- buildPlatform : ' Any CPU '
15- buildConfiguration : ' Release '
19+ buildConfiguration : " Release "
20+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : 1 # Skip .NET welcome message
21+ DOTNET_NOLOGO : true # Suppress .NET logo in output
1622 NUGET_PACKAGES : $(Pipeline.Workspace)/.nuget/packages
1723
24+ # Pipeline steps (equivalent to GitHub Actions 'steps:')
1825steps :
19- - task : NuGetToolInstaller@1
20-
21- - task : Cache@2
22- inputs :
23- key : ' nuget | "$(Agent.OS)" | **/packages.lock.json,!**/bin/**,!**/obj/**'
24- restoreKeys : |
25- nuget | "$(Agent.OS)"
26- path : ' $(NUGET_PACKAGES)'
27- cacheHitVar : ' CACHE_RESTORED'
28-
29- - task : NuGetCommand@2
30- condition : ne(variables.CACHE_RESTORED, true)
31- inputs :
32- restoreSolution : ' $(solution)'
33-
34- - task : VSBuild@1
35- inputs :
36- solution : ' $(solution)'
37- msbuildArgs : ' /t:Restore /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
38- platform : ' $(buildPlatform)'
39- configuration : ' $(buildConfiguration)'
40-
41- - task : VSTest@2
42- inputs :
43- platform : ' $(buildPlatform)'
44- configuration : ' $(buildConfiguration)'
26+ # Checkout repository (equivalent to actions/checkout@v6)
27+ # Azure Pipelines does this implicitly, but making it explicit for clarity
28+ - checkout : self
29+ displayName : " Checkout repository"
30+
31+ # Cache NuGet packages (equivalent to actions/setup-dotnet cache feature)
32+ # Uses packages.lock.json hash as cache key for faster restores
33+ - task : Cache@2
34+ displayName : " Cache NuGet packages"
35+ inputs :
36+ key : ' nuget | "$(Agent.OS)" | **/packages.lock.json'
37+ restoreKeys : |
38+ nuget | "$(Agent.OS)"
39+ path : $(NUGET_PACKAGES)
40+
41+ # Install .NET 8 SDK (equivalent to actions/setup-dotnet@v5)
42+ # performMultiLevelLookup: allows finding other SDK versions if needed
43+ - task : UseDotNet@2
44+ displayName : " Set up .NET 8"
45+ inputs :
46+ version : " 8.x"
47+ performMultiLevelLookup : true
48+
49+ # Restore NuGet packages (equivalent to 'dotnet restore')
50+ # feedsToUse: 'select' uses feeds from NuGet.config
51+ - task : DotNetCoreCLI@2
52+ displayName : " Restore dependencies"
53+ inputs :
54+ command : " restore"
55+ projects : " **/*.csproj"
56+ feedsToUse : " select"
57+
58+ # Build the solution (equivalent to 'dotnet build')
59+ # --no-restore: skip restore since we just did it (faster build)
60+ - task : DotNetCoreCLI@2
61+ displayName : " Build projects"
62+ inputs :
63+ command : " build"
64+ projects : " **/*.sln"
65+ arguments : " --configuration $(buildConfiguration) --no-restore"
66+
67+ # Run unit tests (equivalent to 'dotnet test')
68+ # --no-build: use already-built assemblies (faster)
69+ # publishTestResults: automatically publish test results to Azure DevOps (built-in feature)
70+ - task : DotNetCoreCLI@2
71+ displayName : " Run tests"
72+ inputs :
73+ command : " test"
74+ projects : " **/*Tests/*.csproj"
75+ arguments : " --configuration $(buildConfiguration) --no-build"
76+ publishTestResults : true
0 commit comments