Skip to content

Instantly share code, notes, and snippets.

@Im5tu
Last active June 30, 2018 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Im5tu/3f114127c4174cb4e6602d6295b8c827 to your computer and use it in GitHub Desktop.
Save Im5tu/3f114127c4174cb4e6602d6295b8c827 to your computer and use it in GitHub Desktop.
Sample Service Fabric YML Build File
name: 0.1$(Rev:.r)
queue: Hosted VS2017
variables:
buildConfiguration: 'Release'
buildProjects: '**/*.csproj'
packageProjects: '**/*.sfproj'
testProjects: '**/*Tests*.csproj'
dotnetCliVersion: '2.1.300'
steps:
# Restore the packages for all projects in the 'buildProjects' variable
# - We should only ever use the nuget.config and no other sources
# - Authentication isn't required here
- task: DotNetCoreCLI@2
displayName: Restore Packages (CS Projects)
inputs:
command: restore
feedsToUse: config
nugetConfigPath: 'nuget.config'
projects: $(buildProjects)
noCache: true
verbosityRestore: Normal
# Restore the build targets that service fabric requires to build
- task: NuGetCommand@2
displayName: Restore Packages (SF Projects)
inputs:
restoreSolution: $(packageProjects)
restoreDirectory: '..\..\packages'
feedsToUse: config
nugetConfigPath: nuget.config
noCache: true
verbosityRestore: Normal
# Build all projects in the 'buildProjects' variable
# - Service Fabric forces x64 builds
- task: DotNetCoreCLI@2
displayName: Build Projects
inputs:
projects: $(buildProjects)
packDirectory: '$(Build.ArtifactStagingDirectory)'
arguments: '-c $(buildConfiguration) /p:Platform=x64 /p:Version=$(Build.BuildNumber)'
# Build all projects in the 'testProjects' variable
# - Service Fabric forces x64 builds
- task: DotNetCoreCLI@2
displayName: Test Projects
inputs:
command: test
projects: $(testProjects)
publishTestResults: true
arguments: '--no-build -c $(buildConfiguration) /p:Platform=x64'
# Publish the service fabric application in release mode
- task: DotNetCoreCLI@2
displayName: Package Projects (Publish - Release)
inputs:
projects: $(packageProjects)
packDirectory: '$(Build.ArtifactStagingDirectory)\\drop\\release'
arguments: '-c Release /p:Platform=x64 /p:Version=$(Build.BuildNumber) /t:Package /p:PackageLocation=$(Build.ArtifactStagingDirectory)\drop\release\applicationpackage'
# Update the service fabric build numbers
- task: ServiceFabricUpdateManifests@2
displayName: Update Service Fabric Version (Release)
inputs:
applicationPackagePath: '$(Build.ArtifactStagingDirectory)\\drop\\release\\applicationpackage'
versionSuffix: '$(Build.BuildNumber)'
versionBehavior: Replace
# Copy the output to the staging area
- task: CopyFiles@2
displayName: Copy XML Files To Artifacts (Release)
inputs:
SourceFolder: 'src\'
Contents: |
**\*.ServiceFabric\PublishProfiles\*.xml
**\*.ServiceFabric\ApplicationParameters\*.xml
TargetFolder: '$(Build.ArtifactStagingDirectory)\drop\release\projectartifacts\'
CleanTargetFolder: true
# Publish the service fabric application in debug mode
- task: DotNetCoreCLI@2
displayName: Package Projects (Publish - Debug)
inputs:
projects: $(packageProjects)
packDirectory: '$(Build.ArtifactStagingDirectory)\\drop\\debug'
arguments: '-c Debug /p:Platform=x64 /p:Version=$(Build.BuildNumber) /t:Package /p:PackageLocation=$(Build.ArtifactStagingDirectory)\drop\debug\applicationpackage'
# Update the service fabric build numbers
- task: ServiceFabricUpdateManifests@2
displayName: Update Service Fabric Version (Debug)
inputs:
applicationPackagePath: '$(Build.ArtifactStagingDirectory)\\drop\\debug\\applicationpackage'
versionSuffix: '$(Build.BuildNumber)'
versionBehavior: Replace
# Copy the output to the staging area
- task: CopyFiles@2
displayName: Copy XML Files To Artifacts (Debug)
inputs:
SourceFolder: 'src\'
Contents: |
**\*.ServiceFabric\PublishProfiles\*.xml
**\*.ServiceFabric\ApplicationParameters\*.xml
TargetFolder: '$(Build.ArtifactStagingDirectory)\drop\debug\projectartifacts\'
CleanTargetFolder: true
# Publish all files in the staging area
- task: PublishBuildArtifacts@1
displayName: Publish Build Artifacts
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)/drop'
artifactName: 'drop'
publishLocation: Container
# Tag the VSTS build with:
# - The build number
- task: YodLabs.VariableTasks.AddTag.AddTag@0
displayName: Tag VSTS Build
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
tags: |
Build-$(Build.BuildNumber)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment