locked
Why does my test publish profile use my release configuration? RRS feed

  • Question

  • Hello,

    I'm have issues with deploying my web.config with the correct appSettings. I'm hoping someone can help me out.

    I'm deploying a web API that logs error messages to a log file on the server. Depending on whether I deploy as 'test' or 'production', the log file path will be different.

    My web.config in development looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    ...
      <appSettings>
    ...
        <add key="LogPath" value="C:\Users\junkm\Source\Repos\RiskAlive3\WebAPI\log.txt"/>
      </appSettings>
    ...
    </configuration>

    I have two transform file: web.Test.config and web.Release.config.

    Here's what web.Test.config looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    ...
      <appSettings>
        <add key="LogPath" value="C:\inetpub\wwwroot\RiskAliveAPI\log.txt" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
      </appSettings>
    ...
    </configuration>

    Here's what web.Release.config looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    ...
      <appSettings>
        <add key="LogPath" value="C:\inetpub\wwwroot\RiskAliveProdAPI\log.txt" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
      </appSettings>
    ...
    </configuration>

    My publish profile is set to use the test configuration, but for some reason, after deploying the web API, it looks like it uses the log path of the release configuration. That is, if I got onto the server and look at web.config, I see this:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    ...
      <appSettings>
    ...
        <add key="LogPath" value="C:\inetpub\wwwroot\RiskAliveProdAPI\log.txt" />
      </appSettings>
    ...
    </configuration>

    Here is my test publish profile:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
    This file is used by the publish/package process of your Web project. You can customize the behavior of this process
    by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. 
    -->
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <WebPublishMethod>MSDeploy</WebPublishMethod>
        <LastUsedBuildConfiguration>Test</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <MSDeployServiceURL>ec2-54-159-229-158.compute-1.amazonaws.com</MSDeployServiceURL>
        <DeployIisAppPath>Default Web Site/RiskAliveAPI</DeployIisAppPath>
        <RemoteSitePhysicalPath />
        <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
        <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
        <EnableMSDeployBackup>True</EnableMSDeployBackup>
        <UserName>***</UserName>
        <_SavePWD>True</_SavePWD>
        <PublishDatabaseSettings>
          <Objects xmlns="">
            <ObjectGroup Name="AuthContext" Order="1" Enabled="False">
              <Destination Path="Data Source=riskalive.czov2x1choqv.us-east-1.rds.amazonaws.com;Initial Catalog=RiskAlive;User ID=riskalive;Password=sql65RiskAlive!;Pooling=False;Application Name=RiskAlive" Name="Data Source=riskalive.czov2x1choqv.us-east-1.rds.amazonaws.com;initial catalog=RiskAlive;Pooling=False;User ID=riskalive;Password=sql65RiskAlive!;MultipleActiveResultSets=True;App=RiskAlive" />
              <Object Type="DbCodeFirst">
                <Source Path="DBContext" DbContext="WebAPI.AuthContext, WebAPI" Origin="Convention" />
              </Object>
            </ObjectGroup>
            <ObjectGroup Name="RiskAliveEntities" Order="2" Enabled="False">
              <Destination Path="Data Source=riskalive.czov2x1choqv.us-east-1.rds.amazonaws.com;Initial Catalog=RiskAlive;User ID=riskalive;Password=sql65RiskAlive!;Pooling=False;Application Name=RiskAlive" Name="Data Source=riskalive.czov2x1choqv.us-east-1.rds.amazonaws.com;initial catalog=RiskAlive;Pooling=False;User ID=riskalive;Password=sql65RiskAlive!;MultipleActiveResultSets=True;App=RiskAlive" />
              <Object Type="DbCodeFirst">
                <Source Path="DBContext" DbContext="ACM.RiskAlive.Core.Data.RiskAliveEntities, ACM.RiskAlive.Core" Origin="Configuration" />
              </Object>
            </ObjectGroup>
          </Objects>
        </PublishDatabaseSettings>
        <ADUsesOwinOrOpenIdConnect>False</ADUsesOwinOrOpenIdConnect>
      </PropertyGroup>
      <ItemGroup>
        <MSDeployParameterValue Include="$(DeployParameterPrefix)AuthContext-Web.config Connection String">
          <ParameterValue>Data Source=riskalive.czov2x1choqv.us-east-1.rds.amazonaws.com;initial catalog=RiskAlive;Pooling=False;User ID=riskalive;Password=sql65RiskAlive!;MultipleActiveResultSets=True;App=RiskAlive</ParameterValue>
        </MSDeployParameterValue>
        <MSDeployParameterValue Include="$(DeployParameterPrefix)RiskAliveEntities-Web.config Connection String">
          <ParameterValue>metadata=res://*/Data.RiskAliveModel.csdl|res://*/Data.RiskAliveModel.ssdl|res://*/Data.RiskAliveModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=riskalive.czov2x1choqv.us-east-1.rds.amazonaws.com;initial catalog=RiskAlive;Pooling=False;User ID=riskalive;Password=sql65RiskAlive!;MultipleActiveResultSets=True;App=RiskAlive"</ParameterValue>
        </MSDeployParameterValue>
      </ItemGroup>
    </Project>

    Please help me understand why the test publish profile is using the release configuration even though I tell it to use the test configuration. Thank you.
    Wednesday, May 10, 2017 9:34 PM

All replies

  • Hi friend,

    Thanks for your post.

    As your issue is more related to Web API developing, I suggest you post your issue on the forum below:

    https://forums.asp.net/1246.aspx/1?Web+API

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Thursday, May 11, 2017 7:03 AM
    • Proposed as answer by Fletch Zhou Saturday, May 13, 2017 12:01 AM
    Thursday, May 11, 2017 7:03 AM