Skip to content

Commit

Permalink
Disable source generators from binplacing (#51539)
Browse files Browse the repository at this point in the history
* Disable source generators from binplacing

* Ensure APICompat doesn't run for non-Source projects
  • Loading branch information
ericstj committed Apr 20, 2021
1 parent 7d24b36 commit 9580b7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
<SkipInferTargetOSName>true</SkipInferTargetOSName>
<DisableArcadeTestFramework>true</DisableArcadeTestFramework>

<_projectDirName>$([System.IO.Path]::GetFileName('$(MSBuildProjectDirectory)'))</_projectDirName>
<IsReferenceAssembly Condition="'$(_projectDirName)' == 'ref'">true</IsReferenceAssembly>
<IsSourceProject Condition="'$(_projectDirName)' == 'src'">true</IsSourceProject>
<IsGeneratorProject Condition="'$(_projectDirName)' == 'gen'">true</IsGeneratorProject>

<!-- Set OutDirName to change BaseOutputPath and BaseIntermediateOutputPath to include the ref subfolder. -->
<_sepChar>$([System.IO.Path]::DirectorySeparatorChar)</_sepChar>
<IsReferenceAssembly Condition="$(MSBuildProjectFullPath.Contains('$(_sepChar)ref$(_sepChar)'))">true</IsReferenceAssembly>
<OutDirName Condition="'$(IsReferenceAssembly)' == 'true'">$(MSBuildProjectName)$(_sepChar)ref</OutDirName>
</PropertyGroup>

Expand All @@ -14,7 +17,6 @@

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

<PropertyGroup>
<RunApiCompatForSrc>$(IsSourceProject)</RunApiCompatForSrc>
<RunMatchingRefApiCompat>$(IsSourceProject)</RunMatchingRefApiCompat>
<RunApiCompatForSrc>$([MSBuild]::ValueOrDefault('$(IsSourceProject)', 'false'))</RunApiCompatForSrc>
<RunMatchingRefApiCompat>$([MSBuild]::ValueOrDefault('$(IsSourceProject)', 'false'))</RunMatchingRefApiCompat>
<ApiCompatEnforceOptionalRules>true</ApiCompatEnforceOptionalRules>
<ApiCompatExcludeAttributeList>$(RepositoryEngineeringDir)DefaultGenApiDocIds.txt,$(RepositoryEngineeringDir)ApiCompatExcludeAttributes.txt</ApiCompatExcludeAttributeList>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

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

0 comments on commit 9580b7d

Please sign in to comment.