Skip to content

Instantly share code, notes, and snippets.

@itorian
Last active October 1, 2019 05:44
Show Gist options
  • Save itorian/900ab47004b6a71e80ea1a1ea5ca8a5c to your computer and use it in GitHub Desktop.
Save itorian/900ab47004b6a71e80ea1a1ea5ca8a5c to your computer and use it in GitHub Desktop.
This gist has sample DevOps pipeline code to build ASP.NET Core Web Application for Linux
# ------------------------------------------------------------------------------
# 1. To build all .net core projects in a solution use below pipeline code
# ------------------------------------------------------------------------------
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- script: dotnet restore
displayName: 'dotnet restore'
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'dotnet test $(buildConfiguration)'
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
- task: DotNetCoreCLI@2
displayName: 'dotnet publish $(buildConfiguration)'
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
- task: PublishBuildArtifacts@1
displayName: 'publish artifacts'
# ------------------------------------------------------------------------------
# To build selected .net core projects in a solution use below pipeline code
# ------------------------------------------------------------------------------
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI@2
displayName: 'Restore project'
inputs:
command: 'restore'
projects: |
**/WebApplication_Li_CI_CD.csproj
**/WebApplication_Li_CI_CD_1.csproj
feedsToUse: 'select'
- task: DotNetCoreCLI@2
displayName: 'Build project'
inputs:
command: 'build'
projects: |
**/WebApplication_Li_CI_CD.csproj
**/WebApplication_Li_CI_CD_1.csproj
- task: DotNetCoreCLI@2
displayName: 'Publish project'
inputs:
command: publish
projects: |
**/WebApplication_Li_CI_CD.csproj
**/WebApplication_Li_CI_CD_1.csproj
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True
- task: CopyFiles@2
displayName: 'Copy zip files'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**\*.zip'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
# ---------------------------------------------------------------------------------------------------
# To build all .net framework in solution use below pipeline code
# ---------------------------------------------------------------------------------------------------
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**\*.zip'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment