-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Currently, new projects using SDK build into per-project bin and obj directories. That's good for simple projects that don't participate in CI. For repos that build using CI servers it is often a requirement to produce all outputs under a single root directory with following (or similar) layout:
$(RootOutputPath)\$(Configuration)\bin\$(MSBuildProjectName)
$(RootOutputPath)\$(Configuration)\obj\$(MSBuildProjectName)
$(RootOutputPath)\$(Configuration)\packages
We have seen countless repos with build systems that are customized to do so, each in a different way. Such build customization is usually hard to get right.
I propose to add an out of the box option to the SDK that allows customers to create such repo layouts trivially.
The $(RootOutputPath)
could perhaps be specified via implicit Directory.Build.props
import feature: dotnet/msbuild#222.
Perhaps we could also consider $(RepositoryRootPath)
a well-known property that has a documented meaning. It's a generally useful property to have, imo.
To summarize I propose the user has the option to set the following properties in Directory.Build.props
:
<!-- Default value for configuration is set after Directory.Build.props is imported -->
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<RepositoryRootPath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\'))</RepositoryRootPath>
<RootOutputPath>$(RepositoryRootPath)artifacts\$(Configuration)\bin\</RootOutputPath>
<RootIntermediateOutputPath>$(RepositoryRootPath)artifacts\$(Configuration)\obj\</RootIntermediateOutputPath>
And the SDK uses these variables to set the output paths like so:
<PropertyGroup Condition="'$(RootOutputPath)' != ''" >
<BaseOutputPath Condition="'$(BaseOutputPath)' == ''">$(RootOutputPath)$(MSBuildProjectName)\</BaseOutputPath>
<OutputPath>$(BaseOutputPath)</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(RootIntermediateOutputPath)' != ''" >
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(RootIntermediateOutputPath)$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
</PropertyGroup>