locked
why is my test publish profile using my release configuration RRS feed

  • Question

  • User1642115476 posted

    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:29 PM

Answers

  • User-2057865890 posted

    Hi gib9898_00,

    Check your solution's Configuration Properties.

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 11, 2017 8:29 AM

All replies

  • User-2057865890 posted

    Hi gib9898_00,

    Check your solution's Configuration Properties.

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 11, 2017 8:29 AM
  • User1642115476 posted

    Ah, thanks! That did the trick.

    Thursday, May 11, 2017 5:51 PM