Search code examples
c#gitnugetcsprojbuildpath

Change build destination without touching csproj file


I have added a 3rd party project to my solution, which i have forked from github.

I'll do often changes in this repo which i pull-request back to orig repository.

How can i modify build destination of this project, building to ..\..\bin\Debug instead of bin\Debug without modifying the csproj file.

I am trying to avoid stashing the csproj every time while pushing changes.

Answer, based on JakeSays input

//Filename - *.csproj.user
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <OutputPath>..\..\..\bin\Debug\</OutputPath>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    <OutputPath>..\..\..\bin\Debug\</OutputPath>
  </PropertyGroup>
</Project>

This outputpaths will be used instead of the orig OutputPath entry


Solution

  • The changes should be made outside of the .csproj file. I suggest placing a .csproj.user file next to the project file, and overriding the output path in it.

    You can then add the .user file to gitignore (if it isn't already)