Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:00:51+00:00 2026-05-22T03:00:51+00:00

When adding an Application Configuration file to a .Net project in Visual Studio it

  • 0

When adding an Application Configuration file to a .Net project in Visual Studio it will be named app.config and will be renamed (on build) to ApplicationName.config.

I have a solution with about 40 projects. I want to add log4net functionality to quite a few of them. So for every project I would add a file app.log4net. I would then declare a post-build event like this:

copy $(ProjectDir)app.log4net $(TargetPath).log4net

That works just fine. But I was wondering whether there was a built-in way to achieve the same without an explicit post-build event.

Edit: While I like both solutions proposed by JaredPar and Simon Mourier, they don’t provide what I was hoping for. Having a custom tool or MsBuild rule for this makes it less transparent (for other programmers on the project) or at least more complicated than using the post-build event I am currently using. Nevertheless, I feel like MsBuild would be the correct place to solve similar issues.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:00:52+00:00Added an answer on May 22, 2026 at 3:00 am

    In this case it’s not Visual Studio which is updating the name of app.config but instead it’s a core MSBuild rule which is independent of Visual Studio. If you want to emulate the app.config model this is the approach you should take

    The two parts of the build sequence which control the copying of app.config are found in Microsoft.Common.targets.

    First the name of the file is calculated

    <ItemGroup>
        <AppConfigWithTargetPath Include="$(AppConfig)" Condition="'$(AppConfig)'!=''">
            <TargetPath>$(TargetFileName).config</TargetPath>
        </AppConfigWithTargetPath>
    </ItemGroup>
    

    Next it is actually copied as a part of the build

    <Target
        Name="_CopyAppConfigFile"
        Condition=" '@(AppConfigWithTargetPath)' != '' "
        Inputs="@(AppConfigWithTargetPath)"
        Outputs="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')">
    
        <!--
        Copy the application's .config file, if any.
        Not using SkipUnchangedFiles="true" because the application may want to change
        the app.config and not have an incremental build replace it.
        -->
        <Copy
            SourceFiles="@(AppConfigWithTargetPath)"
            DestinationFiles="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')"
            OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
            Retries="$(CopyRetryCount)"
            RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
            UseHardlinksIfPossible="$(CreateHardLinksForAdditionalFilesIfPossible)"
            >
    
            <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
    
        </Copy>
    
    </Target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Visual Studio Web application project I am adding a reference to a
I'm looking for a way to edit a configuration file (web.config in an asp.net
Much to my annoyance, Visual Studio 2010 added App.config files to all of my
I've created an Console application project then add new App.conf file into my project.
I tried adding namespaces to configuration/system.web/pages/namespaces in the web.config of my ASP.NET MVC 3
Aloha I'm referencing an external webservice in my .NET 2.0 application. Adding a service
When adding a DLL as a reference to an ASP.Net project, VS2008 adds several
If I set <compilation targetFramework=4.0> in web.config, Visual Studio 2010 shows all Linq extension
I have an application with a configuration file which has a lots of environment-specific
I was trying to add some configuration in web.config file after the web page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.