Skip to content

Commit f017723

Browse files
authored
Add custom props imports around DB.props import Fixes #36749 (#36777)
2 parents 10d1f1c + da2d559 commit f017723

File tree

2 files changed

+36
-47
lines changed

2 files changed

+36
-47
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.props

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,54 +37,8 @@ Copyright (c) .NET Foundation. All rights reserved.
3737
Similar to the property above, it must be set here.
3838
-->
3939
<UsingNETSdkDefaults>true</UsingNETSdkDefaults>
40-
</PropertyGroup>
41-
42-
43-
44-
<!-- We need to put the UseArtifactsOutput logic after the import of Directory.Build.props, but before the MSBuild Project Extensions .props import.
45-
However, both of these things happen in Microsoft.Common.props with no opportunity to insert logic in between them.
46-
47-
So what we do here is duplicate the Directory.Build.props import logic from Microsoft.Common.props, and then set ImportDirectoryBuildProps to
48-
false so that it doesn't get imported twice.
49-
50-
Alternatively, we could add a hook in MSBuild to define a file to import at the right location, to avoid duplicating the logic here.
51-
-->
52-
<PropertyGroup>
53-
<ImportDirectoryBuildProps Condition="'$(ImportDirectoryBuildProps)' == ''">true</ImportDirectoryBuildProps>
54-
</PropertyGroup>
55-
<PropertyGroup Condition="'$(ImportDirectoryBuildProps)' == 'true' and '$(DirectoryBuildPropsPath)' == ''">
56-
<_DirectoryBuildPropsFile Condition="'$(_DirectoryBuildPropsFile)' == ''">Directory.Build.props</_DirectoryBuildPropsFile>
57-
<_DirectoryBuildPropsBasePath Condition="'$(_DirectoryBuildPropsBasePath)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), '$(_DirectoryBuildPropsFile)'))</_DirectoryBuildPropsBasePath>
58-
<DirectoryBuildPropsPath Condition="'$(_DirectoryBuildPropsBasePath)' != '' and '$(_DirectoryBuildPropsFile)' != ''">$([System.IO.Path]::Combine('$(_DirectoryBuildPropsBasePath)', '$(_DirectoryBuildPropsFile)'))</DirectoryBuildPropsPath>
59-
</PropertyGroup>
60-
61-
<Import Project="$(DirectoryBuildPropsPath)" Condition="'$(ImportDirectoryBuildProps)' == 'true' and exists('$(DirectoryBuildPropsPath)')"/>
62-
63-
<PropertyGroup>
64-
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
65-
</PropertyGroup>
66-
67-
<!-- If ArtifactsPath or UseArtifactsOutput are set, then import .props to set ArtifactsPath here, so that BaseIntermediateOutputPath can be
68-
set in the ArtifactsPath.
69-
If the .props file is not imported here, it will be imported from Microsoft.NET.DefaultOutputPaths.targets, so that artifacts output
70-
properties can be set directly in the project file too (only in that case they won't affect the intermediate output). -->
71-
<Import Project="$(MSBuildThisFileDirectory)..\targets\Microsoft.NET.DefaultArtifactsPath.props"
72-
Condition="'$(UseArtifactsOutput)' == 'true' Or '$(ArtifactsPath)' != ''"/>
73-
74-
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
75-
<UseArtifactsIntermediateOutput Condition="'$(UseArtifactsIntermediateOutput)' == ''">true</UseArtifactsIntermediateOutput>
76-
<ArtifactsProjectName Condition="'$(ArtifactsProjectName)' == ''">$(MSBuildProjectName)</ArtifactsProjectName>
77-
</PropertyGroup>
78-
79-
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(BaseIntermediateOutputPath)' == '' And '$(UseArtifactsIntermediateOutput)' == 'true'">
80-
<BaseIntermediateOutputPath Condition="'$(IncludeProjectNameInArtifactsPaths)' == 'true'">$(ArtifactsPath)\obj\$(ArtifactsProjectName)\</BaseIntermediateOutputPath>
81-
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(ArtifactsPath)\obj\</BaseIntermediateOutputPath>
82-
</PropertyGroup>
8340

84-
<!-- Record whether ArtifactsPath / UseArtifactsOutput was set at this point in evaluation. We will generate an error if these properties are set
85-
after this point (ie in the project file). -->
86-
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
87-
<_ArtifactsPathSetEarly>true</_ArtifactsPathSetEarly>
41+
<CustomAfterDirectoryBuildProps>$(CustomAfterDirectoryBuildProps);$(MSBuildThisFileDirectory)UseArtifactsOutputPath.props</CustomAfterDirectoryBuildProps>
8842
</PropertyGroup>
8943

9044
<PropertyGroup Condition="'$(MSBuildProjectFullPath)' == '$(ProjectToOverrideProjectExtensionsPath)'">
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
***********************************************************************************************
3+
UseArtifactsOutputPath.props
4+
5+
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
6+
created a backup copy. Incorrect changes to this file will make it
7+
impossible to load or build your projects from the command-line or the IDE.
8+
9+
Copyright (c) .NET Foundation. All rights reserved.
10+
***********************************************************************************************
11+
-->
12+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
13+
<!-- If ArtifactsPath or UseArtifactsOutput are set, then import .props to set ArtifactsPath here, so that BaseIntermediateOutputPath can be
14+
set in the ArtifactsPath.
15+
If the .props file is not imported here, it will be imported from Microsoft.NET.DefaultOutputPaths.targets, so that artifacts output
16+
properties can be set directly in the project file too (only in that case they won't affect the intermediate output). -->
17+
<Import Project="$(MSBuildThisFileDirectory)..\targets\Microsoft.NET.DefaultArtifactsPath.props"
18+
Condition="'$(UseArtifactsOutput)' == 'true' Or '$(ArtifactsPath)' != ''"/>
19+
20+
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
21+
<UseArtifactsIntermediateOutput Condition="'$(UseArtifactsIntermediateOutput)' == ''">true</UseArtifactsIntermediateOutput>
22+
<ArtifactsProjectName Condition="'$(ArtifactsProjectName)' == ''">$(MSBuildProjectName)</ArtifactsProjectName>
23+
</PropertyGroup>
24+
25+
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(BaseIntermediateOutputPath)' == '' And '$(UseArtifactsIntermediateOutput)' == 'true'">
26+
<BaseIntermediateOutputPath Condition="'$(IncludeProjectNameInArtifactsPaths)' == 'true'">$(ArtifactsPath)\obj\$(ArtifactsProjectName)\</BaseIntermediateOutputPath>
27+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(ArtifactsPath)\obj\</BaseIntermediateOutputPath>
28+
</PropertyGroup>
29+
30+
<!-- Record whether ArtifactsPath / UseArtifactsOutput was set at this point in evaluation. We will generate an error if these properties are set
31+
after this point (ie in the project file). -->
32+
<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true'">
33+
<_ArtifactsPathSetEarly>true</_ArtifactsPathSetEarly>
34+
</PropertyGroup>
35+
</Project>

0 commit comments

Comments
 (0)