Using Microsoft xml document conversion to convert web.config adds unwanted spaces

I am using XML-Document-Transform to convert my web.config file for deployment to an intermediate server. Unfortunately, it does not convert exactly as indicated, and adds some spaces to the element text. This gap is then captured by the Castle Windsor configuration, which I use and bombard the application.

Here is an example:

web.config:

<configuration>
  <castle>
    <properties>
      <serverUrl>http://test</serverUrl>
    <properties>
    <components>
      <component id="MyService">
        <parameters>
          <Url>#{serverUrl}/MyService.asmx</Url>
        </parameters>
      </component>
    </components>
  <castle>
<configuration>

web.staging.config:

<configuration>
  <castle>
    <properties>
      <serverUrl xdt:Transform="Replace">http://staging</serverUrl>
    <properties>
  <castle>
<configuration>

Output web.config file:

<configuration>
  <castle>
    <properties>
      <serverUrl>http://staging
      </serverUrl>
    <properties>
    <components>
      <component id="MyService">
        <parameters>
          <Url>#{serverUrl}/MyService.asmx</Url>
        </parameters>
      </component>
    </components>
  <castle>
<configuration>

As you can see, extra spaces were inserted into the element serverUrlby conversion.

Unfortunately, Castle includes spaces when pasting serverUrlinto Urlservices, which creates an invalid URL.

- ? - , - Microsoft, ?

IMHO , , , .

,

+3
2

Visual Studio 2010 1 (SP1) Microsoft.Web.Publishing.Tasks.dll *.target . , Visual Studio SP1, MsBuild, , .

, 1 (SP1) C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web .

+2

applicationSettings, , , . Settings.cs.

internal sealed partial class Settings
{
    public override object this[string propertyName]
    {
        get
        {
            // trim the value if it a string
            string value = base[propertyName] as string;
            if (value != null)
            {
                return value.Trim();
            }

            return base[propertyName];
        }
        set { base[propertyName] = value; }
    }
}

, Castle, , , - !

+1

Source: https://habr.com/ru/post/1747399/


All Articles