Optimizing Visual Studio solution build - where to put DLL files?

后端 未结 3 1162
礼貌的吻别
礼貌的吻别 2021-01-06 01:49

I found out that build time of C# solution with many projects gets much faster if you don\'t have \"copy local\" enabled everywhere. I did some tests and it seems that (for

相关标签:
3条回答
  • 2021-01-06 02:32

    We retarget the output directory of projects to be ../../Debug (or ../../Release) Our libs are placed in these directories as well.

    We set the reference paths in each project to be the Debug or Release directory accordingly (this setting is persisted in the user files since it is an absolute rather than relative reference)

    We keep project references as project references, All dll references have copy local false and specific version false unless they are system level dlls we know will be in the GAC on all deployed machines.

    This works a treat and manual builds in the IDE mimic scripted builds from the command line (using MSBuild)

    Test projects not for deployment do not direct their output to the centralized Debug|Release directory, they just use the standard default location (and do use copy local to avoid issues with locking)

    The library versions may be changed by the automated build process replacing the dlls in the Debug and Release directories.

    0 讨论(0)
  • 2021-01-06 02:38

    I recommend building to ..\..\Build if your application is spread across solutions. (If you only have one solution, you may consider ..\Build.) Visual studio will, by default, pick up reference files in it's output folder. When building without VS using MSBuild, though, you must add the build folder as a reference path as shown in the example below:

      <Target Name="BuildApp">
        <MSBuild
            Projects="@(ProjectReference)"
            Targets="Rebuild"
            Properties="ReferencePath=..\..\Build;$(LibraryFolder)" >
        </MSBuild>
        <OnError ExecuteTargets="BuildFailed" />
      </Target>
    

    The example also takes me to my second argument. I do not think you should use your build folder as library folder, since this may lead to individual projects erroneously overwriting library assemblies e.g. by using Copy Local. You should have strict control over your library versions, so I suggest you keep this separated. (Developers would need to add this path in VS as a reference path.)

    You may also choose to separate ..\..\Build into ..\..\Release and ..\..\Debug as suggested by ShuggyCoUk.

    0 讨论(0)
  • 2021-01-06 02:54

    I like the top level Bin Lib folder setup that is common in Unix based systems, by the way moving to this type of system will also make your release engineer's life a lot easier as well. Installer Creation is much simplified by only having to pull everyhting out of one folder. Dll's would then go in bin..

    0 讨论(0)
提交回复
热议问题