Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Brian Lacy 28 posts 101 karma points
    Jun 03, 2016 @ 18:25
    Brian Lacy
    0

    configSource not allowed??

    I prefer to separate my appSettings and connectionStrings elements out of my web.config and keep them in separate config files. My customized web.config file replaces the elements with the following:

    <appSettings configSource="config\appSettings.config" />
    <connectionStrings configSource="config\connectionStrings.config" />
    

    However, I discovered that for some reason, when building from source, these are being stripped out and replaced in my modi

    This is defined in web.Template.Debug.config:

    <appSettings xdt:Transform="Remove" xdt:Locator="Condition(@configSource != '')" />
    <appSettings xdt:Transform="InsertIfMissing">
      <add key="umbracoConfigurationStatus" value="" />
      <add key="umbracoReservedUrls" value="~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
      <add key="umbracoReservedPaths" value="~/umbraco,~/install/" />
      <add key="umbracoPath" value="~/umbraco" />
      <add key="umbracoHideTopLevelNodeFromPath" value="true" />
      <add key="umbracoUseDirectoryUrls" value="true" />
      <add key="umbracoTimeOutInMinutes" value="20" />
      <add key="umbracoDefaultUILanguage" value="en" />
      <add key="umbracoUseSSL" value="false" />
      <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
      <add key="webpages:Enabled" value="false" />
      <add key="enableSimpleMembership" value="false" />
      <add key="autoFormsAuthentication" value="false" />
      <add key="log4net.Config" value="config\log4net.config" />
      <add key="owin:appStartup" value="UmbracoDefaultOwinStartup" xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)"  />
    </appSettings>
    
    <connectionStrings xdt:Transform="Remove" xdt:Locator="Condition(@configSource != '')" />
    <connectionStrings xdt:Transform="InsertIfMissing">
      <remove name="umbracoDbDSN" />
      <add name="umbracoDbDSN" connectionString="" providerName="" />
    </connectionStrings>
    

    My questions is -- WHY?

    What is the purpose of explicitly replacing the appSettings and connectionStrings elements with boilerplate code just because they contain a configSource redirect??


    Note:
    For reference and clarification, this all occurs in the first place because of this section in Umbraco.Web.UI.csproj:

    <Target Name="BeforeBuild">
      <!-- Create web.config file from Template if it doesn't exist -->
      <Copy SourceFiles="$(ProjectDir)web.Template.config" DestinationFiles="$(ProjectDir)Web.config" OverwriteReadOnlyFiles="true" SkipUnchangedFiles="false" Condition="!Exists('$(ProjectDir)Web.config')" />
      <!-- Transform the local Web.config file in Visual Studio -->
      <TransformXml Source="$(ProjectDir)Web.config" Transform="$(ProjectDir)web.Template.$(Configuration).config" Destination="$(ProjectDir)Web.$(Configuration).config.transformed" Condition="$(BuildingInsideVisualStudio) == true" />
      <!-- Always transform the Template file when not in VS (ie: build.bat) -->
      <TransformXml Source="$(ProjectDir)Web.Template.config" Transform="$(ProjectDir)web.Template.$(Configuration).config" Destination="Web.$(Configuration).config.transformed" Condition="$(BuildingInsideVisualStudio) != true" />
      <!-- Only runs if the Belle build folder doesn't yet exist -->
      <CallTarget Targets="BelleBuild" Condition="!Exists('$(ProjectDir)\..\Umbraco.Web.UI.Client\build')" />
    </Target>
    <Target Name="AfterBuild">
      <Copy SourceFiles="$(ProjectDir)Web.$(Configuration).config.transformed" DestinationFiles="$(ProjectDir)Web.config" OverwriteReadOnlyFiles="true" SkipUnchangedFiles="false" Condition="$(BuildingInsideVisualStudio) == true" />
    </Target>
    
  • Nik 1599 posts 7179 karma points MVP 6x c-trib
    Jun 03, 2016 @ 22:18
    Nik
    0

    Hi Brian,

    I was wondering if there was a particular reason you are building from source?

    I've move my connection string details into a separate file and have had no issues with either debug or release builds removing that configuration from within my web config.

  • Brian Lacy 28 posts 101 karma points
    Aug 12, 2016 @ 15:51
    Brian Lacy
    0

    I'm troubleshooting a complicated issue and the simplest way to do this is to import my custom project into a solution with the full Umbraco source for better debugging visibility.

    But since I use "configSource" to manage my environment settings separately, I have to comment out those lines in the config template; otherwise, I'd have to fix my web.config every time I build. So I'd just like to understand their purpose for being there in the first place.

  • Damiaan 442 posts 1301 karma points MVP 6x c-trib
    Aug 12, 2016 @ 16:04
    Damiaan
    2

    Hi Brian,

    The reason lies in these lines in the Umbraco.Web.Ui.csproj:

    <Target Name="BeforeBuild">
        <!-- Create web.config file from Template if it doesn't exist -->
        <Copy SourceFiles="$(ProjectDir)web.Template.config" DestinationFiles="$(ProjectDir)Web.config" OverwriteReadOnlyFiles="true" SkipUnchangedFiles="false" Condition="!Exists('$(ProjectDir)Web.config')" />
        <!-- Transform the local Web.config file in Visual Studio -->
        <TransformXml Source="$(ProjectDir)Web.config" Transform="$(ProjectDir)web.Template.$(Configuration).config" Destination="$(ProjectDir)Web.$(Configuration).config.transformed" Condition="$(BuildingInsideVisualStudio) == true" />
        <!-- Always transform the Template file when not in VS (ie: build.bat) -->
        <TransformXml Source="$(ProjectDir)Web.Template.config" Transform="$(ProjectDir)web.Template.$(Configuration).config" Destination="Web.$(Configuration).config.transformed" Condition="$(BuildingInsideVisualStudio) != true" />
        ...
       </Target>
    

    The reason is from the past. Every developer was overwriting the web.config. And they had many different configurations checked in.

    I am pretty sure, if you add an extra "web.template.**.config" file and you add a configuration to your VS solution, you will be a happy man again.

Please Sign in or register to post replies

Write your reply to:

Draft