【发布时间】:2018-12-19 12:22:21
【问题描述】:
我有一个 .net MVC 项目,我正在尝试使用发布设置文件直接部署到 Azure。我可以毫无问题地在本地发布,但是当尝试发布到 Azure 时,它似乎正在尝试转换子文件夹中的 web.config 文件(这些文件没有转换,也不需要它们)。我收到以下错误:
使用 C:\Projects\Git\Web.Project\Web.Debug.config 将 Web.config 转换为 obj\Debug\TransformWebConfig\transformed\Web.config。 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(2311,5):错误:无法打开源文件:找不到路径“C:\Projects\Git\Web.Project\App_Plugins\PluginName\Web.config;\App_Plugins\PluginName\Web.config”的一部分。
引用的web.config 确实存在(我已验证),并且如前所述,发布到本地文件夹时不会引发此错误。
关于为什么会发生这种情况以及如何解决它的任何建议?
已编辑:在下面添加了 web.debug 文件的内容
<?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>
<!--
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>
【问题讨论】:
-
你的 web.debug.config 的内容是什么?里面有什么不应该的吗?
-
@rogerdeuce 主 web.config 的 web.debug.config 只是默认文件。它实际上并没有被使用。其他 web.config(我相信还有两三个其他)都没有调试或发布配置。而且,如果调试配置有问题,为什么本地发布会起作用?
-
我对“在本地发布”感到困惑。您是否将其发布到您控制的开发/UAT 服务器?还是你在本地运行?如果它正在发布,那么无论您在(调试/发布)下发布它的哪个配置,都会检查它的转换文件。如果它在本地运行,我认为不会检查转换。
-
我的意思是我正在使用“发布”但选择“文件夹”选项并发布到我本地计算机上的文件夹。我只是将其作为测试,我的最终目标是发布到 Azure 应用服务。我无法使用应用服务选项来拉取要发布到的应用服务列表,因为该列表永远不会填充(它曾经可以工作,不确定发生了什么变化),所以我使用了 Azure 门户中的发布设置文件和导入那个。
-
我很茫然,没有看到调试配置文件的内容,很难排除。我想知道 Azure 发布设置是否有一些时髦的东西。我还质疑您的公司现在是否阻止了 Azure 所依赖的某些东西,因为您再也看不到下拉列表了。阻止可能会阻止 Azure 找到它要替换的文件......也许。对不起,我没有更多的帮助
标签: c# asp.net asp.net-mvc azure web-deployment