Files
dotnet-runtime/eng/codeOptimization.targets
Viktor Hofer a6f4539535 Make Is*Project properties unambiguous and improve IsGeneratorProject detection (#65896)
* Make Is*Project properties unambiguous

Currently these properties exist which categorize projects:
- IsReferenceAssembly: The project's parent directory is 'ref'
- IsGeneratorProject: The project's parent directory is 'gen'
- IsTestProject: The project is located somewhere under a '/tests/'
                 directory and the project name's suffix is either
                 '.Tests' or '.UnitTests'.
- IsTrimmingTestProject: Same as IsTestProject but the project name's
                         suffix is '.TrimmingTests'.
- IsTestSupportProject: The project is located somewhere under a
                        '/tests/' directory and the above IsTestProject
                        property is false.
- UsingMicrosoftNoTargetsSdk: The project uses the NoTargets msbuild SDK
- UsingMicrosoftTraversalSdk: The project uses the Traversal msbuild SDK
- IsRuntimeAssembly: True when all above is false
- IsSourceProject: True when the project's parent directory is 'src'

The IsRuntimeAssembly and IsSourceProject properties meanings are
ambiguous and the property names aren't consistent (IsReferenceAssembly
vs IsGeneratorProject).

I'm changing the above to the following:
- **IsReferenceSourceProject: The project's parent directory is 'ref'
                        or the parent of the parent directory is 'ref'**
- IsGeneratorProject: The project's parent directory is 'gen'
- IsTestProject: The project is located somewhere under a '/tests/'
                 directory and the project name's suffix is either
                 '.Tests' or '.UnitTests'.
- IsTrimmingTestProject: Same as IsTestProject but the project name's
                         suffix is '.TrimmingTests'.
- IsTestSupportProject: The project is located somewhere under a
                        '/tests/' directory and the above IsTestProject
                        **and IsTrimmingTestProject** props are false.
- UsingMicrosoftNoTargetsSdk: The project uses the NoTargets msbuild SDK
- UsingMicrosoftTraversalSdk: The project uses the Traversal msbuild SDK
- IsSourceProject: **True when all above is false.**

* React to PR feedback
2022-02-28 21:13:22 +01:00

31 lines
1.7 KiB
XML

<Project>
<PropertyGroup Condition="'$(IsEligibleForNgenOptimization)' == ''">
<IsEligibleForNgenOptimization>true</IsEligibleForNgenOptimization>
<IsEligibleForNgenOptimization Condition="'$(IsReferenceAssemblyProject)' == 'true'">false</IsEligibleForNgenOptimization>
<IsEligibleForNgenOptimization Condition="'$(GeneratePlatformNotSupportedAssembly)' == 'true' or '$(GeneratePlatformNotSupportedAssemblyMessage)' != ''">false</IsEligibleForNgenOptimization>
<!-- There's an issue causing IBCMerge failures because of mismatched MVIDs
across many of our assemblies on Mac, so disable
IBCMerge optimizations on Mac for now to unblock the offical build.
See issue https://github.com/dotnet/runtime/issues/33303
-->
<IsEligibleForNgenOptimization Condition="'$(TargetOS)' == 'OSX' or '$(TargetsMobile)' == 'true'">false</IsEligibleForNgenOptimization>
</PropertyGroup>
<Target Name="SetApplyNgenOptimization"
Condition="'$(IsEligibleForNgenOptimization)' == 'true'"
BeforeTargets="CoreCompile">
<PropertyGroup>
<IbcOptimizationDataDir Condition="'$(TargetOS)' == 'Unix' or '$(TargetOS)' == 'Linux'">$(IbcOptimizationDataDir)Linux\</IbcOptimizationDataDir>
<IbcOptimizationDataDir Condition="'$(TargetOS)' == 'windows'">$(IbcOptimizationDataDir)Windows\</IbcOptimizationDataDir>
</PropertyGroup>
<ItemGroup>
<_optimizationDataAssembly Include="$(IbcOptimizationDataDir)**\$(TargetFileName)" />
</ItemGroup>
<PropertyGroup>
<ApplyNgenOptimization Condition="'@(_optimizationDataAssembly)' != ''">full</ApplyNgenOptimization>
</PropertyGroup>
</Target>
</Project>