简体   繁体   中英

Web.config Transform Issue with Azure Project Deployment

I have a .net MVC project that i'm attempting to deploy directly to Azure using the publish settings file. I can publish locally without an issue, however when attempting to publish to Azure, it appears to be trying to transform the web.config files within subfolders (which don't have transforms, and don't need them). I receive the following error:

Transformed Web.config using C:\\Projects\\Git\\Web.Project\\Web.Debug.config into 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): Error : Could not open Source file: Could not find a part of the path 'C:\\Projects\\Git\\Web.Project\\App_Plugins\\PluginName\\Web.config;\\App_Plugins\\PluginName\\Web.config'.

The web.config referenced does exist (I've verified) and this error, as mentioned, is not thrown when publishing to a local folder.

Any suggestions as to why this is occurring and how to fix it?

Edited: Added contents of web.debug file below

<?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>

According to your description, you could go to .net project in visual studio and right click Property on the web.config .

Set your Build Action to Content . This means that there will be no transform on this config, usual configuration is compile.

在此处输入图片说明

i'm attempting to deploy directly to Azure using the publish settings file.

To achieve you requirement, you could refer to import publish settings and deploy to Azure .

Step 1 : Create the publish settings file in azure app service.

Click Get publish profile and save the profile locally. 在此处输入图片说明

Step 2: Import the publish settings in Visual Studio and deploy

在此处输入图片说明

After deploying, you could visit it successfully through browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM