Skip to content

Commit

Permalink
Upgrade to .NET 9 SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Nov 22, 2024
1 parent 107db01 commit 276d1c1
Show file tree
Hide file tree
Showing 29 changed files with 173 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .github/.github.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>False</IsPackable>
</PropertyGroup>

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/bootstrap/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ runs:
with:
global-json-file: ./global.json

- name: Install Aspire workload
shell: bash
run: dotnet workload install aspire

- id: dotnet
shell: bash
run: |
Expand All @@ -53,6 +49,7 @@ runs:
echo "AGENT_VERSION=${AGENT_VERSION}" >> $GITHUB_ENV
echo "agent-version=${AGENT_VERSION}" >> $GITHUB_OUTPUT
echo "major-version=$(echo ${AGENT_VERSION} | cut -d"." -f1)" >> $GITHUB_OUTPUT
dotnet --version
# Setup git config
- uses: elastic/oblt-actions/git/setup@v1
6 changes: 3 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ concurrency:

env:
# (keep_serverless-staging-oblt, keep_serverless-qa-oblt or serverless-production-oblt)
SERVERLESS_PROJECT: serverless-production-oblt
SERVERLESS_PROJECT: keep_serverless-qa-oblt

# NOTE: if you add a new job and it's a mandatory check then
# update e2e-docs.yml
Expand Down Expand Up @@ -64,8 +64,8 @@ jobs:
with:
export_to_environment: true
secrets: |-
E2E__BROWSEREMAIL:elastic-observability/elastic-cloud-observability-team-pro-username
E2E__BROWSERPASSWORD:elastic-observability/elastic-cloud-observability-team-pro-password
E2E__BROWSEREMAIL:elastic-observability/elastic-cloud-observability-team-qa-username
E2E__BROWSERPASSWORD:elastic-observability/elastic-cloud-observability-team-qa-password
- name: End-to-end tests
run: ./build.sh test --test-suite=e2e
Expand Down
2 changes: 1 addition & 1 deletion build/build.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Exe</OutputType>
<NoWarn>$(NoWarn);NU1701</NoWarn>
<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion build/patch-dotnet-auto-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ case "$ARCHITECTURE" in
esac

test -z "$OTEL_DOTNET_AUTO_HOME" && OTEL_DOTNET_AUTO_HOME="$HOME/.otel-dotnet-auto"
test -z "$VERSION" && VERSION="v1.7.0"
test -z "$VERSION" && VERSION="v1.9.0"

DOWNLOAD_DIR="${DOWNLOAD_DIR:=${TMPDIR:=$(mktemp -d)}}"

Expand Down
7 changes: 1 addition & 6 deletions build/scripts/Packaging.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,8 @@ let stageInstrumentationScript (stagedZips:List<ReleaseAsset * FileInfo>) =
let stageInstallationBashScript () =
let installScript = downloadFileInfo "otel-dotnet-auto-install.sh"
let staged = installScript.CopyTo ((stageFile installScript).FullName, true)
// temporary while https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/pull/3549 is not released.
// Should be released after 1.7.0.
// We should be able to read from `staged` instead after
let patchScript = fileInfo Paths.Root <| Path.Combine("build", "patch-dotnet-auto-install.sh")

let contents =
(File.ReadAllText patchScript.FullName)
(File.ReadAllText staged.FullName)
.Replace("/open-telemetry/opentelemetry-dotnet-instrumentation/", "/elastic/elastic-otel-dotnet/")
.Replace("opentelemetry-dotnet-instrumentation", "elastic-dotnet-instrumentation")
.Replace("v" + Software.OpenTelemetryAutoInstrumentationVersion.AsString, Software.Version.NormalizeToShorter())
Expand Down
10 changes: 6 additions & 4 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ let private runTests suite _ =
| Integration -> [ "--filter"; "FullyQualifiedName~.IntegrationTests" ]
| E2E -> [ "--filter"; "FullyQualifiedName~.EndToEndTests" ]
| Skip_E2E -> [ "--filter"; "FullyQualifiedName!~.EndToEndTests" ]



let settingsArg = ["-s"; "tests/.runsettings"]
let tfmArgs = if OS.Current = OS.Windows then [] else ["-f"; "net8.0"]
let tfmArgs =
if OS.Current = Windows then []
elif suite.Equals(E2E) then ["-f"; "net8.0"]
else ["-f"; "net9.0"]
exec {
env (Map ["TEST_SUITE", suite.SuitName])
run "dotnet" (
Expand All @@ -87,7 +89,7 @@ let private runTests suite _ =
@ ["--"; "RunConfiguration.CollectSourceInformation=true"]
)
}

let private test (arguments:ParseResults<Build>) =
let arg = arguments.TryGetResult Test_Suite
match arg with
Expand Down
6 changes: 4 additions & 2 deletions examples/AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.2.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 15 additions & 2 deletions examples/AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17236;http://localhost:15173",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21045",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22093"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15114",
"applicationUrl": "http://localhost:15173",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16161"
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19153",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20247"
}
}
}
Expand Down
35 changes: 14 additions & 21 deletions examples/Example.AspNetCore.Mvc/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:45954",
"sslPort": 44302
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5247",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5247"
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7295;http://localhost:5247",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"OTEL_RESOURCE_ATTRIBUTES": "service.name=AspNetCoreApp,service.version=1.0.0,deployment.environment=development"
}
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7295;http://localhost:5247"
},
"IIS Express": {
"commandName": "IISExpress",
Expand All @@ -35,5 +19,14 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:45954",
"sslPort": 44302
}
}
}
}
6 changes: 3 additions & 3 deletions examples/Example.AutoInstrumentation/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG OTEL_VERSION=1.7.0
ARG OTEL_VERSION=1.9.0
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
ARG TARGETPLATFORM
ARG TARGETARCH
Expand All @@ -18,7 +18,6 @@ ADD https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/relea
RUN chmod +x otel-dotnet-auto-install.sh
RUN OTEL_DOTNET_AUTO_HOME="/app/otel" sh otel-dotnet-auto-install.sh


FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build_example
ENV _PROJECT="Example.AutoInstrumentation"
ENV _PROJECTPATH="${_PROJECT}/${_PROJECT}.csproj"
Expand All @@ -33,7 +32,7 @@ RUN dotnet build "${_PROJECT}.csproj" -c Release -o /app/build_example
FROM build_example AS publish_example
RUN dotnet publish "Example.AutoInstrumentation.csproj" -c Release -o /app/example /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build_distro
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build_distro
ENV _PROJECT="Elastic.OpenTelemetry"
ENV _PROJECTPATH="${_PROJECT}/${_PROJECT}.csproj"
WORKDIR /work
Expand Down Expand Up @@ -67,6 +66,7 @@ ENV OTEL_DOTNET_AUTO_LOG_DIRECTORY=/app/logs
ENV ELASTIC_OTEL_LOG_TARGETS=stdout

ENV OTEL_DOTNET_AUTO_HOME="/app/otel"
ENV OTEL_DOTNET_AUTO_LOGGER="console"
ENV DOTNET_ADDITIONAL_DEPS="/app/otel/AdditionalDeps"
ENV DOTNET_SHARED_STORE="/app/otel/store"
ENV DOTNET_STARTUP_HOOKS="/app/otel/net/OpenTelemetry.AutoInstrumentation.StartupHook.dll"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG OTEL_VERSION=1.7.0
ARG OTEL_VERSION=1.9.0
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETPLATFORM
ARG TARGETARCH
Expand Down
4 changes: 2 additions & 2 deletions examples/Example.Console/Example.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.0.0-rc9.15" />
<PackageReference Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.9.0-beta.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/Example.MinimalApi/Example.MinimalApi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/Example.WorkerService/Example.WorkerService.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-Example.Elastic.OpenTelemetry.Worker-3a9724de-5d6b-4e68-a21e-b90c655cc721</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion examples/ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.UseServiceDiscovery();
http.AddServiceDiscovery();
});

return builder;
Expand Down
4 changes: 2 additions & 2 deletions examples/ServiceDefaults/ServiceDefaults.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.2.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.4.24156.9" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.404",
"version": "9.0.100",
"rollForward": "latestFeature",
"allowPrerelease": false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>True</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry.AutoInstrumentation" Version="1.7.0" GeneratePathProperty="true" PrivateAssets="contentfiles" />
<PackageReference Include="OpenTelemetry.AutoInstrumentation" Version="1.9.0" GeneratePathProperty="true" PrivateAssets="contentfiles" />
</ItemGroup>

<ItemGroup>
Expand All @@ -18,31 +18,26 @@
and link it as _instrument.cmd since we manually copy it over in the prebuild event -->
<Content Update="instrument.cmd" CopyToPublishDirectory="Never" CopyToOutputDirectory="Never" />
<Content Remove="instrument.cmd" />
<Content Include="_instrument.cmd" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="contentFiles/any/any/_instrument.cmd"/>
<Content Include="instrument.cmd" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="contentFiles/any/any/instrument.cmd"/>
<Content Include="_instrument.cmd" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="contentFiles/any/any/_instrument.cmd" />
<Content Include="instrument.cmd" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="contentFiles/any/any/instrument.cmd" />

<!-- ensure we remove the linked instrument.sh from base OpenTelemetry.AutoInstrumentation
and link it as _instrument.sh since we manually copy it over in the prebuild event -->

<Content Update="instrument.sh" CopyToPublishDirectory="Never" CopyToOutputDirectory="Never" />
<Content Remove="instrument.sh" />
<Content Include="_instrument.sh" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="contentFiles/any/any/_instrument.sh"/>
<Content Include="instrument.sh" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="contentFiles/any/any/instrument.sh"/>
<Content Include="_instrument.sh" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="contentFiles/any/any/_instrument.sh" />
<Content Include="instrument.sh" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="contentFiles/any/any/instrument.sh" />

<Content Include="instrument.props" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always"
Pack="True" PackagePath="build/elastic.opentelemetry.autoinstrumentation.props"/>
<Content Include="instrument.props" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" Pack="True" PackagePath="build/elastic.opentelemetry.autoinstrumentation.props" />

</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<!-- Copies the content files manually as physical files in the source repository -->
<!-- we manually repackage these as contentfiles (albeit renamed) -->
<Copy SourceFiles="$(PkgOpenTelemetry_AutoInstrumentation)/contentFiles/any/any/instrument.cmd" DestinationFiles="$(MSBuildThisFileDirectory)/_instrument.cmd"/>
<Copy SourceFiles="$(PkgOpenTelemetry_AutoInstrumentation)/contentFiles/any/any/instrument.sh" DestinationFiles="$(MSBuildThisFileDirectory)/_instrument.sh"/>
<Copy SourceFiles="$(PkgOpenTelemetry_AutoInstrumentation)/contentFiles/any/any/instrument.cmd" DestinationFiles="$(MSBuildThisFileDirectory)/_instrument.cmd" />
<Copy SourceFiles="$(PkgOpenTelemetry_AutoInstrumentation)/contentFiles/any/any/instrument.sh" DestinationFiles="$(MSBuildThisFileDirectory)/_instrument.sh" />
</Target>

<ItemGroup>
Expand Down
Loading

0 comments on commit 276d1c1

Please sign in to comment.