我正在为我的Web应用程序使用Meleze.Web库,我想仅在发布版本上添加压缩。
我尝试进行web.config转换但是在Web.Release.config文件中,当我尝试做
<configuration>
<system.web.webPages.razor>
<host xdt:Transform="Replace" factoryType="Meleze.Web.Razor.MinifyHtmlWebRazorHostFactory, Meleze.Web, Version=1.4.0.3, Culture=neutral, PublicKeyToken=0a868b5321967eda" />
</system.web.webPages.razor>
</configuration>
给我一个错误,说明:未声明变换。任何帮助,将不胜感激。请注意,这是Views文件夹中的Web.Config。
答案 0 :(得分:0)
您可以使用以下Web.Release.config文件来转换Web.config文件。
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web.webPages.razor>
<host factoryType="Meleze.Web.Razor.MinifyHtmlWebRazorHostFactory, Meleze.Web, Version=1.4.0.6, Culture=neutral, PublicKeyToken=0a868b5321967eda" xdt:Transform="Replace" />
</system.web.webPages.razor>
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
答案 1 :(得分:-1)
对我而言,它的工作非常完美。我遵循的步骤如下:
PM> Install-Package Meleze.Web
View/Web.config
并将<host...../>
内的<system.web.webPages.razor>
行替换为<host factoryType="Meleze.Web.Razor.MinifyHtmlWebRazorHostFactory, Meleze.Web, Version=1.4.0.3, Culture=neutral, PublicKeyToken=0a868b5321967eda" />
这就是我所做的一切。顺便说一下,我正在使用MVC 4.