4

XML-Document-Transform を使用して、web.config ファイルをステージング サーバーへの展開用に変換しています。残念ながら、指定どおりに変換されておらず、要素のテキストに空白が追加されています。この空白は、私が使用しているキャッスル ウィンザー構成によって取得され、アプリケーションを爆撃します。

次に例を示します。

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>

出力 web.config:

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

ご覧のとおりserverUrl、変換によって追加の空白が要素に挿入されています。

残念ながら、サービスの に を挿入すると Castle に空白が含まれserverUrlUrl無効な URL が作成されます。

他の誰かがこれに出くわしますか?Microsoft の新しい変換方法を引き続き使用しているが、追加の空白が挿入されないソリューションを得た人はいますか?

IMHO これは変換プロセスのバグですが、Castle はおそらく空白も無視する必要があります。

どうもありがとう、ロブ

4

2 に答える 2

2

これは Visual Studio 2010 SP1 で修正され、Microsoft.Web.Publishing.Tasks.dll および関連する *.target ファイルの問題です。Visual Studio SP1 がインストールされていないが、MsBuild を使用しているビルド サーバーを使用している場合は、これらのファイルをコピーする必要があります。

この問題を解決するには、SP1 がインストールされているマシンのすべてを C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web からビルド サーバーの同じディレクトリにコピーします。

于 2011-12-06T14:49:11.773 に答える
1

この問題はapplicationSettingsにも影響しますが、あなたが提案したように空白をトリミングすることで回避できました。これが私の Settings.cs ファイルです。

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

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

キャッスルに関するあなたの問題の解決にはならないかもしれませんが、他の誰かの助けになるかもしれません!

于 2010-06-25T13:58:56.860 に答える