Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for .NET 7 #1617

Merged
merged 8 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
- run: ./build.cmd Workflow --containers ${{ matrix.containers }}
- name: Upload logs
uses: actions/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- name: check out code
uses: actions/[email protected]

- name: Setup .NET 6.0
- name: Setup .NET 7.0
uses: actions/[email protected]
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Install format tool
run: dotnet tool install -g dotnet-format
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
- run: ./build.cmd
- name: Upload binaries
uses: actions/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/verify-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
- run: ./build.cmd BuildTracer ManagedTests --containers ${{ matrix.containers }} --test-project "${{ github.event.inputs.testProject }}" --test-name '"${{ github.event.inputs.testName }}"' --test-count ${{ github.event.inputs.count }}
- name: Upload logs
uses: actions/[email protected]
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h

### Added

- Add support for .NET 7.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan was only to add tests for .NET 7, but additional dependencies/store requires separate folder structure for each supported .NET version.

- Error message on the native log if bytecode instrumentation type is missing all
instrumentation methods [#1499](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/1499).
- Plugins can overwrite OpenTelemetry dotnet SDK instrumentation and exporter options.
Expand Down
26 changes: 14 additions & 12 deletions build/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Nuke.Common.Tools.Npm;
using Nuke.Common.Tools.NuGet;
using Nuke.Common.Utilities.Collections;
using static DotNetMSBuildTasks;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
Expand Down Expand Up @@ -52,7 +51,10 @@ partial class Build
TargetFramework.NET6_0
};

private static readonly IEnumerable<TargetFramework> TestFrameworks = TargetFrameworks;
private static readonly IEnumerable<TargetFramework> TestFrameworks = TargetFrameworks
.Concat(new[] {
TargetFramework.NET7_0
});

Target CreateRequiredDirectories => _ => _
.Unlisted()
Expand Down Expand Up @@ -129,7 +131,7 @@ partial class Build

DotNetMSBuild(x => x
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DotNetMSBuild is build in the Nuke itself, so I was able to remove our custom class.

.SetTargetPath(MsBuildProject)
.SetTargetPlatform(Platform)
.SetPlatform(Platform)
.SetConfiguration(BuildConfiguration)
.DisableRestore()
.SetTargets("BuildCsharpTest"));
Expand Down Expand Up @@ -333,22 +335,21 @@ partial class Build
return;
}

IEnumerable<TargetFramework> frameworks = IsWin ? TestFrameworks : TestFrameworks.ExceptNetFramework();
var frameworks = IsWin ? TestFrameworks : TestFrameworks.ExceptNetFramework();

for (int i = 0; i < TestCount; i++)
{
DotNetTest(config => config
DotNetMSBuild(config => config
.SetConfiguration(BuildConfiguration)
.SetTargetPlatform(Platform)
.SetPlatform(Platform)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way to pass Platform (x64/x86) through the dotnet tests to dotnet msbuild executed under the hood.
I have decided to call it directly.

This property is important, because .NET 7 SDK changed the output path structure based on this. Previously it was working only by accident.

.SetFilter(AndFilter(TestNameFilter(), ContainersFilter()))
.SetBlameHangTimeout("5m")
.EnableTrxLogOutput(GetResultsDirectory(project))
.SetProjectFile(project)
.EnableNoRestore()
.EnableNoBuild()
.CombineWith(frameworks, (s, fx) => s
.SetFramework(fx)
));
.SetTargetPath(project)
.DisableRestore()
.SetTargets("VSTest")
Kielek marked this conversation as resolved.
Show resolved Hide resolved
.SetProperty("VSTestNoBuild", true)
);
}
});

Expand Down Expand Up @@ -488,6 +489,7 @@ string GetFolderRuntimeName(JsonDocument jsonDocument)
var folderRuntimeName = runtimeName switch
{
".NETCoreApp,Version=v6.0" => "net6.0",
".NETCoreApp,Version=v7.0" => "net7.0",
_ => throw new ArgumentOutOfRangeException(nameof(runtimeName), runtimeName,
"This value is not supported. You have probably introduced new .NET version to AutoInstrumentation")
};
Expand Down
21 changes: 0 additions & 21 deletions build/DotNetMSBuildSettings.cs

This file was deleted.

32 changes: 0 additions & 32 deletions build/DotNetMSBuildTasks.cs

This file was deleted.

29 changes: 27 additions & 2 deletions build/Extensions/DotNetSettingsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public static DotNetPublishSettings SetTargetPlatformAnyCPU(this DotNetPublishSe
public static DotNetTestSettings SetTargetPlatformAnyCPU(this DotNetTestSettings settings)
=> settings.SetTargetPlatform(MSBuildTargetPlatform.MSIL);

public static T SetTargetPlatformAnyCPU<T>(this T settings)
where T : MSBuildSettings
public static DotNetMSBuildSettings SetTargetPlatformAnyCPU(this DotNetMSBuildSettings settings)
=> settings.SetTargetPlatform(MSBuildTargetPlatform.MSIL);

public static DotNetPublishSettings SetTargetPlatform(this DotNetPublishSettings settings, MSBuildTargetPlatform platform)
Expand All @@ -29,13 +28,39 @@ public static DotNetTestSettings SetTargetPlatform(this DotNetTestSettings setti
: settings.SetProperty("Platform", GetTargetPlatform(platform));
}

public static DotNetMSBuildSettings SetTargetPlatform(this DotNetMSBuildSettings settings, MSBuildTargetPlatform platform)
{
return platform is null
? settings
: settings.SetProperty("Platform", GetTargetPlatform(platform));
}

public static DotNetTestSettings EnableTrxLogOutput(this DotNetTestSettings settings, string resultsDirectory)
{
return settings
.AddLoggers("trx")
.SetResultsDirectory(resultsDirectory);
}

public static DotNetMSBuildSettings EnableTrxLogOutput(this DotNetMSBuildSettings settings, string resultsDirectory)
Kielek marked this conversation as resolved.
Show resolved Hide resolved
{
return settings
.SetProperty("VSTestLogger", "trx")
.SetProperty("VSTestResultsDirectory", resultsDirectory);
}
public static DotNetMSBuildSettings SetBlameHangTimeout(this DotNetMSBuildSettings settings, string timeout)
{
return settings
.SetProperty("VSTestBlameHang", true)
.SetProperty("VSTestBlameHangTimeout", timeout);
}

public static DotNetMSBuildSettings SetFilter(this DotNetMSBuildSettings settings, string filter)
{
return settings
.SetProperty("VSTestTestCaseFilter", filter);
}

private static string GetTargetPlatform(MSBuildTargetPlatform platform) =>
platform == MSBuildTargetPlatform.MSIL ? "AnyCPU" : platform.ToString();
}
1 change: 1 addition & 0 deletions build/TargetFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class TargetFramework : Enumeration
{
public static readonly TargetFramework NET462 = new() { Value = "net462" };
public static readonly TargetFramework NET6_0 = new() { Value = "net6.0" };
public static readonly TargetFramework NET7_0 = new() { Value = "net7.0" };

public static readonly TargetFramework[] NetFramework = {
NET462
Expand Down
2 changes: 1 addition & 1 deletion build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..\..</NukeRootDirectory>
Expand Down
12 changes: 5 additions & 7 deletions docker/alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine3.16
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine3.16

RUN apk update \
&& apk upgrade \
Expand All @@ -16,11 +16,9 @@ ENV IsAlpine=true
ENV PROTOBUF_PROTOC=/usr/bin/protoc
ENV gRPC_PluginFullPath=/usr/bin/grpc_csharp_plugin

# Install older .NET SDKs using the install script
# will be needed when we switch to 7.0
# RUN curl -sSL https://dot.net/v1/dotnet-install.sh --output dotnet-install.sh \
# && chmod +x ./dotnet-install.sh \
# && ./dotnet-install.sh -c 3.1 --install-dir /usr/share/dotnet --no-path \
# && rm dotnet-install.sh
RUN curl -sSL https://dot.net/v1/dotnet-install.sh --output dotnet-install.sh \
&& chmod +x ./dotnet-install.sh \
&& ./dotnet-install.sh -c 6.0 --install-dir /usr/share/dotnet --no-path \
&& rm dotnet-install.sh

WORKDIR /project
2 changes: 1 addition & 1 deletion examples/AspNetCoreMvc/Examples.AspNetCoreMvc.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<RootNamespace>Examples.AspNetCoreMvc</RootNamespace>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;net462</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
Expand Down
2 changes: 1 addition & 1 deletion examples/ConsoleApp/Examples.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;net462</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion examples/Vendor.Distro/Examples.Vendor.Distro.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netstandard2.0;net462</TargetFrameworks>
<Version>0.0.1</Version>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion integrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"minimum_major": 3,
"minimum_minor": 1,
"minimum_patch": 0,
"maximum_major": 6,
"maximum_major": 7,
"maximum_minor": 65535,
"maximum_patch": 65535
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Target Name="CallComposeStore" AfterTargets="Publish">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace OpenTelemetry.AutoInstrumentation.Instrumentations.Logger;
ReturnTypeName = ClrNames.Void,
ParameterTypeNames = new[] { "Microsoft.Extensions.DependencyInjection.IServiceCollection" },
MinimumVersion = "3.1.0",
MaximumVersion = "6.*.*",
MaximumVersion = "7.*.*",
IntegrationName = "ILogger",
Type = InstrumentationType.Log)]
public class LoggingBuilderIntegration
Expand Down
2 changes: 1 addition & 1 deletion test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<!-- only run .NET Framework tests on Windows -->
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>

<!-- Hide warnings for EOL .NET Core targets (e.g. netcoreapp3.0) -->
Expand Down
Loading