我正在尝试用slowcheetah转换Silverlight Applications OutOfBrowser.xml文件,该文件名为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 Project本地安装的名称没有从SLTestApp更改为RenamedApp。
有什么想法吗?
亲切问候
问题是您要替换整个文件,而不仅仅是节点。虽然可以通过SlowCheetah进行,但您必须大量修改替换xml(将根节点的替换更改为SetAttribute,并将所有子节点更改为使用替换转换(。
但在我看来,当您真正想做的只是复制特定的文件时,使用转换似乎有些过头了。
假设在.csproj中,您希望将OutOfBrowserSettings.xml
替换为调试版本的OutOfBrowserSettings.Debug.xml
,将发布版本的OutOfBrowserSettings.Release.xml
。
那么在你的.csproj中应该有
<ItemGroup>
<None Include="PropertiesOutOfBrowserSettings.Debug.xml">
</None>
<None Include="PropertiesOutOfBrowserSettings.Release.xml">
</None>
</ItemGroup>
不要在.csproj中指定OutOfBrowserSettings.xml-我们将在BeforeBuild target:中动态计算它们
<Target Name="BeforeBuild">
<Copy Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " SourceFiles="$(ProjectDir)PropertiesOutOfBrowserSettings.Debug.xml" DestinationFiles="$(ProjectDir)PropertiesOutOfBrowserSettings.xml" ContinueOnError="true" />
<Copy Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " SourceFiles="$(ProjectDir)PropertiesOutOfBrowserSettings.Release.xml" DestinationFiles="$(ProjectDir)PropertiesOutOfBrowserSettings.xml" ContinueOnError="true" />
<ItemGroup>
<Content Include="$(ProjectDir)PropertiesOutOfBrowserSettings.xml" />
</ItemGroup>
</Target>
因此,对于调试版本,复制调试版本,对于发布版本,复制发布版本,并且输出始终包含在Content中(因此也包含在.xap中(。