Deployment error when having .config file which is not valid xml


I’m having error when deploying nuget package of my web application.
Error message i’m getting is the following:
System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

I have found that error goes away when i exclude quartz.config file from root folder of the application. And the thing is that quartz.config is non-xml file and it is used for third-party library Quartz, which i can’t just change to xml.

So is there any option to tell Octopus to exclude certain .config files from being used for variable replacement?
Or is there maybe some kind of special variable to ignore variable replacement errors similar as it’s possible for config transformation errors?

Hi Andris

Thanks for getting in touch.

Sorry you’ve hit this, it’s not one we’ve heard before that I remember.
I think we should probably skip the config file if we can’t parse it and log that it’s been skipped.

I’ve created a GitHub issue here so you can track it, we’ll probably get it out fairly quickly.

In the meantime, one way to get around it would be rename it inside your package and use a script to turn it back into .config after the variable replacements have happened. You can see the order of events here

Sorry it’s not an ideal solution but may help in the short term.

Kind regards


Hi Damian!

Ok, will try to solve that with renaming scripts then for now.

Thank You!


Just one more side note to this. It was very hard to figure out where this error actually comes from because error log didn’t mention anything about parsing error on particular quartz.config, instead it just showed last successful info message which seemed very much like action on which subsequent error occurred.

Transforming 'C:\Octopus\Applications\MyApp.Web\1.0.1056_3\Web.config' using 'C:\Octopus\Applications\MyApp.Web\1.0.1056_3\Web.Release.config'.
System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

But as i discovered later - the error actually did not happen when transforming web.config, but it was thrown on parsing next config file instead. So the investigation would be much much faster if log would tell the exact file on which the parsing error occurred.

Thank You!

Has there been any update on this bug? I am having the same issue.

17:09:39 Error | Exception while replacing configuration-variables in: D:\Octopus\Applications\Automation\PingFederateService\\kp_agent.config

17:09:39 Error | System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

17:09:39 Error | at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)

17:09:39 Error | at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()

17:09:39 Error | at System.Xml.XmlTextReaderImpl.ParseDocumentContent()

17:09:39 Error | at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)

17:09:39 Error | at Calamari.Integration.ConfigurationVariables.ConfigurationVariablesReplacer.ReadXmlDocument(String configurationFilePath) in Y:\work\b1fd300731d5f2fc\source\Calamari\Integration\ConfigurationVariables\ConfigurationVariablesReplacer.cs:line 62

17:09:39 Error | at Calamari.Integration.ConfigurationVariables.ConfigurationVariablesReplacer.ModifyConfigurationFile(String configurationFilePath, VariableDictionary variables) in Y:\work\b1fd300731d5f2fc\source\Calamari\Integration\ConfigurationVariables\ConfigurationVariablesReplacer.cs:line 55

17:09:39 Error | at Calamari.Deployment.Conventions.ConfigurationVariablesConvention.Install(RunningDeployment deployment) in Y:\work\b1fd300731d5f2fc\source\Calamari\Deployment\Conventions\ConfigurationVariablesConvention.cs:line 40

17:09:39 Error | at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Y:\work\b1fd300731d5f2fc\source\Calamari\Deployment\ConventionProcessor.cs:line 60

17:09:39 Error | at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\b1fd300731d5f2fc\source\Calamari\Deployment\ConventionProcessor.cs:line 28

Hi Branden,

We added a new system variable, Octopus.Action.Package.IgnoreVariableReplacementErrors, to stop this error from failing a deployment in #1897, this should at least get you past failed deployments due to these XML transformation errors.

Hope that helps!

Thank you and kind regards,

I’ve added a possible fix inthe comments on the Githubissue page: