Skip to content

Commit

Permalink
update buildscript system.diagnostics version discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Oct 22, 2024
1 parent 1284698 commit 88c0d99
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<PackageVersion Include="Azure.Storage.Files.Shares" Version="12.7.0" />
<PackageVersion Include="Azure.Storage.Queues" Version="12.11.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.5" />
<PackageVersion Include="Buildalyzer" Version="3.2.0" />
<PackageVersion Include="Bullseye" Version="3.5.0" />
<PackageVersion Include="CommandLineParser" Version="2.6.0" />
<PackageVersion Include="Confluent.Kafka" Version="1.9.3" />
Expand Down
1 change: 0 additions & 1 deletion build/build.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

</ItemGroup>
<ItemGroup>
<PackageReference Include="Buildalyzer"/>
<PackageReference Include="Bullseye" />
<PackageReference Include="System.CommandLine" />

Expand Down
17 changes: 7 additions & 10 deletions build/scripts/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ open System
open System.Collections.Generic
open System.IO
open System.IO.Compression
open System.Linq
open System.Runtime.InteropServices
open System.Xml.Linq
open Buildalyzer
open System.Xml.XPath
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
open Scripts.TestEnvironment
open TestEnvironment
open Tooling

module Build =
Expand Down Expand Up @@ -87,15 +85,14 @@ module Build =
}) projectOrSln

/// Gets the current version of System.Diagnostics.DiagnosticSource referenced by Elastic.Apm
let private getCurrentApmDiagnosticSourceVersion =
let getCurrentApmDiagnosticSourceVersion =
match currentDiagnosticSourceVersion with
| Some v -> v
| None ->
let manager = AnalyzerManager();
let analyzer = manager.GetProject(Paths.SrcProjFile "Elastic.Apm")
let analyzeResult = analyzer.Build("netstandard2.0").First()
let values = analyzeResult.PackageReferences["System.Diagnostics.DiagnosticSource"]
let version = SemVer.parse values["VersionOverride"]
| None ->
let xml = XDocument.Load("Directory.Packages.props")
let package = xml.XPathSelectElement("//PackageVersion[@Include='System.Diagnostics.DiagnosticSource']")
let version = package.Attribute("Version").Value
let version = SemVer.parse version
currentDiagnosticSourceVersion <- Some(version)
version

Expand Down
2 changes: 2 additions & 0 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ module Main =

Targets.Target("restore", Build.Restore)

Targets.Target("print-diagnostics-version", fun _ -> printfn $"%s{Build.getCurrentApmDiagnosticSourceVersion.ToString()}")

Targets.Target("format", Build.Format)

Targets.Target("build", ["restore"; "clean"; "version"], Build.Build)
Expand Down

0 comments on commit 88c0d99

Please sign in to comment.