Install TopShelf service

Octopus.Script exported 2018-02-22 by sphinxy belongs to ‘Topshelf’ category.

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Unpackage step =

The step where you unpack the topshelf service

Service username

Username =

null

Service password

Password =

null

Exe filename =

Name of exe file for service, if empty, package Id+“.exe.” will be used as default

Script body

Steps based on this template will execute the following PowerShell script.

$step = $OctopusParameters['Unpackage step']
$username = $OctopusParameters['Username'];
$password = $OctopusParameters['Password'];
$customExeFilename = $OctopusParameters['Exe filename'];

$outputPath = $OctopusParameters["Octopus.Action[$step].Package.CustomInstallationDirectory"]
if(!$outputPath) 
{
    $outputPath = $OctopusParameters["Octopus.Action[$step].Output.Package.InstallationDirectoryPath"]
}

$defaultExeFilename = $OctopusParameters["Octopus.Action[$step].Package.NuGetPackageId"] + ".exe"
$exeFilename = If ($customExeFilename) {$customExeFilename} Else {$defaultExeFilename}
$path = Join-Path $outputPath $exeFilename

if(-not (Test-Path $path) )
{
    Throw "$path was not found"
}

Write-Host "Installing from: $path"
if(!$username)
{
    Start-Process $path -ArgumentList "install" -NoNewWindow -Wait | Write-Host
} 
else 
{
    Start-Process $path -ArgumentList @("install", "-username", $username, "-password", $password) -NoNewWindow -Wait | Write-Host
}
Start-Process $path -ArgumentList "start" -NoNewWindow -Wait | Write-Host

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "24189509-ae05-434b-9a28-080b81875e10",
  "Name": "Install TopShelf service",
  "Description": null,
  "Version": 3,
  "ExportedAt": "2018-02-22T16:54:25.613Z",
  "ActionType": "Octopus.Script",
  "Author": "sphinxy",
  "Parameters": [
    {
      "Id": "463159e1-62fa-4150-bdb9-dfb7dac6ecfa",
      "Name": "Unpackage step",
      "Label": "",
      "HelpText": "The step where you unpack the topshelf service",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "StepName"
      },
      "Links": {}
    },
    {
      "Id": "d5d3e88e-b16a-4864-ac1e-614f11c861ed",
      "Name": "Username",
      "Label": "Service username",
      "HelpText": null,
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      },
      "Links": {}
    },
    {
      "Id": "0fcca6af-0ba4-495c-b120-b06ac8de2ebd",
      "Name": "Password",
      "Label": "Service password",
      "HelpText": null,
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "Sensitive"
      },
      "Links": {}
    },
    {
      "Id": "40da9228-33db-402a-9404-8e06c2817d7d",
      "Name": "Exe filename",
      "Label": "",
      "HelpText": "Name of exe file for service, if empty, package Id+\".exe.\" will be used as default",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      },
      "Links": {}
    }
  ],
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptSource": "Inline",
    "Octopus.Action.RunOnServer": "false",
    "Octopus.Action.Script.ScriptBody": "$step = $OctopusParameters['Unpackage step']\n$username = $OctopusParameters['Username'];\n$password = $OctopusParameters['Password'];\n$customExeFilename = $OctopusParameters['Exe filename'];\n\n$outputPath = $OctopusParameters[\"Octopus.Action[$step].Package.CustomInstallationDirectory\"]\nif(!$outputPath) \n{\n    $outputPath = $OctopusParameters[\"Octopus.Action[$step].Output.Package.InstallationDirectoryPath\"]\n}\n\n$defaultExeFilename = $OctopusParameters[\"Octopus.Action[$step].Package.NuGetPackageId\"] + \".exe\"\n$exeFilename = If ($customExeFilename) {$customExeFilename} Else {$defaultExeFilename}\n$path = Join-Path $outputPath $exeFilename\n\nif(-not (Test-Path $path) )\n{\n    Throw \"$path was not found\"\n}\n\nWrite-Host \"Installing from: $path\"\nif(!$username)\n{\n    Start-Process $path -ArgumentList \"install\" -NoNewWindow -Wait | Write-Host\n} \nelse \n{\n    Start-Process $path -ArgumentList @(\"install\", \"-username\", $username, \"-password\", $password) -NoNewWindow -Wait | Write-Host\n}\nStart-Process $path -ArgumentList \"start\" -NoNewWindow -Wait | Write-Host\n"
  },
  "Category": "Topshelf",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/topshelf-install.json",
  "Website": "/step-templates/24189509-ae05-434b-9a28-080b81875e10",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAMAUExURQAAAGuNkHCRlHGSlXKSlnOTl3OUlnOUl3STlnSTl3SUl3WUmHaVmXaWmHaWmXeWmniWmXiWmniXm3mYmnmYm3qZnHuanXyanHyanX2ann2cnn6cn3+coICcn4Cen4CcoICdoYGeoYKfooOgooOgo4SgooSgo4WgpIWipIaipYejpoijpYijpoikpomkp4qlqIumqIumqYymqIymqY2nqo2oqo6oq4+orJCpq5CprJCqrJGqrZKrrpKsrZKsrpSsr5StsJWusJausZivsZiwspmws5qxtJqytJyztZyztp20tp61t5+2t5+2uKC2t6C2uKG2uaK4uqO5u6S4uqS5u6W5vKW6vKa7vae8vqi8vqm9v6q+v6u+wKy/wKy/wa2/wq3Awa3Awq7Bw6/Cw7DCw7DCxLHDxbLExbLExrTFxrTFx7XGx7XGyLfHybbIybjIybjIyrnJy7rKy7rKzLvLzbzLzLzLzbzMzLzMzb3Mzr7Nz7/Ozr/Oz7/O0MDOz8DO0MHP0cHQ0MLQ0cLQ0sPR08TR0sTR08TS0sTS08XS1MbT1cbU1cjU1cjU1snV18jW1srW18rW2MvX2czX2MzX2czY2MzY2c3Y2s7Z287a2s/a28/a3NDa29Da3NHb3dLc3dLc3tPd39Pe3tPe39Td3tTd39Te3tTe39Xe4Nbf4dbg4Nbg4djg4djg4tni4tni49rj5Nvk5Nzj5Nzk5Nzk5d3l5t7l597m5t7m59/m6ODn5+Dm6OHn6eDo6OHo6eLp6uPq6uPq6+Tp6uTq6uTq6+Xr7Obs7Ofs7ejt7ejt7uju7unu7+vv8Ovw8Ovw8ezw8Ozw8e3x8u3y8u/y8/Dz8/Dz9PD09PL09fL19vL29vT29vT39/X3+Pb4+Pr7+/v8/Pz9/f///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdLIC0AAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAACXBIWXMAAAsSAAALEgHS3X78AAAAGXRFWHRTb2Z0d2FyZQBwYWludC5uZXQgNC4wLjEyQwRr7AAADAJJREFUeF7tmv1bW1cdwOdyJzO3nuy6ZAulk0G1rnNQtCvTtrYr9oWBClVkDmtt3aDosGXiJkHWMNCatGNNBrsp2Cxx6pIt0LA1SDok6dYUCrGSQtfq5tv+kus533NuCFD6MnA97jmfH3jueT+fe15vHm754GOCEOENIcIbQoQ3hAhvCBHeECK8IUR4Q4jwhhDhDSHCG0KEN4QIbwgR3hAivCFEeEOI8IYQ4Q0hwhtChDeECG8IEd4QIrwhRHhDiPCGEOENIcIbQoQ3hAhvCBHeECK8IUR4Q4jwhhDhDSHCG0KEN4QIb9yifUwQIrwhRHhDiPDGRyrSpqaxsahr4WT5Me0siqD2vBmNRgf7VS+L+GhForurqoGqxjdZ1LVINepFdsVYlKYdmjy+LT/bar33/kpvykHj0iJ271VpY9kWRXi5QTICG8Is6lqk1utFcoZZlOZMlMqygvKK7kGyVDpEI9MiXtvuvQuyxxZh2RZFItBephDQ5usVmYo4q8xQJC8tMr0B4XBZajS2CqGNAzQyLdL7FYPRaGDQdyClQ1LxSZZtUTgD4cuP4E7cgMgLgZOxMnmWiOfx23E4/8IhzdMkoU3zRDYhxVyyrx6zr5K8AsVUSgL1Py41K2jTkowIJlJ7YyKYo7VGUiQtEs8hwRJcw2tB4xVF0I5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fNcPAf9HfIm8ViRNods2CxN4nFiHCFEOEN8X+/vCFEeEOI8IYQ4Q0hwhtChDeECG8IEd4QIrwhRHhDiPCGEOENIcIbQoQ3hAhvCBHeECK8IUR4Q4jwhhDhDSHCG0KEN4QIbwgR3hAivCFEeEOI8IYQ4Q0hwhtChDeECG8IEd4QIrwhRHhDiPCGEOGNj4nIBx/8F1iAxE3PuRtyAAAAAElFTkSuQmCC",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Thursday, February 22, 2018