Skip to content

Commit

Permalink
[build] Fix more ordering issues with ExposeExperimentalFeatures comp…
Browse files Browse the repository at this point in the history
…iler switch (#4832)
  • Loading branch information
CodeBlanch authored Sep 6, 2023
1 parent 268d29a commit 5cc1f39
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 26 deletions.
30 changes: 26 additions & 4 deletions build/Common.prod.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,48 @@
</PropertyGroup>

<Target Name="AssemblyVersionTarget" AfterTargets="MinVer" Condition="'$(MinVerVersion)'!='' AND '$(BuildNumber)' != ''">
<!-- Note: $(BuildNumber) is typically only set for builds initiated by the
publish workflow. The goal here is to set the assembly FileVersion and
resolve ExposeExperimentalFeatures based on the version MinVer resolved from
the git tag -->
<PropertyGroup>
<FileVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(BuildNumber)</FileVersion>
<ExposeExperimentalFeatures Condition="'$(MinVerPreRelease)' != ''">true</ExposeExperimentalFeatures>
<ExposeExperimentalFeatures Condition="'$(MinVerPreRelease)' == ''">false</ExposeExperimentalFeatures>
</PropertyGroup>

<Message Importance="high" Text="**AssemblyVersionDebug** TargetFramework: $(TargetFramework), MinVerVersion: $(MinVerVersion), MinVerMajor: $(MinVerMajor), MinVerMinor: $(MinVerMinor), MinVerPatch: $(MinVerPatch), MinVerPreRelease: $(MinVerPreRelease), BuildNumber: $(BuildNumber), FileVersion: $(FileVersion), ExposeExperimentalFeatures: $(ExposeExperimentalFeatures)" />
<!-- Note: The '$(TargetFramework)' != '' check here is to reduce log spam
in builds like dotnet pack which fire MinVer but don't resolve the actual
TargetFramework -->
<Message
Condition="'$(TargetFramework)' != ''"
Importance="high"
Text="**AssemblyVersionDebug** TargetFramework: $(TargetFramework), MinVerVersion: $(MinVerVersion), BuildNumber: $(BuildNumber), FileVersion: $(FileVersion), ExposeExperimentalFeatures: $(ExposeExperimentalFeatures)" />
</Target>

<Target Name="ResolveExposeExperimentalFeatures" BeforeTargets="BeforeCompile" DependsOnTargets="AssemblyVersionTarget">
<Target Name="ResolveExposeExperimentalFeatures" BeforeTargets="CoreCompile" DependsOnTargets="AssemblyVersionTarget">
<!-- Note: This runs for all builds. The goal here is to set the
EXPOSE_EXPERIMENTAL_FEATURES compiler constant if
$(ExposeExperimentalFeatures) is enabled and then select the correct api
files for the analyzer -->
<PropertyGroup Condition="'$(ExposeExperimentalFeatures)' == 'true'">
<DefineConstants>$(DefineConstants);EXPOSE_EXPERIMENTAL_FEATURES</DefineConstants>
</PropertyGroup>

<!--PublicApi Analyzer-->
<!-- Note: This selects the correct PublicApiAnalyzers files based on $(ExposeExperimentalFeatures) -->
<ItemGroup>
<AdditionalFiles Include=".publicApi\Stable\$(TargetFramework)\PublicAPI.*.txt" />
<AdditionalFiles Include=".publicApi\Experimental\$(TargetFramework)\PublicAPI.*.txt" Condition="'$(ExposeExperimentalFeatures)' == 'true'" />
<AdditionalFiles Include=".publicApi\$(TargetFramework)\PublicAPI.*.txt" />
</ItemGroup>

<!-- Note: The '$(BuildNumber)' != '' check here is to reduce log spam in
local and CI builds. We only want to log this for the publish workflows
where official builds are generated -->
<Message
Condition="'$(BuildNumber)' != ''"
Importance="high"
Text="**ResolveExposeExperimentalFeaturesDebug** TargetFramework: $(TargetFramework), DefineConstants: $(DefineConstants)" />
</Target>

<PropertyGroup>
Expand Down Expand Up @@ -101,7 +123,7 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<!--PublicApi Analyzer-->
<!-- Note: This includes all the PublicApiAnalyzers files in projects to make editing easier in the IDE -->
<ItemGroup>
<None Include=".publicApi\**\PublicAPI.*.txt" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(ExposeExperimentalFeatures)' == 'true'">
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\SpanAttributeConstants.cs" Link="Includes\SpanAttributeConstants.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Metrics\Base2ExponentialBucketHistogram.LowerBoundary.cs" Link="Includes\Base2ExponentialBucketHistogram.LowerBoundary.cs" />
</ItemGroup>
<Target Name="PostResolveExposeExperimentalFeatures" AfterTargets="ResolveExposeExperimentalFeatures">
<ItemGroup Condition="'$(ExposeExperimentalFeatures)' == 'true'">
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\SpanAttributeConstants.cs" Link="Includes\SpanAttributeConstants.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Metrics\Base2ExponentialBucketHistogram.LowerBoundary.cs" Link="Includes\Base2ExponentialBucketHistogram.LowerBoundary.cs" />
</ItemGroup>
</Target>

<ItemGroup>
<Compile Include="$(RepoRoot)\src\Shared\PeriodicExportingMetricReaderHelper.cs" Link="Includes\PeriodicExportingMetricReaderHelper.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
</ItemGroup>

<Target Name="PostResolveExposeExperimentalFeatures" AfterTargets="ResolveExposeExperimentalFeatures">
<ItemGroup Condition="'$(ExposeExperimentalFeatures)' == 'true'">
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
</ItemGroup>
</Target>

<ItemGroup>
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" Condition="'$(ExposeExperimentalFeatures)' == 'true'" />
<Compile Include="$(RepoRoot)\src\Shared\PeriodicExportingMetricReaderHelper.cs" Link="Includes\PeriodicExportingMetricReaderHelper.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@
<PackageReference Include="System.Reflection.Emit.Lightweight" Condition="'$(TargetFramework)' != 'net6.0'" />
</ItemGroup>

<ItemGroup Condition="'$(ExposeExperimentalFeatures)' == 'true'">
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\EnvironmentVariables\*.cs" Link="Includes\EnvironmentVariables\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Options\*.cs" Link="Includes\Options\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\SemanticConventions.cs" Link="Includes\SemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\SpanAttributeConstants.cs" Link="Includes\SpanAttributeConstants.cs" />
<Compile Include="$(RepoRoot)\src\Shared\StatusHelper.cs" Link="Includes\StatusHelper.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Shims\NullableAttributes.cs" />
</ItemGroup>
<Target Name="PostResolveExposeExperimentalFeatures" AfterTargets="ResolveExposeExperimentalFeatures">
<ItemGroup Condition="'$(ExposeExperimentalFeatures)' == 'true'">
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\EnvironmentVariables\*.cs" Link="Includes\EnvironmentVariables\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Options\*.cs" Link="Includes\Options\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\SemanticConventions.cs" Link="Includes\SemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\SpanAttributeConstants.cs" Link="Includes\SpanAttributeConstants.cs" />
<Compile Include="$(RepoRoot)\src\Shared\StatusHelper.cs" Link="Includes\StatusHelper.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Shims\NullableAttributes.cs" />
</ItemGroup>
</Target>

<ItemGroup>
<Compile Include="$(RepoRoot)\src\Shared\PeriodicExportingMetricReaderHelper.cs" Link="Includes\PeriodicExportingMetricReaderHelper.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(ExposeExperimentalFeatures)' == 'true'">
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
</ItemGroup>
<Target Name="PostResolveExposeExperimentalFeatures" AfterTargets="ResolveExposeExperimentalFeatures">
<ItemGroup Condition="'$(ExposeExperimentalFeatures)' == 'true'">
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
</ItemGroup>
</Target>

</Project>

0 comments on commit 5cc1f39

Please sign in to comment.