none
web.config not app.config being published to xxx.dll.config

    Question

  • I have an ASP.NET project that outputs a class library as a dll which is then deployed to IIS. Per standard builds a config file is also output along with the dll as xxx.dll.config and it contains many useful environment variables such as connection strings (i.e. it conforms to the application settings architecture requirements).

    In VS 2012 the contents of xxx.dll.config file were sourced from app.config in the project root directory.

    In VS 2015 it appears xxx.dll.config's contents are instead sourced from web.config in the project root directory.

    This is causing me a bit of a headache as I was relying on app.config to hold variables (connection strings,  auth providers) for my functional tests while web.config held variables for deployed code.

    Most of the reading I've done on AppDomains and their configuration variables seems to indicate that web.config shouldn't factor into the build output unless explicitly instructed and even then it isn't exactly easy to transform a web.config file, nevermind have it end up as the xxx.dll.config file.

    Any thoughts you may have on why the apparent behaviour change and what I could do about it would be appreciated. I am trying to avoid having to create my own application settings subclasses for tests.



    Wednesday, August 17, 2016 4:10 AM

Answers

  • Hi LennysComb,

    According to your description, I tested in both of my Visual Studio 2012 and Visual Studio 2015 and I get the same result.

    As far as I know, in ASP.NET application, we often use Web.config to hold variables such as connection string, auth providers and so on. And if we host the web application on IIS, we also choose Web.config.

    And I think the action in Visual Studio 2015 is applicable. In Visual Studio 2012, I think there has any issue when build ASP.NET application. I have submit this issue to product team. Please vote and add your comments for this feedback. I think the product team will response this issue as soon as possible.

    https://connect.microsoft.com/VisualStudio/feedback/details/3060127

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 18, 2016 6:02 AM
    Moderator
  • To restore the original behaviour of Visual Studio 2015 back to what I was accustomed to in Visual Studio 2012 I added a post build event:

    1. Go to Project-> Properties
    2. Select Build Events
    3. Add the following to the "Post-build event command line" :

      copy /Y "$(ProjectDir)\App.config" "$(TargetDir)\$(TargetName).dll.config"

    The .dll.config is now once again the App.config instead of Web.config

    Monday, September 5, 2016 1:53 PM

All replies

  • Hi LennysComb,

    According to your description, I tested in both of my Visual Studio 2012 and Visual Studio 2015 and I get the same result.

    As far as I know, in ASP.NET application, we often use Web.config to hold variables such as connection string, auth providers and so on. And if we host the web application on IIS, we also choose Web.config.

    And I think the action in Visual Studio 2015 is applicable. In Visual Studio 2012, I think there has any issue when build ASP.NET application. I have submit this issue to product team. Please vote and add your comments for this feedback. I think the product team will response this issue as soon as possible.

    https://connect.microsoft.com/VisualStudio/feedback/details/3060127

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 18, 2016 6:02 AM
    Moderator
  • To restore the original behaviour of Visual Studio 2015 back to what I was accustomed to in Visual Studio 2012 I added a post build event:

    1. Go to Project-> Properties
    2. Select Build Events
    3. Add the following to the "Post-build event command line" :

      copy /Y "$(ProjectDir)\App.config" "$(TargetDir)\$(TargetName).dll.config"

    The .dll.config is now once again the App.config instead of Web.config

    Monday, September 5, 2016 1:53 PM