Skip to content

Commit

Permalink
Enable common working directory via 'BuildDir'
Browse files Browse the repository at this point in the history
Work IN Progress
  • Loading branch information
Nirmal4G committed Dec 25, 2020
1 parent 260b1bd commit ab012dc
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,53 @@ Copyright (c) .NET Foundation. All rights reserved.
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!--
Apply the same default output paths as Microsoft.Common.targets now since we're running before them,
but need to adjust them and/or make decisions in terms of them.
Also note that common targets only set a default OutputPath if neither configuration nor
platform were set by the user. This was used to validate that a valid configuration is passed,
assuming the convention maintained by VS that every Configuration|Platform combination had
an explicit OutputPath. Since we now want to support leaner project files with less
duplication and more automatic defaults, we always set a default OutputPath and can no
longer depend on that convention for validation. Getting validation re-enabled with a
different mechanism is tracked by https://github.com/dotnet/sdk/issues/350
The Microsoft.Common.targets now uses the same defaults as here.
-->
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<Platform Condition="'$(Platform)'==''">AnyCPU</Platform>
<PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>

<BaseOutputPath Condition="'$(BaseOutputPath)' == ''">bin\</BaseOutputPath>
<BaseOutputPath Condition="!HasTrailingSlash('$(BaseOutputPath)')">$(BaseOutputPath)\</BaseOutputPath>
<OutputPath Condition="'$(OutputPath)' == '' and '$(PlatformName)' == 'AnyCPU'">$(BaseOutputPath)$(Configuration)\</OutputPath>
<OutputPath Condition="'$(OutputPath)' == '' and '$(PlatformName)' != 'AnyCPU'">$(BaseOutputPath)$(PlatformName)\$(Configuration)\</OutputPath>
<OutputPath Condition="!HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath>

<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">obj\</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition="!HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
<IntermediateOutputPath Condition=" $(IntermediateOutputPath) == '' and '$(PlatformName)' == 'AnyCPU' ">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition=" $(IntermediateOutputPath) == '' and '$(PlatformName)' != 'AnyCPU' ">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition="!HasTrailingSlash('$(IntermediateOutputPath)')">$(IntermediateOutputPath)\</IntermediateOutputPath>
<!-- Initialize BuildDir when empty, to ensure build doesn't produce inconsistent paths -->
<BuildDir>$([MSBuild]::EnsureTrailingSlash($([MSBuild]::ValueOrDefault('$(BuildDir)', 'build'))))</BuildDir>

<BaseOutputPath>$([MSBuild]::EnsureTrailingSlash($([MSBuild]::ValueOrDefault('$(BaseOutputPath)', '$(BuildDir)bin'))))</BaseOutputPath>
<OutputPath Condition="'$(OutputPath)' == '' and '$(PlatformName)' == 'AnyCPU'">$([System.IO.Path]::Combine('$(BaseOutputPath)', '$(Configuration)'))</OutputPath>
<OutputPath Condition="'$(OutputPath)' == '' and '$(PlatformName)' != 'AnyCPU'">$([System.IO.Path]::Combine('$(BaseOutputPath)', '$(PlatformName)', '$(Configuration)'))</OutputPath>
<OutputPath>$([MSBuild]::EnsureTrailingSlash('$(OutputPath)'))</OutputPath>

<BaseIntermediateOutputPath>$([MSBuild]::EnsureTrailingSlash($([MSBuild]::ValueOrDefault('$(BaseIntermediateOutputPath)', '$(BuildDir)obj'))))</BaseIntermediateOutputPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == '' and '$(PlatformName)' == 'AnyCPU'">$([System.IO.Path]::Combine('$(BaseIntermediateOutputPath)', '$(Configuration)'))</IntermediateOutputPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == '' and '$(PlatformName)' != 'AnyCPU'">$([System.IO.Path]::Combine('$(BaseIntermediateOutputPath)', '$(PlatformName)', '$(Configuration)'))</IntermediateOutputPath>
<IntermediateOutputPath>$([MSBuild]::EnsureTrailingSlash('$(IntermediateOutputPath)'))</IntermediateOutputPath>
</PropertyGroup>

<!-- Set PublishDir here, before Microsoft.Common.targets, to avoid a competing default there. -->
<PropertyGroup>
<PublishDirName Condition="'$(PublishDirName)' == ''">publish</PublishDirName>
<PublishDir>$([MSBuild]::EnsureTrailingSlash($([MSBuild]::ValueOrDefault('$(PublishDir)', '$(PublishDirName)'))))</PublishDir>
</PropertyGroup>

<!-- Set DefaultItemExcludes property for items that should be excluded by default from the None, Compile, etc items. -->
<PropertyGroup>
<!-- build folder, by default -->
<DefaultItemExcludes>$(DefaultItemExcludes);$(BuildDir)**</DefaultItemExcludes>
<!-- publish folder, by default -->
<DefaultItemExcludes>$(DefaultItemExcludes);$(PublishDir)**</DefaultItemExcludes>
<!-- bin folder, by default -->
<DefaultItemExcludes>$(DefaultItemExcludes);$(BaseOutputPath)**</DefaultItemExcludes>
<!-- obj folder, by default -->
<DefaultItemExcludes>$(DefaultItemExcludes);$(BaseIntermediateOutputPath)**</DefaultItemExcludes>
</PropertyGroup>

<!--
Exclude files from OutputPath and IntermediateOutputPath only if they are different from their Base* properties.
Use their value before any value is appended later (eg.: TargetFramework, RuntimeIdentifier),
so that if these values are specified in the project file, the specified value will be used for the exclude.
-->
<PropertyGroup>
<DefaultItemExcludes Condition="!$(OutputPath.StartsWith('$(BaseOutputPath)'))">$(DefaultItemExcludes);$(OutputPath)**</DefaultItemExcludes>
<DefaultItemExcludes Condition="!$(IntermediateOutputPath.StartsWith('$(BaseIntermediateOutputPath)'))">$(DefaultItemExcludes);$(IntermediateOutputPath)**</DefaultItemExcludes>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<Target Name="_CheckForEolTargetFrameworks" AfterTargets="_CheckForUnsupportedNETCoreVersion"
Condition="'@(_EolNetCoreTargetFrameworkVersions->AnyHaveMetadataValue('Identity', '$(_TargetFrameworkVersionWithoutV)'))' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(CheckEolTargetFramework)' == 'true'">
<NETSdkWarning ResourceName="TargetFrameworkIsEol"
FormatArguments="$(TargetFramework.ToLowerInvariant());https://aka.ms/dotnet-core-support" />
FormatArguments="$(TargetFramework);https://aka.ms/dotnet-core-support" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,20 @@ Copyright (c) .NET Foundation. All rights reserved.
Configuration-specific PropertyGroup), so in that case we won't append to it by default. -->
<PropertyGroup Condition="'$(UsingNETSdkDefaults)' == 'true'">
<!-- Projects can opt out of having the RID appended to the output path by setting this to false. -->
<AppendRuntimeIdentifierToOutputPath Condition="'$(AppendRuntimeIdentifierToOutputPath)' == ''">true</AppendRuntimeIdentifierToOutputPath>
<AppendRuntimeIdentifierToOutputPath Condition="'$(AppendRuntimeIdentifierToOutputPath)' == ''">false</AppendRuntimeIdentifierToOutputPath>
<AppendRuntimeIdentifierToOutputPath Condition="'$(RuntimeIdentifiers)' != ''">true</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>

<!--
Append $(RuntimeIdentifier) directory to output and intermediate paths to prevent bin clashes between
targets.
Append $(RuntimeIdentifier) directory to publish, output and intermediate paths to prevent bin clashes between targets.
But do not append the implicit default runtime identifier for .NET Framework apps as that would
append a RID the user never mentioned in the path and do so even in the AnyCPU case.
-->
<PropertyGroup Condition="'$(AppendRuntimeIdentifierToOutputPath)' == 'true' and '$(RuntimeIdentifier)' != '' and '$(_UsingDefaultRuntimeIdentifier)' != 'true'">
<IntermediateOutputPath>$(IntermediateOutputPath)$(RuntimeIdentifier)\</IntermediateOutputPath>
<OutputPath>$(OutputPath)$(RuntimeIdentifier)\</OutputPath>
<IntermediateOutputPath>$([MSBuild]::EnsureTrailingSlash('$(IntermediateOutputPath)$(RuntimeIdentifier)')</IntermediateOutputPath>
<OutputPath>$([MSBuild]::EnsureTrailingSlash('$(OutputPath)$(RuntimeIdentifier)')</OutputPath>
<PublishDir>$([MSBuild]::EnsureTrailingSlash('$(PublishDir)$(RuntimeIdentifier)')</PublishDir>
</PropertyGroup>

<UsingTask TaskName="Microsoft.NET.Build.Tasks.GetDefaultPlatformTargetForNetFramework"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<GenerateDependencyFile Condition="'$(GenerateDependencyFile)' == ''">$(PreserveCompilationContext)</GenerateDependencyFile>
</PropertyGroup>

<!-- Set PublishDir here, before Microsoft.Common.targets, to avoid a competing default there. -->
<PropertyGroup>
<PublishDirName Condition="'$(PublishDirName)' == ''">publish</PublishDirName>
<!-- ensure the PublishDir is RID specific-->
<PublishDir Condition="'$(PublishDir)' == '' and
'$(AppendRuntimeIdentifierToOutputPath)' != 'true' and
'$(RuntimeIdentifier)' != '' and
'$(_UsingDefaultRuntimeIdentifier)' != 'true'">$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\</PublishDir>
<PublishDir Condition="'$(PublishDir)' == ''">$(OutputPath)$(PublishDirName)\</PublishDir>
</PropertyGroup>

<!--
Sets RestoreAdditionalProjectSources or RestoreAdditionalProjectFallbackFolders to the SDK Offline Cache based
on the TargetFramework.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<EnableDefaultNoneItems Condition=" '$(EnableDefaultNoneItems)' == '' ">true</EnableDefaultNoneItems>
</PropertyGroup>

<!-- Set DefaultItemExcludes property for items that should be excluded by default from the None, Compile, etc items. -->
<PropertyGroup>
<!-- Set DefaultItemExcludes property for items that should be excluded from the default Compile, etc items.
This is in the .targets because it needs to come after the final BaseOutputPath has been evaluated. -->

<!-- bin folder, by default -->
<DefaultItemExcludes>$(DefaultItemExcludes);$(BaseOutputPath)/**</DefaultItemExcludes>
<!-- obj folder, by default -->
<DefaultItemExcludes>$(DefaultItemExcludes);$(BaseIntermediateOutputPath)/**</DefaultItemExcludes>

<!-- Various files that should generally always be ignored -->
<DefaultItemExcludes>$(DefaultItemExcludes);**/*.user</DefaultItemExcludes>
<DefaultItemExcludes>$(DefaultItemExcludes);**/*.*proj</DefaultItemExcludes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,31 +215,24 @@ Copyright (c) .NET Foundation. All rights reserved.
FormatArguments="$(TargetPlatformVersion);$(TargetPlatformIdentifier);$(_ValidTargetPlatformVersions)" />
</Target>

<!-- Exclude files from OutputPath and IntermediateOutputPath from default item globs. Use the value
of these properties before the TargetFramework is appended, so that if these values are specified
in the project file, the specified value will be used for the exclude. -->
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);$(OutputPath)/**</DefaultItemExcludes>
<DefaultItemExcludes>$(DefaultItemExcludes);$(IntermediateOutputPath)/**</DefaultItemExcludes>
</PropertyGroup>

<!-- Projects which don't use Microsoft.NET.Sdk will typically define the OutputPath directly (usually in a
Configuration-specific PropertyGroup), so in that case we won't append to it by default. -->
<PropertyGroup Condition="'$(UsingNETSdkDefaults)' == 'true'">
<AppendTargetFrameworkToOutputPath Condition="'$(AppendTargetFrameworkToOutputPath)' == ''">true</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath Condition="'$(AppendTargetFrameworkToOutputPath)' == ''">false</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFrameworks)' != ''">true</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<PropertyGroup>
<ProduceReferenceAssembly Condition="'$(ProduceReferenceAssembly)' == '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 5.0))" >true</ProduceReferenceAssembly>
</PropertyGroup>

<!--
Append $(TargetFramework) directory to output and intermediate paths to prevent bin clashes between
targets.
Append $(TargetFramework) directory to publish, output and intermediate paths to prevent bin clashes between targets.
-->
<PropertyGroup Condition="'$(AppendTargetFrameworkToOutputPath)' == 'true' and '$(TargetFramework)' != '' and '$(_UnsupportedTargetFrameworkError)' != 'true'">
<IntermediateOutputPath>$(IntermediateOutputPath)$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath>
<OutputPath>$(OutputPath)$(TargetFramework.ToLowerInvariant())\</OutputPath>
<IntermediateOutputPath>$([MSBuild]::EnsureTrailingSlash('$(IntermediateOutputPath)$(TargetFramework)')</IntermediateOutputPath>
<OutputPath>$([MSBuild]::EnsureTrailingSlash('$(OutputPath)$(TargetFramework)')</OutputPath>
<PublishDir>$([MSBuild]::EnsureTrailingSlash('$(PublishDir)$(TargetFramework)')</PublishDir>
</PropertyGroup>

</Project>

0 comments on commit ab012dc

Please sign in to comment.