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

  • Home
  • SEARCH
  • 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 178445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:13:56+00:00 2026-05-11T14:13:56+00:00

I have a large c# solution file (~100 projects), and I am trying to

  • 0

I have a large c# solution file (~100 projects), and I am trying to improve build times. I think that ‘Copy Local’ is wasteful in many cases for us, but I am wondering about best practices.

In our .sln, we have application A depending on assembly B which depends on assembly C. In our case, there are dozens of ‘B’ and a handful of ‘C’. Since these are all included in the .sln, we’re using project references. All assemblies currently build into $(SolutionDir)/Debug (or Release).

By default, Visual Studio marks these project references as ‘Copy Local’, which results in every ‘C’ being copied into $(SolutionDir)/Debug once for every ‘B’ that builds. This seems wasteful. What can go wrong if I just turn ‘Copy Local’ off? What do other people with large systems do?

FOLLOWUP:

Lots of responses suggest breaking up the build into smaller .sln files… In the example above, I would build the foundation classes ‘C’ first, followed by the bulk of the modules ‘B’, and then a few applications, ‘A’. In this model, I need to have non-project references to C from B. The problem I run into there is that ‘Debug’ or ‘Release’ gets baked into the hint path and I wind up building my Release builds of ‘B’ against debug builds of ‘C’.

For those of you that split the build up into multiple .sln files, how do you manage this problem?

  • 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. 2026-05-11T14:13:57+00:00Added an answer on May 11, 2026 at 2:13 pm

    In a previous project I worked with one big solution with project references and bumped into a performance problem as well. The solution was three fold:

    1. Always set the Copy Local property to false and enforce this via a custom msbuild step

    2. Set the output directory for each project to the same directory (preferably relative to $(SolutionDir)

    3. The default cs targets that get shipped with the framework calculate the set of references to be copied to the output directory of the project currently being built. Since this requires calculating a transitive closure under the ‘References’ relation this can become VERY costly. My workaround for this was to redefine the GetCopyToOutputDirectoryItems target in a common targets file (eg. Common.targets ) that’s imported in every project after the import of the Microsoft.CSharp.targets. Resulting in every project file to look like the following:

      <Project DefaultTargets='Build' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>   <PropertyGroup>     ... snip ...   </ItemGroup>   <Import Project='$(MSBuildBinPath)\Microsoft.CSharp.targets' />   <Import Project='[relative path to Common.targets]' />   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.         Other similar extension points exist, see Microsoft.Common.targets.   <Target Name='BeforeBuild'>   </Target>   <Target Name='AfterBuild'>   </Target>   --> </Project> 

    This reduced our build time at a given time from a couple of hours (mostly due to memory constraints), to a couple of minutes.

    The redefined GetCopyToOutputDirectoryItems can be created by copying the lines 2,438–2,450 and 2,474–2,524 from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets into Common.targets.

    For completeness the resulting target definition then becomes:

    <!-- This is a modified version of the Microsoft.Common.targets      version of this target it does not include transitively      referenced projects. Since this leads to enormous memory      consumption and is not needed since we use the single      output directory strategy. ============================================================                     GetCopyToOutputDirectoryItems  Get all project items that may need to be transferred to the output directory. ============================================================ --> <Target     Name='GetCopyToOutputDirectoryItems'     Outputs='@(AllItemsFullPathWithTargetPath)'     DependsOnTargets='AssignTargetPaths;_SplitProjectReferencesByFileExistence'>      <!-- Get items from this project last so that they will be copied last. -->     <CreateItem         Include='@(ContentWithTargetPath->'%(FullPath)')'         Condition=''%(ContentWithTargetPath.CopyToOutputDirectory)'=='Always' or '%(ContentWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest''             >         <Output TaskParameter='Include' ItemName='AllItemsFullPathWithTargetPath'/>         <Output TaskParameter='Include' ItemName='_SourceItemsToCopyToOutputDirectoryAlways'                 Condition=''%(ContentWithTargetPath.CopyToOutputDirectory)'=='Always''/>         <Output TaskParameter='Include' ItemName='_SourceItemsToCopyToOutputDirectory'                 Condition=''%(ContentWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest''/>     </CreateItem>      <CreateItem         Include='@(_EmbeddedResourceWithTargetPath->'%(FullPath)')'         Condition=''%(_EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='Always' or '%(_EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest''             >         <Output TaskParameter='Include' ItemName='AllItemsFullPathWithTargetPath'/>         <Output TaskParameter='Include' ItemName='_SourceItemsToCopyToOutputDirectoryAlways'                 Condition=''%(_EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='Always''/>         <Output TaskParameter='Include' ItemName='_SourceItemsToCopyToOutputDirectory'                 Condition=''%(_EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest''/>     </CreateItem>      <CreateItem         Include='@(Compile->'%(FullPath)')'         Condition=''%(Compile.CopyToOutputDirectory)'=='Always' or '%(Compile.CopyToOutputDirectory)'=='PreserveNewest''>         <Output TaskParameter='Include' ItemName='_CompileItemsToCopy'/>     </CreateItem>     <AssignTargetPath Files='@(_CompileItemsToCopy)' RootFolder='$(MSBuildProjectDirectory)'>         <Output TaskParameter='AssignedFiles' ItemName='_CompileItemsToCopyWithTargetPath' />     </AssignTargetPath>     <CreateItem Include='@(_CompileItemsToCopyWithTargetPath)'>         <Output TaskParameter='Include' ItemName='AllItemsFullPathWithTargetPath'/>         <Output TaskParameter='Include' ItemName='_SourceItemsToCopyToOutputDirectoryAlways'                 Condition=''%(_CompileItemsToCopyWithTargetPath.CopyToOutputDirectory)'=='Always''/>         <Output TaskParameter='Include' ItemName='_SourceItemsToCopyToOutputDirectory'                 Condition=''%(_CompileItemsToCopyWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest''/>     </CreateItem>      <CreateItem         Include='@(_NoneWithTargetPath->'%(FullPath)')'         Condition=''%(_NoneWithTargetPath.CopyToOutputDirectory)'=='Always' or '%(_NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest''             >         <Output TaskParameter='Include' ItemName='AllItemsFullPathWithTargetPath'/>         <Output TaskParameter='Include' ItemName='_SourceItemsToCopyToOutputDirectoryAlways'                 Condition=''%(_NoneWithTargetPath.CopyToOutputDirectory)'=='Always''/>         <Output TaskParameter='Include' ItemName='_SourceItemsToCopyToOutputDirectory'                 Condition=''%(_NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest''/>     </CreateItem> </Target> 

    With this workaround in place I found it workable to have as much as > 120 projects in one solution, this has the main benefit that the build order of the projects can still be determined by VS instead of doing that by hand by splitting up your solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The datacontext of the element needed to be set. XAML:… May 11, 2026 at 4:25 pm
  • Editorial Team
    Editorial Team added an answer To answer your first question, yes Microsoft is a bit… May 11, 2026 at 4:25 pm
  • Editorial Team
    Editorial Team added an answer I'd recommend you use the HTTP tool Fiddler. It'll show… May 11, 2026 at 4:25 pm

Related Questions

I'm working with a small (4 person) development team on a C# project. I've
I have a large solution containing many C# projects. When I open the solution
Where I work, we have a large codebase of C code that we build
Background I work for a large organization which has thousands of MS Access applications

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.