silverlight outofbrowser.xml转换

时间:2014-06-04 09:42:06

标签: xml silverlight transformation slowcheetah

我尝试使用slowcheetah转换Silverlight应用程序OutOfBrowser.xml文件,该文件是unter Projectname \ Properties \。

不幸的是,我只获得消息,表示每个单个Element属性(例如:ShortName)和元素(例如:OutOfBrowserSettings.Blurb)没有架构信息

这就是xml的样子:

<OutOfBrowserSettings ShortName="SLTestApp" EnableGPUAcceleration="True"
                      ShowInstallMenuItem="True">       
    <OutOfBrowserSettings.Blurb>SLTestApp</OutOfBrowserSettings.Blurb>
    <OutOfBrowserSettings.WindowSettings>
        <WindowSettings Title="SLTestApp" />
    </OutOfBrowserSettings.WindowSettings>
    <OutOfBrowserSettings.SecuritySettings>
        <SecuritySettings ElevatedPermissions="Required" />
    </OutOfBrowserSettings.SecuritySettings>
    <OutOfBrowserSettings.Icons />
</OutOfBrowserSettings>

这就是我用于转型的东西。我想替换完整的xml。

<?xml version="1.0" encoding="utf-8" ?>
<OutOfBrowserSettings ShortName="RenamedApp" EnableGPUAcceleration="True"
                  ShowInstallMenuItem="True"
                  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
                  xdt:Transform="Replace">
    <OutOfBrowserSettings.Blurb>RenamedApp</OutOfBrowserSettings.Blurb>
    <OutOfBrowserSettings.WindowSettings>
        <WindowSettings Title="RenamedApp" />
    </OutOfBrowserSettings.WindowSettings>
    <OutOfBrowserSettings.SecuritySettings>
        <SecuritySettings ElevatedPermissions="Required" />
    </OutOfBrowserSettings.SecuritySettings>
    <OutOfBrowserSettings.Icons />
</OutOfBrowserSettings>

什么都没有改变。如果我发布SilverlightApplication.Web项目,则本地安装的名称未从SLTestApp更改为RenamedApp。

有什么想法吗?

亲切的问候

1 个答案:

答案 0 :(得分:0)

问题是你正在寻找替换整个文件 - 而不仅仅是节点/节点。虽然可以通过SlowCheetah,但您必须经常修改替换xml(将根节点替换为SetAttribute并将所有子节点更改为使用替换转换)。

但在我看来,如果你真正想做的就是复制特定文件,那么使用转换就像是一种过度杀伤力。

让我们在您的.csproj中说,您希望将OutOfBrowserSettings.xml替换为调试版OutOfBrowserSettings.Debug.xml,将OutOfBrowserSettings.Release.xml替换为版本。

然后在你的.csproj中应该有

<ItemGroup>
  <None Include="Properties\OutOfBrowserSettings.Debug.xml">
  </None>
  <None Include="Properties\OutOfBrowserSettings.Release.xml">
  </None>
</ItemGroup>

不要在.csproj中指定OutOfBrowserSettings.xml - 我们将在BeforeBuild目标中动态计算它们:

<Target Name="BeforeBuild">
  <Copy Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " SourceFiles="$(ProjectDir)Properties\OutOfBrowserSettings.Debug.xml" DestinationFiles="$(ProjectDir)Properties\OutOfBrowserSettings.xml" ContinueOnError="true" />
  <Copy Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " SourceFiles="$(ProjectDir)Properties\OutOfBrowserSettings.Release.xml" DestinationFiles="$(ProjectDir)Properties\OutOfBrowserSettings.xml" ContinueOnError="true" />
  <ItemGroup>
    <Content Include="$(ProjectDir)Properties\OutOfBrowserSettings.xml" />
  </ItemGroup> 
</Target>

因此,对于Debug版本,将复制调试版本,对于Release版本,将复制发行版本,并且输出始终包含在Content中(因此也在.xap中)。