While doing deployment to different environments of Sitefinity website I faced issue with transformation configuration file.
I have the following custom configuration file, which is custom configuration section in DataConfig.config
One of the requirements was to deploy application to different environments, such as DEV, UAT, PROD… and modify configuraition parameters for environment, such as connection string…
Also as part of configuraiton file transformation I have to add site deployment Id (incrementalGuidRange="1") in the root element dataConfig of xml configuration file.
The connection string is easy, but modification of root element was not possible, every time I tried to add attribute to root element I got “Object reference not set to an instance of an object.” exception. I used the foolowing transformation file
the parameter incrementalGuidRange="2" in the root element dataConfig was the reason why I get null reference exception.
Googling and asking questions on stackoverflow did not helped, the only solution I found is use xdt:Transform=”Replace” which worked on root element, but have some limitations, such as if the number of attributes I have to set more then one it failed, also all attributes from original config file were removed during the transformation.
But after trying different approaches I finally found a solution how to transform configuration file and add my attribute in the root of the file. I have to add my parameters in the original untransformed config file. So my orignal file should look like:
incrementalGuidRange="0" in the root element solved my problem.