Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build all projects in one single folder?

Tags:

c#

solution

Is there a way to build solution into a single folder? I have several projects in this solution and each access a config file that should be in the current directory. I just move each project's build files into one and it still works, however, it looks so unorganized and messy. I just want to know it there are other ways on how to do it.

like image 741
user3068522 Avatar asked Dec 06 '13 09:12

user3068522


2 Answers

You can set output directory in the settings of every project in solution (if we are about Visual Studio). Menu: Project -> properties -> Build -> Output path. For example, I use ..\Build\ to build projects into Build directory of solution root.

like image 86
FLCL Avatar answered Nov 15 '22 21:11

FLCL


This MSDN article explains how to do it in a nice, DRY way: https://blogs.msdn.microsoft.com/kirillosenkov/2015/04/04/using-a-common-intermediate-and-output-directory-for-your-solution/

It allows you to specify those directories only once, and use those settings in multiple projects.

Steps:

  1. Create a single common.props file in solution, that will specify and overwrite output and intermediate paths for a project to a common directory (like "Solution/bin"). Here is a sample *.props file that I found linked in the article:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
            <Configuration Condition="$(Configuration) == ''">Debug</Configuration>
            <OutputPath>$(SolutionDir)\bin\$(Configuration)\</OutputPath>
            <OutDir>$(OutputPath)</OutDir>
            <OutDir>$(OutputPath)</OutDir>
            <IntermediateOutputPath>
                $(SolutionDir)\obj\$(Configuration)\$(MSBuildProjectName)\
            </IntermediateOutputPath>
            <UseCommonOutputDirectory>False</UseCommonOutputDirectory>
            <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
        </PropertyGroup>
    </Project>
    
  2. Include this file into every *.csproj that you want to set the common output dirs for, by adding this line (the actual path may differ): <Import Project="..\Common.props" />

like image 43
JSparrow Avatar answered Nov 15 '22 21:11

JSparrow