Search code examples
visual-studiopowershellazureazure-deployment

Executable Script Code Found in Signature Block Error


When using Visual Studio 2017 on a Windows 7 machine to deploy Azure ARM templates I recently started receiving an error stating that Executable script code found in signature block which appears only after the second deployment of a template. I found few sources that mentioned this error but none with an actual solution aside from closing and re-opening Visual Studio which really isn't an acceptable solution. I've included the full deploy log below:

17:40:53 - The following parameter values will be used for this operation:
17:40:53 -     AZTemplateTestName: AZTemplateTest-AppService
17:40:53 -     AZTemplateTestSkuName: S1
17:40:54 - Build started.
17:40:54 - Project "AZTemplateTest.deployproj" (StageArtifacts target(s)):
17:40:54 - Project "AZTemplateTest.deployproj" (ContentFilesProjectOutputGroup target(s)):
17:40:54 - Done building project "AZTemplateTest.deployproj".
17:40:54 - Done building project "AZTemplateTest.deployproj".
17:40:54 - Build succeeded.
17:40:54 - Launching PowerShell script with the following command:
17:40:54 - 'C:\Users\username\documents\visual studio 2017\Projects\AZTemplateTest-Test\AZTemplateTest-Test\bin\Debug\staging\AZTemplateTest\Deploy-AzureResourceGroup.ps1' -StorageAccountName '' -ResourceGroupName 'AZTemplateTest-Test-2' -ResourceGroupLocation 'eastus' -TemplateFile 'C:\Users\username\documents\visual studio 2017\Projects\AZTemplateTest-Test\AZTemplateTest-Test\bin\Debug\staging\AZTemplateTest\azuredeploy.json' -TemplateParametersFile 'C:\Users\username\documents\visual studio     2017\Projects\AZTemplateTest-Test\AZTemplateTest-Test\bin\Debug\staging\AZTemplateTest\azuredeploy.parameters.json' -ArtifactStagingDirectory '.' -DSCSourceFolder '.\DSC'
17:40:54 - [ERROR] At line:1 char:2337
+ $UI = 'VS-'; if (!(Test-Path 'C:\Users\username\AppData\Roaming\Windows Azure P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Executable script code found in signature block.

The more interesting part is that if I go to C:\Users\username\AppData\Roaming the only folder that fits the pattern of Windows Azure P is Windows Azure Powershell. Inside that folder the only thing present is AzureDataCollectionProfile.json which only contains if I opted in or out of the Azure data collection. If I try deleting that file and/or the folder the results remain the same.

I've also tried the following in hopes of finding a solution:

  • Created a new project entirely, same results
  • Cleaning the project, same results
  • Rebuilding the project, same results

Solution

  • This is a known issue in PowerShell 3 on Win7 - the only fix we have is to upgrade PowerShell.