Nuget web.config.install.xdt未转换

Nuget web.config.install.xdt未转换,nuget,web.config-transform,Nuget,Web.config Transform,在安装NuGet软件包时,我无法确定如何转换web.config文件。它正在做一些转换,但不是全部 以下是安装NuGet软件包时需要修改的未触及的web.config文件: <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add key="

在安装NuGet软件包时,我无法确定如何转换web.config文件。它正在做一些转换,但不是全部

以下是安装NuGet软件包时需要修改的未触及的web.config文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <authentication mode="None" />  ***** I want this removed *****
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication" />  ***** I want this removed *****
    </modules>
  </system.webServer>
</configuration>

,但它在实际中不起作用


我被难住了。关于如何使这项工作正常进行,有什么建议吗?

以下是成功处理该作业的新web.config.install.xdt的外观:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="SecurityGuardEmailFrom" value="info@email.net" xdt:Transform="Insert" />
    <add key="SecurityGuardEmailSubject" value="Your Password has been reset." xdt:Transform="Insert" />
    <add key="SecurityGuardEmailTemplatePath" value="~/MailerTemplates/ResetPassword.html" xdt:Transform="Insert" />  
  </appSettings>
  <system.web>
    <authentication mode="Forms" xdt:Transform="SetAttributes" />
    <authentication mode="Forms">
      <forms loginUrl="~/SGAccount/Login" timeout="2880" xdt:Transform="Insert" />
    </authentication>
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication" xdt:Transform="Remove" />
    </modules>
  </system.webServer>
</configuration>


我没有尝试删除原始的身份验证元素,而是更改了mode属性,然后插入了forms元素。其余的似乎在正确工作后自行解决。

您编写的转换在webconfigtransformationtester站点中似乎不起作用。它失败,因为第一个定位器正在尝试匹配不存在的name属性。第一个定位器匹配应该是
xdt:locator=“match(mode)”
@MattWard-没错,我在这个示例中犯了一个错误。否则,它应该在测试仪中工作,但在安装Nuget软件包时仍然不工作。我在Visual Studio中使用Nuget 2.8.1时,您的转换似乎很好。@MattWard-hmmm。我有Nuget 2.8.5,只有插入可以工作,没有删除。嗯,我必须考虑一些事情,因为我不能发布这个新版本,直到我得到这个可靠的工作。我正在从localNugetfeed测试它,这就是您测试它的方式吗?顺便说一句,谢谢你的对话。NuGet版本号有两部分:文件版本和产品版本。我在Visual Studio 2013中使用的插件是2.8.50313.46(文件版本),它对应于NuGet 2.8.1(产品版本)。我通过创建一个NuGet包并将其从指向本地目录的包源添加到项目中来测试转换。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="MvcMailer.BaseURL" value="" />
    <add key="SecurityGuardEmailFrom" value="info@email.net" />
    <add key="SecurityGuardEmailSubject" value="Your Password has been reset." />
    <add key="SecurityGuardEmailTemplatePath" value="~/MailerTemplates/ResetPassword.html" />
  </appSettings>
  <system.web>
    <authentication mode="None" />  ***** Not removed when it should be *****
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/SGAccount/Login" timeout="2880" />
    </authentication>
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication" />  ***** Not removed when it should be *****
    </modules>
  </system.webServer>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
    <authentication mode="None" xdt:Transform="Remove" xdt:Locator="Match(mode)" />
    <authentication mode="Forms" xdt:Transform="Insert">
      <forms loginUrl="~/SGAccount/Login" timeout="2880" />
    </authentication>
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication" xdt:Transform="Remove" xdt:Locator="Match(name)" />
    </modules>
  </system.webServer>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="SecurityGuardEmailFrom" value="info@email.net" xdt:Transform="Insert" />
    <add key="SecurityGuardEmailSubject" value="Your Password has been reset." xdt:Transform="Insert" />
    <add key="SecurityGuardEmailTemplatePath" value="~/MailerTemplates/ResetPassword.html" xdt:Transform="Insert" />  
  </appSettings>
  <system.web>
    <authentication mode="Forms" xdt:Transform="SetAttributes" />
    <authentication mode="Forms">
      <forms loginUrl="~/SGAccount/Login" timeout="2880" xdt:Transform="Insert" />
    </authentication>
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication" xdt:Transform="Remove" />
    </modules>
  </system.webServer>
</configuration>