This post is part of the Advanced MSBuild series.
This will be a comparatively short post.
It is only about how to change the build output folder of a csproj project.
Nevertheless it is warranted because it took me a couple of internet searches to find all the relevant project properties.
Relatively easy to find are the properties BaseIntermediateOutputPath
for the obj
folder and the BaseOutputPath
for the bin
folder.
This is not sufficient though.
Files like project.asset.json
will still end up in the default build folder.
To move those too, we also need to redefine the MSBuildProjectExtensionsPath
property.
To avoid duplicating the new build output path, we define a property for the new build base path first.
Note that we need to be careful to define the directories with trailing directory separator to be in line with MSBuild conventions and expectations.
<PropertyGroup> <__BuildBase>../_Build</__BuildBase> <BaseIntermediateOutputPath>$(__BuildBase)/obj/</BaseIntermediateOutputPath> <BaseOutputPath>$(__BuildBase)/bin/</BaseOutputPath> <MSBuildProjectExtensionsPath>$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath> </PropertyGroup>
That’s already it, happy building.