@@ -25,46 +25,95 @@ Copyright (c) .NET Foundation. All rights reserved.
25
25
<AppendTargetFrameworkToOutputPath Condition =" '$(AppendTargetFrameworkToOutputPath)' == ''" >true</AppendTargetFrameworkToOutputPath >
26
26
</PropertyGroup >
27
27
28
- <!-- NOTE: If we want to default UseStandardOutputPaths to true when targeting a given version of .NET or higher, this is where we would do it.
28
+ <!-- NOTE: If we want to default UseArtifactsOutput to true when targeting a given version of .NET or higher, this is where we would do it.
29
29
30
30
It would look something like this:
31
31
32
- <PropertyGroup Condition="'$(UseStandardOutputPaths )' == '' and
32
+ <PropertyGroup Condition="'$(UseArtifactsOutput )' == '' and
33
33
'$(TargetFrameworks)' == '' and
34
34
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
35
35
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), 8.0))">
36
- <UseStandardOutputPaths >true</UseStandardOutputPaths >
36
+ <UseArtifactsOutput >true</UseArtifactsOutput >
37
37
</PropertyGroup>
38
38
-->
39
39
40
- <!-- Handle RootOutputPath and if it wasn't set in Sdk.props -->
41
- <PropertyGroup Condition =" '$(RootOutputPath)' != ''" >
42
- <UseStandardOutputPaths Condition =" '$(UseStandardOutputPaths)' == ''" >true</UseStandardOutputPaths >
43
- <BaseStandardOutputPath Condition =" '$(BaseStandardOutputPath)' == ''" >$(RootOutputPath)</BaseStandardOutputPath >
40
+ <!-- Handle ArtifactsPath if it wasn't set in Sdk.props -->
41
+ <PropertyGroup Condition =" '$(ArtifactsPath)' != ''" >
42
+ <UseArtifactsOutput Condition =" '$(UseArtifactsOutput)' == ''" >true</UseArtifactsOutput >
44
43
</PropertyGroup >
45
44
46
- <!-- Set BaseOutputPath for standard output format if it wasn't set in Sdk.props -->
47
- <PropertyGroup Condition =" '$(UseStandardOutputPaths)' == 'true' And '$(BaseOutputPath)' == ''" >
48
- <BaseStandardOutputPath Condition =" '$(BaseStandardOutputPath)' == ''" >bin\</BaseStandardOutputPath >
49
- <BaseStandardOutputPath >$([MSBuild]::EnsureTrailingSlash($(BaseStandardOutputPath)))</BaseStandardOutputPath >
45
+ <!-- Repeat ArtifactsPath logic from Sdk.props here, in case UseArtifactsOutput was set in the project file -->
46
+ <PropertyGroup Condition =" '$(UseArtifactsOutput)' == 'true' And '$(ArtifactsPath)' == '' And '$(_DirectoryBuildPropsBasePath)' != ''" >
47
+ <!-- Default ArtifactsPath to be in the directory where Directory.Build.props is found
48
+ Note that we do not append a backslash to the ArtifactsPath as we do with most paths, because it may be a global property passed in on the command-line which we can't easily change -->
49
+ <ArtifactsPath >$(_DirectoryBuildPropsBasePath)\.artifacts</ArtifactsPath >
50
+ <IncludeProjectNameInArtifactsPaths Condition =" '$(IncludeProjectNameInArtifactsPaths)' == ''" >true</IncludeProjectNameInArtifactsPaths >
51
+ </PropertyGroup >
52
+
53
+ <PropertyGroup Condition =" '$(UseArtifactsOutput)' == 'true' And '$(ArtifactsPath)' == ''" >
54
+ <!-- If there was no Directory.Build.props file, then put the artifacts path in the project folder -->
55
+ <ArtifactsPath >$(MSBuildProjectDirectory)\.artifacts</ArtifactsPath >
56
+ </PropertyGroup >
57
+
58
+ <PropertyGroup Condition =" '$(UseArtifactsOutput)' == 'true'" >
59
+ <ArtifactsProjectName Condition =" '$(ArtifactsProjectName)' == ''" >$(MSBuildProjectName)</ArtifactsProjectName >
60
+
61
+ <ArtifactsBinOutputName Condition =" '$(ArtifactsBinOutputName)' == ''" >bin</ArtifactsBinOutputName >
62
+ <ArtifactsPublishOutputName Condition =" '$(ArtifactsPublishOutputName)' == ''" >publish</ArtifactsPublishOutputName >
63
+ <ArtifactsPackageOutputName Condition =" '$(ArtifactsPackageOutputName)' == ''" >package</ArtifactsPackageOutputName >
64
+
65
+ <!-- ArtifactsPivots instead? -->
66
+ <ArtifactsPivots >$(Configuration.ToLowerInvariant())</ArtifactsPivots >
67
+
68
+ <!-- Include the TargetFramework in the pivots if the project is multi-targeted (ie TargetFrameworks) is defined -->
69
+ <ArtifactsPivots Condition =" '$(TargetFrameworks)' != ''"
70
+ >$(ArtifactsPivots)_$(TargetFramework.ToLowerInvariant())</ArtifactsPivots >
71
+
72
+ <!-- This targets file is evaluated before RuntimeIdentifierInference.targets, so this will only include the
73
+ RuntimeIdentifier in the path if it was explicitly specified, not if it was inferred. This is the
74
+ behavior we want.
50
75
51
- <BaseOutputPath >$(BaseStandardOutputPath)build\</BaseOutputPath >
76
+ The BlazorWebAssembly .props file sets the RuntimeIdentifier to blazor-wasm, so treat that as a special case.
77
+ -->
78
+ <ArtifactsPivots Condition =" '$(RuntimeIdentifier)' != '' And !('$(RuntimeIdentifier)' == 'browser-wasm' And '$(AppendRuntimeIdentifierToOutputPath)' == 'false')"
79
+ >$(ArtifactsPivots)_$(RuntimeIdentifier.ToLowerInvariant())</ArtifactsPivots >
80
+
81
+ </PropertyGroup >
52
82
53
- <!-- If RootOutputPath is set, then projects share the BaseStandardOutputPath, and the project name should be appended to the output path -->
54
- <BaseOutputPath Condition =" '$(RootOutputPath)' != ''" >$(BaseOutputPath)$(MSBuildProjectName)\</BaseOutputPath >
83
+ <PropertyGroup Condition =" '$(UseArtifactsOutput)' == 'true' And '$(IncludeProjectNameInArtifactsPaths)' == 'true'" >
84
+ <!-- Set artifacts paths when project name should be included in the path -->
85
+ <BaseOutputPath Condition =" '$(BaseOutputPath)' == ''" >$(ArtifactsPath)\$(ArtifactsBinOutputName)\$(ArtifactsProjectName)\</BaseOutputPath >
86
+ <BaseIntermediateOutputPath Condition =" '$(BaseIntermediateOutputPath)' == '' And '$(UseArtifactsIntermediateOutput)' == 'true'" >$(ArtifactsPath)\obj\$(ArtifactsProjectName)\</BaseIntermediateOutputPath >
87
+ <PublishDir Condition =" '$(PublishDir)' == ''" >$(ArtifactsPath)\$(ArtifactsPublishOutputName)\$(ArtifactsProjectName)\$(ArtifactsPivots)\</PublishDir >
55
88
</PropertyGroup >
56
89
57
- <PropertyGroup Condition =" '$(UseStandardOutputPaths)' != 'true'" >
90
+ <PropertyGroup Condition =" '$(UseArtifactsOutput)' == 'true' And '$(IncludeProjectNameInArtifactsPaths)' != 'true'" >
91
+ <!-- Set artifacts paths when project name should not be included in the path -->
92
+ <BaseOutputPath Condition =" '$(BaseOutputPath)' == ''" >$(ArtifactsPath)\$(ArtifactsBinOutputName)\</BaseOutputPath >
93
+ <BaseIntermediateOutputPath Condition =" '$(BaseIntermediateOutputPath)' == '' And '$(UseArtifactsIntermediateOutput)' == 'true'" >$(ArtifactsPath)\obj\</BaseIntermediateOutputPath >
94
+ <PublishDir Condition =" '$(PublishDir)' == ''" >$(ArtifactsPath)\$(ArtifactsPublishOutputName)\$(ArtifactsPivots)\</PublishDir >
95
+ </PropertyGroup >
96
+
97
+ <PropertyGroup Condition =" '$(UseArtifactsOutput)' == 'true'" >
98
+ <OutputPath Condition =" '$(OutputPath)' == ''" >$(BaseOutputPath)$(ArtifactsPivots)\</OutputPath >
99
+ <IntermediateOutputPath Condition =" $(IntermediateOutputPath) == '' And '$(UseArtifactsIntermediateOutput)' == 'true'" >$(BaseIntermediateOutputPath)$(ArtifactsPivots)\</IntermediateOutputPath >
100
+
101
+ <!-- The package output path does not include the project name, and only includes the Configuration as a pivot -->
102
+ <PackageOutputPath Condition =" '$(PackageOutputPath)' == ''" >$(ArtifactsPath)\$(ArtifactsPackageOutputName)\$(Configuration.ToLowerInvariant())\</PackageOutputPath >
103
+
104
+ </PropertyGroup >
105
+
106
+ <PropertyGroup Condition =" '$(UseArtifactsOutput)' != 'true'" >
58
107
<BaseOutputPath Condition =" '$(BaseOutputPath)' == ''" >bin\</BaseOutputPath >
59
108
<BaseOutputPath Condition =" !HasTrailingSlash('$(BaseOutputPath)')" >$(BaseOutputPath)\</BaseOutputPath >
60
109
<OutputPath Condition =" '$(OutputPath)' == '' and '$(PlatformName)' == 'AnyCPU'" >$(BaseOutputPath)$(Configuration)\</OutputPath >
61
110
<OutputPath Condition =" '$(OutputPath)' == '' and '$(PlatformName)' != 'AnyCPU'" >$(BaseOutputPath)$(PlatformName)\$(Configuration)\</OutputPath >
62
111
<OutputPath Condition =" !HasTrailingSlash('$(OutputPath)')" >$(OutputPath)\</OutputPath >
63
112
</PropertyGroup >
64
113
65
- <!-- If "UseStandardOutputPaths " wasn't set when the MSBuild project extensions .props files were imported, then use "obj" for the intermediate output path
66
- instead of $(BaseStandardOutputPath)\obj . To have the intermediate output path in the standard output folder, "UseStandardOutputPaths " should be set in Directory.Build.props-->
67
- <PropertyGroup Condition =" '$(UseStandardIntermediateOutput )' != 'true'" >
114
+ <!-- If "UseArtifactsOutput " wasn't set when the MSBuild project extensions .props files were imported, then use "obj" in the project folder for the intermediate output path
115
+ instead a folder under ArtifactsPath . To have the intermediate output path in the artifacts folder, "UseArtifactsOutput " should be set in Directory.Build.props-->
116
+ <PropertyGroup Condition =" '$(UseArtifactsIntermediateOutput )' != 'true'" >
68
117
<BaseIntermediateOutputPath Condition =" '$(BaseIntermediateOutputPath)' == ''" >obj\</BaseIntermediateOutputPath >
69
118
<BaseIntermediateOutputPath Condition =" !HasTrailingSlash('$(BaseIntermediateOutputPath)')" >$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath >
70
119
<IntermediateOutputPath Condition =" $(IntermediateOutputPath) == '' and '$(PlatformName)' == 'AnyCPU' " >$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath >
@@ -74,67 +123,32 @@ Copyright (c) .NET Foundation. All rights reserved.
74
123
75
124
<!-- Set the package output path (for nuget pack target) now, before the TargetFramework is appended -->
76
125
<PropertyGroup Condition =" '$(PackageOutputPath)' == ''" >
77
- <PackageOutputPath Condition =" '$(UseStandardOutputPaths)' != 'true'" >$(OutputPath)</PackageOutputPath >
78
- <PackageOutputPath Condition =" '$(UseStandardOutputPaths)' == 'true'" >$(BaseStandardOutputPath)\package\$(Configuration.ToLowerInvariant())\</PackageOutputPath >
126
+ <PackageOutputPath Condition =" '$(UseArtifactsOutput)' != 'true'" >$(OutputPath)</PackageOutputPath >
79
127
</PropertyGroup >
80
128
81
129
<!-- Exclude files from OutputPath and IntermediateOutputPath from default item globs. Use the value
82
130
of these properties before the TargetFramework is appended, so that if these values are specified
83
131
in the project file, the specified value will be used for the exclude. -->
84
- <PropertyGroup Condition =" '$(UseStandardOutputPaths )' != 'true'" >
132
+ <PropertyGroup Condition =" '$(UseArtifactsOutput )' != 'true'" >
85
133
<DefaultItemExcludes >$(DefaultItemExcludes);$(OutputPath)/**</DefaultItemExcludes >
86
134
<DefaultItemExcludes >$(DefaultItemExcludes);$(IntermediateOutputPath)/**</DefaultItemExcludes >
87
135
</PropertyGroup >
88
136
89
- <PropertyGroup Condition =" '$(UseStandardOutputPaths )' == 'true'" >
90
- <DefaultItemExcludes >$(DefaultItemExcludes);$(BaseStandardOutputPath )/**</DefaultItemExcludes >
137
+ <PropertyGroup Condition =" '$(UseArtifactsOutput )' == 'true'" >
138
+ <DefaultItemExcludes >$(DefaultItemExcludes);$(ArtifactsPath )/**</DefaultItemExcludes >
91
139
</PropertyGroup >
92
140
93
141
<!--
94
142
Append $(TargetFramework) directory to output and intermediate paths to prevent bin clashes between
95
143
targets.
96
144
-->
97
- <PropertyGroup Condition =" '$(UseStandardOutputPaths )' != 'true' and
145
+ <PropertyGroup Condition =" '$(UseArtifactsOutput )' != 'true' and
98
146
'$(AppendTargetFrameworkToOutputPath)' == 'true' and '$(TargetFramework)' != '' and '$(_UnsupportedTargetFrameworkError)' != 'true'" >
99
147
<OutputPath >$(OutputPath)$(TargetFramework.ToLowerInvariant())\</OutputPath >
100
148
</PropertyGroup >
101
149
102
- <PropertyGroup Condition =" '$(UseStandardIntermediateOutput )' != 'true' and
150
+ <PropertyGroup Condition =" '$(UseArtifactsOutput )' != 'true' and
103
151
'$(AppendTargetFrameworkToOutputPath)' == 'true' and '$(TargetFramework)' != '' and '$(_UnsupportedTargetFrameworkError)' != 'true'" >
104
152
<IntermediateOutputPath >$(IntermediateOutputPath)$(TargetFramework.ToLowerInvariant())\</IntermediateOutputPath >
105
153
</PropertyGroup >
106
-
107
- <PropertyGroup Condition =" '$(UseStandardOutputPaths)' == 'true'" >
108
- <_ArtifactPivots >$(Configuration.ToLowerInvariant())</_ArtifactPivots >
109
-
110
- <!-- Per the design, we should include the TargetFramework in the pivots if TargetFrameworks is defined, or if TargetFramework is a global property.
111
- However, basing this on whether TargetFramework is a global property currently breaks "dotnet pack": https://github.com/NuGet/Home/issues/12323
112
- Because of this, for now we will only include the TargetFramework in the pivots if TargetFrameworks is defined, and won't look at whether
113
- TargetFramework is a global property or not. -->
114
- <_ArtifactPivots Condition =" '$(TargetFrameworks)' != ''"
115
- >$(_ArtifactPivots)_$(TargetFramework.ToLowerInvariant())</_ArtifactPivots >
116
-
117
- <!-- This targets file is evaluated before RuntimeIdentifierInference.targets, so this will only include the
118
- RuntimeIdentifier in the path if it was explicitly specified, not if it was inferred. This is the
119
- behavior we want.
120
-
121
- The BlazorWebAssembly .props file sets the RuntimeIdentifier to blazor-wasm, so treat that as a special case.
122
- -->
123
-
124
- <_ArtifactPivots Condition =" '$(RuntimeIdentifier)' != '' And !('$(RuntimeIdentifier)' == 'browser-wasm' And '$(AppendRuntimeIdentifierToOutputPath)' == 'false')"
125
- >$(_ArtifactPivots)_$(RuntimeIdentifier.ToLowerInvariant())</_ArtifactPivots >
126
-
127
- <OutputPath Condition =" '$(OutputPath)' == ''" >$(BaseOutputPath)$(_ArtifactPivots)\</OutputPath >
128
-
129
- <!-- Publish path -->
130
- <PublishDirName Condition =" '$(PublishDirName)' == ''" >publish</PublishDirName >
131
-
132
- <PublishDir Condition =" '$(PublishDir)' == '' And '$(RootOutputPath)' == ''" >$(BaseStandardOutputPath)$(PublishDirName)\$(_ArtifactPivots)\</PublishDir >
133
- <PublishDir Condition =" '$(PublishDir)' == '' And '$(RootOutputPath)' != ''" >$(BaseStandardOutputPath)$(PublishDirName)\$(MSBuildProjectName)\$(_ArtifactPivots)\</PublishDir >
134
-
135
- </PropertyGroup >
136
-
137
- <PropertyGroup Condition =" '$(UseStandardOutputPaths)' == 'true' and '$(UseStandardIntermediateOutput)' == 'true'" >
138
- <IntermediateOutputPath Condition =" $(IntermediateOutputPath) == '' " >$(BaseIntermediateOutputPath)$(_ArtifactPivots)\</IntermediateOutputPath >
139
- </PropertyGroup >
140
154
</Project >
0 commit comments