【发布时间】:2012-08-23 23:46:11
【问题描述】:
以前有没有人对 resx 文件执行过 xml 转换?我想为每个配置转换一个 resx 文件。每个配置的转换文件可能会替换资源文件中的一些字符串值。例如:
<None Include="Resources\Label.Release.resx.config">
<DependentUpon>Label.resx</DependentUpon>
</None>
<EmbeddedResource Include="Resources\Label.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Label.Designer.cs</LastGenOutput>
</EmbeddedResource>
我正在尝试转换 resx 文件中的一些数据值。 在 Label.Release.resx.cofing 中:
<?xml version="1.0" encoding="utf-8" ?>
<root xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<data name="Title" xml:space="preserve" xdt:Locator="Match(name)">
<value xdt:Tranform="Replace">CEO</value>
</data>
</root>
我尝试在 BeforeBuild 任务中玩这个:
<Target Name="BeforeBuild">
<MakeDir Directories="$(IntermediateOutputPath)\Resources"
Condition="!Exists('$(IntermediateOutputPath)\Resources')"/>
<TransformXml Source="Resources\Label.resx" Transform="Resources\Label.$(Configuration).resx.config" Destination="$(IntermediateOutputPath)\Resources\Label.resx" />
生成 $(IntermediateOutputPath)\Resources 文件夹后的 Label.resx 没有进行任何转换。我也不确定这是否是我将转换结果输出到的位置,因为 Lable.resx 最终应该是一个嵌入式资源。
感谢任何帮助
【问题讨论】:
标签: .net asp.net-mvc-3 resx xdt-transform