Skip to content

Commit 4f746ad

Browse files
Update projects to .NET 8.0 and enhance functionality
- Upgraded target framework from .NET 6.0/7.0 to .NET 8.0 across multiple projects. - Updated package references for Microsoft.Extensions libraries to versions compatible with .NET 8.0. - Fixed typo in logging message in `NetworkService` class. - Simplified `Runner` class constructor by directly initializing the logger. - Updated `NetworkService` reference in `Runner` to use constructor parameter. - Refactored OpenTelemetry configuration in `Program.cs` for better clarity. - Added new XAML files and code for a WinUI application, including `App.xaml` and `MainWindow.xaml`. - Created/updated application manifest and related files for WinUI support. - Added binary assets such as logos and splash screens for improved branding. - Updated `WindowsAppAnalytics` project to target .NET 8.0 with new package references.
1 parent dd2cf11 commit 4f746ad

24 files changed

+306
-57
lines changed

2_Libs/LoggingAndMetrics/LoggingSample/LoggingSample.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>
@@ -12,10 +12,10 @@
1212
<None Update="appsettings.json">
1313
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1414
</None>
15-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
16-
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
15+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
16+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
1717
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.21.0" />
18-
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="7.0.1" />
18+
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="8.0.14" />
1919
</ItemGroup>
2020

2121
</Project>

2_Libs/LoggingAndMetrics/LoggingSample/NetworkService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public async Task NetworkRequestSampleAsync(Uri requestUri)
3030
string result = await _httpClient.GetStringAsync(requestUri);
3131

3232
Console.WriteLine($"{result[..50]}");
33-
_logger.LogInformation(LoggingEvents.Networking, "NetworkRequestSampleAsync completed, received {lenght} characters", result.Length);
33+
_logger.LogInformation(LoggingEvents.Networking, "NetworkRequestSampleAsync completed, received {length} characters", result.Length);
3434
}
3535
catch (HttpRequestException ex)
3636
{

2_Libs/LoggingAndMetrics/LoggingSample/Runner.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
namespace LoggingSample;
44

5-
class Runner
5+
class Runner(NetworkService networkService, ILogger<Runner> logger)
66
{
7-
private readonly ILogger _logger;
8-
private readonly NetworkService _networkSevice;
9-
public Runner(NetworkService networkService, ILogger<Runner> logger)
10-
{
11-
_networkSevice = networkService;
12-
_logger = logger;
13-
}
7+
private readonly ILogger _logger = logger;
148

159
public async Task RunAsync()
1610
{
@@ -30,7 +24,7 @@ public async Task RunAsync()
3024
try
3125
{
3226
Uri uri = new(url);
33-
await _networkSevice.NetworkRequestSampleAsync(uri);
27+
await networkService.NetworkRequestSampleAsync(uri);
3428
}
3529
catch (UriFormatException ex)
3630
{

2_Libs/LoggingAndMetrics/MetricsSample/MetricsSample.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
12-
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
11+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
12+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
1313
</ItemGroup>
1414

1515
</Project>

2_Libs/LoggingAndMetrics/MetricsSample/Runner.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
namespace MetricsSample;
44

5-
class Runner
5+
class Runner(NetworkService networkService, ILogger<Runner> logger)
66
{
7-
private readonly ILogger _logger;
8-
private readonly NetworkService _networkSevice;
9-
public Runner(NetworkService networkService, ILogger<Runner> logger)
10-
{
11-
_networkSevice = networkService;
12-
_logger = logger;
13-
}
7+
private readonly ILogger _logger = logger;
148

159
public async Task RunAsync()
1610
{
@@ -26,7 +20,7 @@ public async Task RunAsync()
2620
try
2721
{
2822
Uri uri = new(url);
29-
await _networkSevice.NetworkRequestSampleAsync(uri);
23+
await networkService.NetworkRequestSampleAsync(uri);
3024
}
3125
catch (UriFormatException ex)
3226
{

2_Libs/LoggingAndMetrics/OpenTelemetrySample/OpenTelemetrySample.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
12-
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
13-
<PackageReference Include="OpenTelemetry" Version="1.2.0-rc1" />
14-
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.2.0-rc1" />
15-
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc8" />
16-
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
11+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
12+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
13+
<PackageReference Include="OpenTelemetry" Version="1.11.2" />
14+
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.11.2" />
15+
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.11.2" />
16+
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.11.1" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

2_Libs/LoggingAndMetrics/OpenTelemetrySample/Program.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@
3030
})
3131
.ConfigureServices(services =>
3232
{
33-
services.AddOpenTelemetryMetrics();
34-
services.AddOpenTelemetryTracing(builder =>
35-
{
36-
builder.AddConsoleExporter()
37-
.AddSource(Runner.SourceName)
38-
.SetResourceBuilder(
39-
ResourceBuilder.CreateDefault()
40-
.AddService(serviceName: "OpenTelemetrySample", serviceVersion: "1.0.0"))
41-
.AddHttpClientInstrumentation();
42-
});
33+
services.AddOpenTelemetry()
34+
.WithMetrics()
35+
.WithTracing(builder =>
36+
{
37+
builder.AddConsoleExporter()
38+
.AddSource(Runner.SourceName)
39+
.SetResourceBuilder(
40+
ResourceBuilder.CreateDefault()
41+
.AddService(serviceName: "OpenTelemetrySample", serviceVersion: "1.0.0"))
42+
.AddHttpClientInstrumentation();
43+
});
4344
services.Configure<OpenTelemetryLoggerOptions>(options =>
4445
{
4546
options.IncludeScopes = true;
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
10+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.14" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.14">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
17-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.1">
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.14" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.14">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
</PackageReference>
21-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.1" />
21+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" />
2222
</ItemGroup>
2323

2424
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Application
3+
x:Class="App1.App"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:local="using:App1">
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
<ResourceDictionary.MergedDictionaries>
10+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
11+
<!-- Other merged dictionaries here -->
12+
</ResourceDictionary.MergedDictionaries>
13+
<!-- Other app resources here -->
14+
</ResourceDictionary>
15+
</Application.Resources>
16+
</Application>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Microsoft.UI.Xaml;
2+
using Microsoft.UI.Xaml.Controls;
3+
using Microsoft.UI.Xaml.Controls.Primitives;
4+
using Microsoft.UI.Xaml.Data;
5+
using Microsoft.UI.Xaml.Input;
6+
using Microsoft.UI.Xaml.Media;
7+
using Microsoft.UI.Xaml.Navigation;
8+
using Microsoft.UI.Xaml.Shapes;
9+
10+
using System;
11+
using System.Collections.Generic;
12+
using System.IO;
13+
using System.Linq;
14+
using System.Runtime.InteropServices.WindowsRuntime;
15+
16+
using Windows.ApplicationModel;
17+
using Windows.ApplicationModel.Activation;
18+
using Windows.Foundation;
19+
using Windows.Foundation.Collections;
20+
21+
// To learn more about WinUI, the WinUI project structure,
22+
// and more about our project templates, see: http://aka.ms/winui-project-info.
23+
24+
namespace App1
25+
{
26+
/// <summary>
27+
/// Provides application-specific behavior to supplement the default Application class.
28+
/// </summary>
29+
public partial class App : Application
30+
{
31+
/// <summary>
32+
/// Initializes the singleton application object. This is the first line of authored code
33+
/// executed, and as such is the logical equivalent of main() or WinMain().
34+
/// </summary>
35+
public App()
36+
{
37+
this.InitializeComponent();
38+
}
39+
40+
/// <summary>
41+
/// Invoked when the application is launched.
42+
/// </summary>
43+
/// <param name="args">Details about the launch request and process.</param>
44+
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
45+
{
46+
m_window = new MainWindow();
47+
m_window.Activate();
48+
}
49+
50+
private Window? m_window;
51+
}
52+
}

0 commit comments

Comments
 (0)