Skip to content

Empty environment variables causes APPCMD to fail #73

@gamingrobot

Description

@gamingrobot

Azure DevOps sets a few empty environment variables. ServiceMonitor then converts these to an APPCMD command and then APPCMD fails with a configuration error.

ServiceMonitor Output:

Stopping service 'w3svc'

 Service 'w3svc' has been stopped 

APPCMD failed with error code 13

Example environment variables:

PSPath        : Microsoft.PowerShell.Core\Environment::INPUT_ARGUMENTS
PSDrive       : Env
PSProvider    : Microsoft.PowerShell.Core\Environment
PSIsContainer : False
Key           : INPUT_ARGUMENTS
Value         : 
Name          : INPUT_ARGUMENTS


PSPath        : Microsoft.PowerShell.Core\Environment::RESOURCES_TRIGGERINGALIAS
PSDrive       : Env
PSProvider    : Microsoft.PowerShell.Core\Environment
PSIsContainer : False
Key           : RESOURCES_TRIGGERINGALIAS
Value         : 
Name          : RESOURCES_TRIGGERINGALIAS


PSPath        : Microsoft.PowerShell.Core\Environment::RESOURCES_TRIGGERINGCATEGORY
PSDrive       : Env
PSProvider    : Microsoft.PowerShell.Core\Environment
PSIsContainer : False
Key           : RESOURCES_TRIGGERINGCATEGORY
Value         : 
Name          : RESOURCES_TRIGGERINGCATEGORY

Example Azure DevOps yaml:

- powershell: |
    Invoke-WebRequest -UseBasicParsing -Uri "https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.10/ServiceMonitor.exe" -OutFile "C:\ServiceMonitor.exe"
  displayName: Install Service Monitor
- powershell: |
    & C:\ServiceMonitor.exe w3svc
  displayName: Start IIS

Currently we are running this as a workaround before starting ServiceMonitor

Get-ChildItem -Path env: | Where-Object Value -eq "" | ForEach-Object { Set-Item -Path "Env:$($_.Name)" -Value "" }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions