2016年2月13日土曜日

objフォルダの位置を移動させる。

objフォルダの位置の変更はGUIでは設定できないので、直接メモ帳などでプロジェクトファイル(.csproj)を修正する。

以下のようにBaseIntermediateOutputPath、IntermediateOutputPathを追加する。(DebugとReleaseで出力先を分けない場合は赤字のBaseIntermediateOutputPathだけでOK)

赤字を追加するとソリューションフォルダの1つ外に「obj\プロジェクト名\Debug\」にobjフォルダが作成されるようになる。(objフォルダはビルド後は不要なので他のソリューションも含めて一か所にまとめてたまに消す。ソリューションフォルダの外に出すことでバージョン管理の対象から外れる。)

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <OutputType>Library</OutputType>
    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
    <BaseIntermediateOutputPath>..\..\obj\$(SolutionName)\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>..\bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>none</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>..\bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>



Visual Studio 2010の場合は、各プロジェクトの下に「プロジェクトフォルダ\obj\Debug\TempPE」の空のフォルダが作られてしまう。。。。Visual Studio 2012では作られないらしい。


参考

.NETプロジェクト(C#)でobjフォルダパスを変更する方法
http://www.ah-2.com/2013/11/14/dotnet_csharp_objpath.html

Move intermediates directory on C# projects in Visual Studio
http://stackoverflow.com/questions/815056/move-intermediates-directory-on-c-sharp-projects-in-visual-studio

Visual Studioのプロジェクトで最初にやる設定
http://memomo2.blogspot.jp/2016/02/visual-studio.html

0 件のコメント:

コメントを投稿