SmartAssembly 8

Example of azure-pipelines.yml

If you correctly followed the instruction for setting up SmartAssembly on Azure Pipeline, connecting to a database and setting up a error reporting, you should end up with a YAML file similar to the following:

  1. # .NET Desktop
  2. # Build and run tests for .NET Desktop or Windows classic desktop solutions.
  3. # Add steps that publish symbols, save build artifacts, and more:
  4. # https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
  5.  
  6. trigger:
  7. - master
  8.  
  9. pool:
  10. vmImage: 'windows-latest'
  11.  
  12. variables:
  13. solution: '**/*.sln'
  14. buildPlatform: 'Any CPU'
  15. buildConfiguration: 'Release'
  16.  
  17. steps:
  18. - task: NuGetToolInstaller@1
  19.  
  20. - task: NuGetCommand@2
  21. inputs:
  22. restoreSolution: '$(solution)'
  23.  
  24. ### SmartAssembly start ###
  25. - task: NuGetCommand@2
  26. displayName: 'SmartAssembly download'
  27. inputs:
  28. command: 'custom'
  29. arguments: 'install RedGate.SmartAssembly.Installer /OutputDirectory $(System.DefaultWorkingDirectory)'
  30. - task: PowerShell@2
  31. displayName: 'SmartAssembly installation'
  32. inputs:
  33. targetType: 'inline'
  34. script: |
  35. $saExtractPath = "$(System.DefaultWorkingDirectory)\RedGate.SmartAssembly.Installer*\tools\"
  36. $saInstallLocation = "$(System.DefaultWorkingDirectory)\tools\SA\"
  37. "##[debug] Installing SmartAssembly..."
  38. $msiPath = (Get-ChildItem "$saExtractPath\SmartAssembly_*_x64.msi").FullName
  39. "Installing SmartAssembly from $msiPath into $saInstallLocation"
  40. $p = Start-Process -FilePath msiexec -Args "/qn /i `"$msiPath`" INSTALLDIR=`"$saInstallLocation`" RG_LICENSE=`"$(SA_KEY)`" RG_WARNING=`"Ignore`" REBOOT=`"ReallySuppress`" RG_I=`"Red Gate Software Ltd.`"" -Wait -Verbose -PassThru
  41. if ($p.ExitCode -ne 0) {
  42. throw "SmartAssembly installation failed. Installer exited with code: $($p.ExitCode)"
  43. }
  44.  
  45. - task: PowerShell@2
  46. displayName: 'SmartAssembly.settings'
  47. inputs:
  48. targetType: 'inline'
  49. script: |
  50. ########################
  51. $saDbHost = "YOUR_DATABASE_HOST"; # replace with host of your database server
  52. $saDbUser = "YOUR_DATABASE_USER"; # replace with your database username
  53. $saDbName = "SmartAssembly"; # database will be created if it doesn't exist
  54. ########################
  55. $saDbPass = "$(SA_DB_PASSWORD)";
  56. "<SmartAssembly.Settings><Options><Database ConnectionString='Server=$saDbHost;Initial Catalog=$saDbName;User ID=$saDbUser;Password=$saDbPass' Server='$saDbHost' /></Options></SmartAssembly.Settings>" | Out-File -FilePath "$($env:ProgramData)\Red Gate\SmartAssembly 8\SmartAssembly.settings" -Verbose
  57.  
  58. - task: PowerShell@2
  59. displayName: 'Set Azure File Share credentials'
  60. inputs:
  61. targetType: 'inline'
  62. script: |
  63. ########################
  64. $fileShareHost = "YOUR_SHARE_HOST"; # replace with host of your Azure File Share server
  65. $fileShareUser = "YOUR_SHARE_USER"; # replace with your Azure File Share username
  66. ########################
  67. $fileSharePass = "$(SA_FS_PASSWORD)";
  68. Invoke-Expression -Command "cmdkey /add:$fileShareHost /user:$fileShareUser /pass:$fileSharePass"
  69. ### SmartAssembly end ###
  70.  
  71. - task: VSBuild@1
  72. inputs:
  73. solution: '$(solution)'
  74. platform: '$(buildPlatform)'
  75. configuration: '$(buildConfiguration)'
  76.  
  77. ### SmartAssembly start ###
  78. - task: PowerShell@2
  79. displayName: 'SmartAssembly deactivation'
  80. condition: always()
  81. inputs:
  82. targetType: 'inline'
  83. script: |
  84. $saInstallLocation = "$(System.DefaultWorkingDirectory)\Tools\SA\"
  85. $saComPath = "$saInstallLocation\SmartAssembly.com"
  86. "##[debug] Deactivating SmartAssembly..."
  87. $p = Start-Process -FilePath $saComPath -Args "/deactivateSerial" -PassThru -NoNewWindow -Wait
  88. if ($p.ExitCode -ne 0) {
  89. throw "Unable to deactivate SmartAssembly."
  90. }
  91. ### SmartAssembly end ###
  92.  
  93. - task: VSTest@2
  94. inputs:
  95. platform: '$(buildPlatform)'
  96. configuration: '$(buildConfiguration)'

Next steps

You can use the "variables" configuration section to store commonly used values (e.g. database and file share hosts and usernames). The variables can be used similarly to already defined solution, buildPlatform and buildConfiguration variables.

You may also want to use one of the available Azure tasks to store the assemblies processed by SmartAssembly as build artifacts, depending on the output location set in your .saproj file.


Didn't find what you were looking for?