2
votes

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>
1
what are the contents of your web.debug.config? Is there something in there that shouldn't be?rogerdeuce
@rogerdeuce the web.debug.config for the main web.config is simply the default file. It's not actually being used. None of the other web.configs (I believe there is two or three others) have a debug or release config. And, if there were an issue with the debug config, why would publishing locally work?Stephanie J.
I am confused about "Publishing Locally". Are you publishing it to a development/UAT server that is you control? Or are you running it locally? If it's being published, then whichever configuration you are publishing it under (Debug/Release), checks it's transform file. If it's running locally, I do not believe the transforms are checked.rogerdeuce
I mean i'm using "Publish" but selecting the Folder option and publishing to a folder on my local machine. I just did that as a test, my end goal is to publish to the Azure App Service. I can't use the App Service option that pulls the list of app services to publish to, as the list never populates (it used to work, not sure what has changed), so I used the publish settings file from the Azure portal and import that.Stephanie J.
I'm at a loss, without seeing the contents of the debug config file, it's hard to rule that out. I wonder if the Azure publish setting have something funky. I also question if your company is now blocking something that Azure relies on, since you cannot see the drop down anymore. Blocking could potentially prevent Azure from finding the file it's looking to replace on its side... Maybe. Sorry I'm not more helprogerdeuce

1 Answers

0
votes

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.

enter image description here

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. enter image description here

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

enter image description here

After deploying, you could visit it successfully through browser.