Home > other >  Web.config transformation fails on release pipeline with null ref exception
Web.config transformation fails on release pipeline with null ref exception

Time:12-19

Trying to move our web.config transformation from build to release to reuse packages and reduce the amount of builds to run as well pipelines to maintain. This is a asp.net 4.8 project which has run like this for years.

Disabled config transformation in the build pipeline, keeping the other configs and building the generic Release configuration:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\" /p:PrecompileBeforePublish=true /p:UseMerge=true /p:SingleAssemblyName=AppCode /p:TransformWebConfigEnabled=False /p:MarkWebConfigAssistFilesAsExclude=false

Enabled XML Transformation in the stage with name Beta to apply the Web.Beta.config like we did previously during build. enter image description here

This leads to this null ref exception:

2022-12-15T14:36:05.9627529Z [command]C:\agent\_work\_tasks\FileTransform_8ce97e91-56cc-4743-bfab-9a9315be5f27\1.212.0\ctt\ctt.exe s:C:\agent\_work\_temp\...\Web.config t:c:\agent\_work\_temp\...\Web.config pw i verbose
2022-12-15T14:36:06.3615366Z System.NullReferenceException: Object reference not set to an instance of an object.

The config is valid, as it works on the old build pipeline and VS shows me the correct result using the Preview Transform function.

  • Rename the stage to Release and it worked. But Web.Release.config only contains the default which VS generates.
  • Emptied Web.Beta.config as maybe a invalid (?) config could lead to it, still same error.
  • Tried transforming the config using a File Transformation task, same null ref issue.

Really struggling to go ahead as the documentation (or lack thereof) and error message aren't really helping.

Appreciate any pointers

CodePudding user response:

Tried transforming the config using a File Transformation task, same null ref issue.

Did you specify Transformation rules like below?

enter image description here

If you have, please check similar link, check if you have correct syntax defined.

  • Related