Skip to content

Commit 9580b7d

Browse files
authored
Disable source generators from binplacing (#51539)
* Disable source generators from binplacing * Ensure APICompat doesn't run for non-Source projects
1 parent 7d24b36 commit 9580b7d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/libraries/Directory.Build.props

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
<SkipInferTargetOSName>true</SkipInferTargetOSName>
44
<DisableArcadeTestFramework>true</DisableArcadeTestFramework>
55

6+
<_projectDirName>$([System.IO.Path]::GetFileName('$(MSBuildProjectDirectory)'))</_projectDirName>
7+
<IsReferenceAssembly Condition="'$(_projectDirName)' == 'ref'">true</IsReferenceAssembly>
8+
<IsSourceProject Condition="'$(_projectDirName)' == 'src'">true</IsSourceProject>
9+
<IsGeneratorProject Condition="'$(_projectDirName)' == 'gen'">true</IsGeneratorProject>
10+
611
<!-- Set OutDirName to change BaseOutputPath and BaseIntermediateOutputPath to include the ref subfolder. -->
7-
<_sepChar>$([System.IO.Path]::DirectorySeparatorChar)</_sepChar>
8-
<IsReferenceAssembly Condition="$(MSBuildProjectFullPath.Contains('$(_sepChar)ref$(_sepChar)'))">true</IsReferenceAssembly>
912
<OutDirName Condition="'$(IsReferenceAssembly)' == 'true'">$(MSBuildProjectName)$(_sepChar)ref</OutDirName>
1013
</PropertyGroup>
1114

@@ -14,7 +17,6 @@
1417

1518
<PropertyGroup>
1619
<BeforeTargetFrameworkInferenceTargets>$(RepositoryEngineeringDir)BeforeTargetFrameworkInference.targets</BeforeTargetFrameworkInferenceTargets>
17-
<IsSourceProject>$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectDirectory), 'src%24'))</IsSourceProject>
1820
<RuntimeGraph>$(LibrariesProjectRoot)OSGroups.json</RuntimeGraph>
1921
<ShouldUnsetParentConfigurationAndPlatform>false</ShouldUnsetParentConfigurationAndPlatform>
2022
<!-- Remove once is fixed: https://github.com/dotnet/roslyn/issues/42344 -->
@@ -65,8 +67,8 @@
6567
</PropertyGroup>
6668

6769
<PropertyGroup>
68-
<RunApiCompatForSrc>$(IsSourceProject)</RunApiCompatForSrc>
69-
<RunMatchingRefApiCompat>$(IsSourceProject)</RunMatchingRefApiCompat>
70+
<RunApiCompatForSrc>$([MSBuild]::ValueOrDefault('$(IsSourceProject)', 'false'))</RunApiCompatForSrc>
71+
<RunMatchingRefApiCompat>$([MSBuild]::ValueOrDefault('$(IsSourceProject)', 'false'))</RunMatchingRefApiCompat>
7072
<ApiCompatEnforceOptionalRules>true</ApiCompatEnforceOptionalRules>
7173
<ApiCompatExcludeAttributeList>$(RepositoryEngineeringDir)DefaultGenApiDocIds.txt,$(RepositoryEngineeringDir)ApiCompatExcludeAttributes.txt</ApiCompatExcludeAttributeList>
7274
</PropertyGroup>

src/libraries/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
<!-- Libraries-specific binplacing properties -->
4646
<PropertyGroup>
47-
<IsRuntimeAssembly Condition="'$(IsRuntimeAssembly)'=='' and '$(IsReferenceAssembly)' != 'true' and '$(BinPlaceRef)' != 'true' and '$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true'">true</IsRuntimeAssembly>
47+
<IsRuntimeAssembly Condition="'$(IsRuntimeAssembly)'=='' and '$(IsReferenceAssembly)' != 'true' and '$(BinPlaceRef)' != 'true' and '$(IsGeneratorProject)' != 'true' and '$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true'">true</IsRuntimeAssembly>
4848
<!-- Try to determine if this is a simple library without a ref project.
4949
https://github.com/dotnet/runtime/issues/19584 is tracking cleaning this up -->
5050
<IsRuntimeAndReferenceAssembly Condition="'$(IsRuntimeAndReferenceAssembly)' == '' and '$(IsRuntimeAssembly)' == 'true' and Exists('$(LibrariesProjectRoot)$(MSBuildProjectName)') and !Exists('$(LibrariesProjectRoot)$(MSBuildProjectName)/ref') and !$(MSBuildProjectName.StartsWith('System.Private'))">true</IsRuntimeAndReferenceAssembly>

0 commit comments

Comments
 (0)