Skip to content

Instantly share code, notes, and snippets.

@stuartpreston
Last active June 20, 2019 03:45
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 stuartpreston/ea356d28858dc90faf5dd2d6d705bb69 to your computer and use it in GitHub Desktop.
Save stuartpreston/ea356d28858dc90faf5dd2d6d705bb69 to your computer and use it in GitHub Desktop.
Snippets for the workshop: Building and deploying .NET applications with Chef Habitat and Azure Pipelines

Workshop - Get your snippets here!

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
name: Hosted VS2017
variables:
HAB_LICENSE: accept
steps:
- powershell: '[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; Remove-Item $env:ProgramData\habitat -Recurse -Force -ErrorAction Ignore; $s = "https://api.bintray.com/content/habitat/stable/windows/x86_64/hab-%24latest-x86_64-windows.zip?bt_package=hab-x86_64-windows"; (New-Object System.Net.WebClient).DownloadFile($s, "$env:TEMP\habitat.zip"); Expand-Archive $env:TEMP\habitat.zip -DestinationPath $env:ProgramData -Force; Get-ChildItem -Path $env:ProgramData -Filter "hab-*" -Depth 1 | Select-Object -First 1 | Rename-Item -NewName habitat -Force; [Environment]::SetEnvironmentVariable("PATH", "$env:ProgramData\habitat;$env:SystemDrive\hab\bin;$env:PATH", "Machine");'
displayName: 'Install Latest Habitat'
- task: chef-software.vsts-habitat-tasks.vsts-habitat-tasks-signing-key.vsts-habitat-signing-key@3
displayName: 'Signing Origin Key: install'
inputs:
habitatOrigin: workshop
- task: chef-software.vsts-habitat-tasks.vsts-habitat-tasks-build.vsts-habitat-build@3
displayName: 'Build Habitat plan'
inputs:
habitatOrigin: workshop
- powershell: |
. results/last_build.ps1
Set-Location c:\ProgramData\habitat
c:\ProgramData\habitat\hab.exe pkg export docker "$env:BUILD_SOURCESDIRECTORY/results/$pkg_artifact"
docker image list
dir env:
displayName: 'Export to Docker image'
Set-Location {{pkg.path}}
$env:ASPNETCORE_URLS="http://*:5000"
dotnet publish/workshop.dll
$pkg_deps=@("core/dotnet-asp-core")
$pkg_build_deps=@("core/dotnet-core-sdk")
function Invoke-Install {
Push-Location $PLAN_CONTEXT/../
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
& "$(Get-HabPackagePath dotnet-core-sdk)\bin\dotnet" publish --no-cache --configuration Release --output $pkg_prefix/publish
Pop-Location
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment