From 2ac3ece862cd6db3fbf08f93f0ec39f2b55cca9c Mon Sep 17 00:00:00 2001 From: vinayada1 <28875764+vinayada1@users.noreply.github.com> Date: Wed, 24 Feb 2021 10:46:23 -0800 Subject: [PATCH] framework --- test/Dapr.E2E.Test/DaprTestApp.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/Dapr.E2E.Test/DaprTestApp.cs b/test/Dapr.E2E.Test/DaprTestApp.cs index e526fc9b..1068da23 100644 --- a/test/Dapr.E2E.Test/DaprTestApp.cs +++ b/test/Dapr.E2E.Test/DaprTestApp.cs @@ -10,6 +10,7 @@ using System.Reflection; using System.Runtime.InteropServices; using Xunit.Abstractions; using static System.IO.Path; +using System.Runtime.Versioning; namespace Dapr.E2E.Test { @@ -32,15 +33,13 @@ namespace Dapr.E2E.Test public (string, string) Start() { - var targetFrameworkAttribute = Assembly.GetExecutingAssembly() - .GetCustomAttributes(typeof(System.Runtime.Versioning.TargetFrameworkAttribute), false) - .SingleOrDefault(); - + var frameworkName = GetTargetFrameworkName(); + testOutput.WriteLine($"frameworkname: {frameworkName}"); var (appPort, httpPort, grpcPort, metricsPort) = GetFreePorts(); var componentsPath = Combine(".", "..", "..", "..", "..", "..", "test", "Dapr.E2E.Test", "components"); var daprStartCommand = $" run --app-id {appId} --dapr-http-port {httpPort} --dapr-grpc-port {grpcPort} --metrics-port {metricsPort} --components-path {componentsPath}"; var projectPath = Combine(".", "..", "..", "..", "..", "..", "test", "Dapr.E2E.Test.App", "Dapr.E2E.Test.App.csproj"); - var daprDotnetCommand = $" -- dotnet run --project {projectPath} --framework netcoreapp3.1"; + var daprDotnetCommand = $" -- dotnet run --project {projectPath} --framework {frameworkName}"; if (this.useAppPort) { daprStartCommand += $" --app-port {appPort}"; @@ -76,6 +75,14 @@ namespace Dapr.E2E.Test testOutput.WriteLine($"Dapr app: {appId} stopped successfully"); } + private static string GetTargetFrameworkName() + { + var targetFrameworkName = ((TargetFrameworkAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(TargetFrameworkAttribute), false).FirstOrDefault()).FrameworkName; + string frameworkMoniker; + frameworkMoniker = targetFrameworkName == ".NETCoreApp,Version=v3.1" ? "netcoreapp3.1" : "net5"; + return frameworkMoniker; + } + private static (int, int, int, int) GetFreePorts() { const int NUM_LISTENERS = 4;