Skip to content

Commit

Permalink
Target Microsoft.ApplicationInsights.AspNetCore to netcoreapp3.1
Browse files Browse the repository at this point in the history
Remove package references to nugets Microsoft.AspNetCore.* because they are deprecated.
For AspNetCore -framework reference to Microsoft.AspNetCore.App is added.

microsoft#2811
  • Loading branch information
antymon4o committed Mar 28, 2024
1 parent e2d1d0b commit abdf428
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .props/_GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Update for every public release.
-->
<SemanticVersionMajor>2</SemanticVersionMajor>
<SemanticVersionMinor>22</SemanticVersionMinor> <!-- If changing the Minor version, also update the Date value. -->
<SemanticVersionMinor>23</SemanticVersionMinor> <!-- If changing the Minor version, also update the Date value. -->
<SemanticVersionPatch>0</SemanticVersionPatch>
<PreReleaseMilestone></PreReleaseMilestone> <!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone Condition="'$(Redfield)' == 'True'">redfield</PreReleaseMilestone>
Expand All @@ -23,7 +23,7 @@
as it will restart file versions so 2.4.0-beta1 may have higher
file version (like 2.4.0.2222) than 2.4.0-beta2 (like 2.4.0.1111)
-->
<SemanticVersionDate>2022-07-20</SemanticVersionDate>
<SemanticVersionDate>2024-03-28</SemanticVersionDate>

<!--
BuildNumber uniquely identifies all builds (The max allowed value is UInt16.MaxValue = 65535).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

<PropertyGroup>
<AssemblyName>Microsoft.ApplicationInsights.AspNetCore</AssemblyName>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>

<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp3.1</TargetFrameworks>
<DefineConstants>$(DefineConstants);AI_ASPNETCORE_WEB;</DefineConstants>
</PropertyGroup>

Expand All @@ -32,32 +32,10 @@
<ProjectReference Include="..\..\..\WEB\Src\WindowsServer\WindowsServer\WindowsServer.csproj" />
<ProjectReference Include="..\..\..\WEB\Src\EventCounterCollector\EventCounterCollector\EventCounterCollector.csproj" />
<ProjectReference Include="..\..\..\LOGGING\src\ILogger\ILogger.csproj" />

<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<!--
Microsoft.AspNetCore.Http has a vulnerability https://msrc.microsoft.com/update-guide/vulnerability/CVE-2020-1045
System.Text.Encodings.Web has a vulnerability https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-26701
These are both implicit dependencies from Microsoft.AspNetCore.Hosting.
(Microsoft.AspNetCore.Hosting > Microsoft.AspNetCore.Http)
(Microsoft.AspNetCore.Hosting > Microsoft.AspNetCore.Hosting.Abstractions > Microsoft.AspNetCore.Http.Abstractions > System.Text.Encodings.Web)
-->

<!--
Taking a dependency on Microsoft.AspNetCore.Hosting v2.2.0 would resolve this issue, but would also break support for NetCore v2.1.
Instead I'm taking a direct dependency on the fixed version Microsoft.AspNetCore.Http.
We can remove this when NetCore v2.1 reaches EOL on August 21, 2021.
-->
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.22" />

<!--
We must take a temporary dependency on this newer version until Microsoft.AspNetCore.Hosting updates their dependencies.
-->
<PackageReference Include="System.Text.Encodings.Web" Version="4.7.2" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$(PropsRoot)\Test.props" />


Expand Down Expand Up @@ -37,17 +37,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.39" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand All @@ -57,6 +46,14 @@
<PackageReference Include="xunit" Version="2.4.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.32" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.27" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
Expand Down
5 changes: 4 additions & 1 deletion NETCORE/test/FunctionalTests.MVC.Tests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public void ConfigureServices(IServiceCollection services)

services.AddSingleton(typeof(ITelemetryChannel), new InMemoryChannel());
services.AddApplicationInsightsTelemetry(applicationInsightsOptions);
services.AddMvc();
services.AddMvcCore(options => options.EnableEndpointRouting = false);

services.AddControllersWithViews()
.AddRazorRuntimeCompilation();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
2 changes: 2 additions & 0 deletions NETCORE/test/FunctionalTests.Utils/TelemetryTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ protected HttpResponseMessage ExecuteRequest(string requestPath, Dictionary<stri

using (HttpClient httpClient = new HttpClient(httpClientHandler, true))
{
httpClient.Timeout = TimeSpan.FromMilliseconds(TestListenerTimeoutInMs);

this.output.WriteLine($"{DateTime.Now:MM/dd/yyyy hh:mm:ss.fff tt}: Executing request: {requestPath}");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestPath);
if (headers != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task Get()
{
// Microsoft.com will return a redirect to a specific lang version.
// This redirect is not detected in versions older that Net6.0.
await hc.GetAsync("https://www.microsoft.com/en-us/").ContinueWith(t => { }); // ignore all errors
await hc.GetAsync("https://visualstudio.microsoft.com/msdn-platforms/").ContinueWith(t => { }); // ignore all errors
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void TestRequestWithRequestIdAndTraceParentHeader()
}

[Fact]
public void TestRequestWithRequestIdAndTraceParentHeaderWithW3CDisabled()
public void TestRequestWithRequestIdHeaderWithW3CDisabled()
{
try
{
Expand All @@ -239,8 +239,10 @@ public void TestRequestWithRequestIdAndTraceParentHeaderWithW3CDisabled()
{
// Both request id and traceparent
["Request-Id"] = "|8ee8641cbdd8dd280d239fa2121c7e4e.df07da90a5b27d93.",
["traceparent"] = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
["tracestate"] = "some=state",
// If traceparent is sent in the request, it seems that is has more priority then Request-Id
// so, do not send traceparent and tracestate if you want to use Request-Id and test Hierchical Tracing
//["traceparent"] = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
//["tracestate"] = "some=state",
["Correlation-Context"] = "k1=v1,k2=v2"
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.WebApiCompatShim" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
4 changes: 2 additions & 2 deletions NETCORE/test/FunctionalTests.WebApi.Tests/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<EndpointAddress>(endpointAddress);
services.AddSingleton(typeof(ITelemetryChannel), new InMemoryChannel() { EndpointAddress = endpointAddress.ConnectionString, DeveloperMode = true });
services.AddApplicationInsightsTelemetry(InProcessServer.IKey);
services.AddMvc();
services.AddMvcCore(options => options.EnableEndpointRouting = false);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -37,7 +37,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
app.UseMvc(routes =>
{
// Add the following route for porting Web API 2 controllers.
routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
routes.MapRoute("DefaultApi", "api/{controller}/{id?}");
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace Microsoft.Extensions.DependencyInjection.Test
using Microsoft.ApplicationInsights.AspNetCore.Tests;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.Extensions.Configuration;

public abstract class BaseTestClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse;
using Microsoft.ApplicationInsights.WindowsServer;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@
<PackageReference Include="Moq" Version="4.16.1" />
</ItemGroup>

<ItemGroup Condition="'$(IsNetCore)' == 'True'">
<!-- TODO: Can't switch to FrameworkReference yet;
'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version.
The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.' -->
<!--<FrameworkReference Include="Microsoft.AspNetCore.App" />-->

<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
</ItemGroup>

<ItemGroup>
<None Update="App.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
using Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.AspNetCore.Hosting.Internal;
using Xunit;

public class AspNetCoreEnvironmentTelemetryInitializerTests
Expand Down

0 comments on commit abdf428

Please sign in to comment.