Errors when creating cspkg with octopus variables in ServiceConfiguration.Cloud.cscfg

Hi,

You must have already had the questions but when I set some octopus substitution variables in the cscfg, when packaging I get xml validation errors on those substitution strings because they do not conform with the expected value.

Example with error associated to it.

Error 121 The XML specification is not valid: The ‘count’ attribute is invalid - The value ‘#{BentleyConnectPortal.InstanceCount}’ is invalid according to its datatype ‘http://www.w3.org/2001/XMLSchema:int’ - The string ‘#{BentleyConnectPortal.InstanceCount}’ is not a valid Int32 value. D:\bsisrc_tfs\beconnect\Main\Source\Apps\BentleyConnectPortalAzure\ServiceConfiguration.Cloud.cscfg 4 16 BentleyConnectPortalAzure

How do I fix that?
Thanks

Daniel

Hi Daniel,

Thanks for getting in touch! Since it sounds like MSBuild is rejecting the #{} syntax, the only solution I can think of would be to write a PreDeploy.ps1 PowerShell script that:

  1. Opens the ServiceConfiguration.Cloud.cscfg file as XML
  2. Finds and replaces the count attribute
  3. Saves the file

You can use $OctopusParameters["BentleyConnectPortal.InstanceCount"] in PowerShell to get the value of the variable to use as the replacement.

Hope that helps! Let me know if anything is unclear.

Paul

Hi Paul,

Thanks, for the tip, I was trying to avoid that but this is what I was going to do.

What is happening is that when msbuild creates the cspkg, it follows the rules set in the file Microsoft.WindowsAzure.targets which includes the csdef/cscfg validation. Although that validation can be disabled, you cannot disable the cscfg validation without disabling the csdef validation too. Doing so is disabling the whole csdef against cscfg validation which is not what we want.

Daniel