WindowsAzure/azure-sdk-tools — pull request #18 by tedglaza-msft (2011-12-12 19:18:34+00:00)
Title: Displaying error messages from CsRun

This is a proposed change that fixes #5. The current behavior for an error when calling CsRun looks like:

Creating local package...
Starting Emulator...
Start-AzureEmulator : Length cannot be less than zero.
Parameter name: length
At line:1 char:20
+ Start-AzureEmulator <<<<
+ CategoryInfo : CloseError: (:) [Start-AzureEmulator], ArgumentO
utOfRangeException
+ FullyQualifiedErrorId : AzureDeploymentCmdlets.Cmdlet.StartAzureEmulator
Command

This error is actually because we don't stop after the CsRun failure and keep running along until something random breaks much further down. The proposed fix checks for error message from CsRun and throws an exception containing the errors if found. After applying the fix, the output would look like below (and helpfully indicates that, in this case, your package is missing certain required parameters):

Creating local package...
Starting Emulator...
Start-AzureEmulator : An unexpected failure occurred. Details:
C:\src\azure\nodetools\AzureDeploymentCmdlets\src\AzureDeploymentCmdlets\bin\De
bug\test\LocalTest\ServiceConfiguration.Local.cscfg(7, 9) : Error : Error Cloud
Service51 : The XML specification is not valid: The required attribute 'thumbpr
intAlgorithm' is missing.
C:\src\azure\nodetools\AzureDeploymentCmdlets\src\AzureDeploymentCmdlets\bin\De
bug\test\LocalTest\ServiceConfiguration.Local.cscfg(7, 9) : Error : Error Cloud
Service51 : The XML specification is not valid: The required attribute 'thumbpr
int' is missing.
Encountered an unexpected error Object reference not set to an instance of an o
bject. at Microsoft.ServiceHosting.Tools.Internal.SimpleServiceModel.Service
ConfigurationValidator.Validate()
at Microsoft.ServiceHosting.Tools.CloudServiceRun.DoActions.Validate(FileInf
o csdef, FileInfo cscfg)
at Microsoft.ServiceHosting.Tools.CloudServiceRun.DoActions.Run(DirectoryInf
o dir, FileInfo serviceConfiguration, Boolean launchBrowser, Boolean paused, St
ring debugger)
at Microsoft.ServiceHosting.Tools.CloudServiceRun.DoActions.ParseArguments(S
tring[] args, Boolean doActions)
at Microsoft.ServiceHosting.Tools.CloudServiceRun.DoActions.ExecuteActions(S
tring[] args).
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Microsoft.ServiceHosting.Tools.Internal.SimpleServiceModel.ServiceConfigu
rationValidator.Validate()
at Microsoft.ServiceHosting.Tools.CloudServiceRun.DoActions.Validate(FileInf
o csdef, FileInfo cscfg)
at Microsoft.ServiceHosting.Tools.CloudServiceRun.DoActions.Run(DirectoryInf
o dir, FileInfo serviceConfiguration, Boolean launchBrowser, Boolean paused, St
ring debugger)
at Microsoft.ServiceHosting.Tools.CloudServiceRun.DoActions.ParseArguments(S
tring[] args, Boolean doActions)
at Microsoft.ServiceHosting.Tools.CloudServiceRun.DoActions.ExecuteActions(S
tring[] args)
at Microsoft.ServiceHosting.Tools.CloudServiceRun.Program.Main(String[] args
)
At line:1 char:20
+ Start-AzureEmulator <<<<
+ CategoryInfo : CloseError: (:) [Start-AzureEmulator], InvalidOp
erationException
+ FullyQualifiedErrorId : AzureDeploymentCmdlets.Cmdlet.StartAzureEmulator
Command