2
votes

Visual Studio Team Services - Build & Release

In the release definition, under File Transforms & Variable Substitution Options, there are XML transformation, and XML variable substitution.

I checked both checkboxes, but after deployment, nothing in my Web.Dev.config replaces web.config. The transformation doesn't happen at all.

What is the problem?

--------edit: detail---------

build

all the settings here is default.

enter image description here

release

enter image description here

web.dev.config

This transformation works fine if I deploy from visual studio 2015.

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Server=tcp:xxxx.database.windows.net,1433;Database=xxxx;User ID=xxx@xxx;Password=xxxx;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"  providerName="System.Data.SqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    <add name="NicoContext" connectionString="metadata=res://*/Nico.csdl|res://*/Nico.ssdl|res://*/Nico.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:xxxx.database.windows.net,1433;initial catalog=xxxx;User Id=xxxx@xxxx;Password=xxxx;App=EntityFramework&quot;" providerName="System.Data.EntityClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
  </connectionStrings>
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>
  <appSettings>
    <add key="Environment" value="Dev" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
    <add key="AzureStorageContainerName" value="xxx" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
    <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx;EndpointSuffix=core.windows.net"  xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
    <add key="FacebookLoginAppId" value="xxx"   xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
    <add key="FacebookLoginAppSecret" value="xxx"   xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
  </appSettings>
</configuration>

enter image description here

--------edit 2: no longer work ---------

I did as the solution suggested on a new project in another Azure account, but this time it didn't work. For build, I choose template "Asp.net (preview)", for release, I choose template "Azure App Service Deployment".

enter image description here

enter image description here

--------edit 3: Release - Package or folder ---------

enter image description here

1
What's task you used? Do you use Azure App Service Deploy task? What's the detail log? You can share detail log on the OneDrive.starian chen-MSFT
What's the detail code of your web.config and web.dev.config?starian chen-MSFT
Thanks, please check my edited post.martial

1 Answers

4
votes

You have already deployed/published the web app, so the web.config has already been transformed (For web package deployment, the related values in web.config will be updated during web deploy, the values are in parameters.xml).

So, there isn’t other config files (e..g web.dev.config, web.release.config) in published folder and check XML transformation and XML variable substitution is useless.

Based on the build log, the web app build with release configuration, but there isn’t web.release.config, so there isn’t update for web.config.

You can refer to these steps to achieve your requirement:

  1. Publish/deploy the web app with File System way (e.g. /p:WebPublishMethod=FileSystem /p:publishUrl= $(build.artifactstagingdirectory)\)
  2. Add Copy file step copy others config files (web.dev.config, web.prod.config etc) to the published folder (artifact directory)
  3. Add Publish Build Artifacts
  4. For release, uncheck Publish using Web Deploy option and specify $(System.DefaultWorkingDirectory) to Package or folder.