msbuildtasks icon indicating copy to clipboard operation
msbuildtasks copied to clipboard

Allow empty values in XMLUpdate

Open abgivant opened this issue 10 years ago • 2 comments

When trying to use XMLUpdate with an empty value, I receive the following errors: [path-to-file]\build.msbuild(55,5): error : Value cannot be null.\r [path-to-file]\build.msbuild(55,5): error : Parameter name: value

This is happening because I am using XMLUpdate to create environment-specific config files, and in some environments the values of a couple XML nodes are empty, leading to this error (see the example below).

This is something that didn't happen in earlier versions, so I'm wondering if a null check was removed from the implementation of XMLUpdate. And if that's the case, is there any reason it can't be restored?

Example:

<OccasionalyEmptyEnvValue></OccasionalyEmptyEnvValue>

<XmlUpdate
    XmlFileName="$(DestinationConfig)"
    XPath="//settings/setting[@key='EnvironmentConfigValue']/@value"
    Value="$(OccasionalyEmptyEnvValue)" />

abgivant avatar Aug 24 '15 18:08 abgivant

I could really use this so that I can set the runtime section of web configuration files to blank. The way I worked around it is by setting the value to a line break for my element. Unfortunately if I use delete on the contents of the runtime element it will produce a and msbuild will not regenerate it using GenerateBindingRedirects.

maxinfet avatar May 09 '19 11:05 maxinfet

Hey, I try to set value='%20' in XmlUpdate section, and it works. It shows value=" " in the file.

zhan9san avatar Aug 21 '19 07:08 zhan9san