From 3d2bf869c535911e2a867d1cd3188e4dfb80fa7b Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Tue, 1 May 2018 10:57:00 -0700 Subject: [PATCH] Don't rely on USERPROFILE to find the path to dotnet.exe (#803) --- build/dependencies.props | 1 + .../IISIntegration.FunctionalTests.csproj | 3 ++- .../Inprocess/StartupTests.cs | 25 +++++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 96b6b1e7de..a45d38b922 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -21,6 +21,7 @@ 15.6.82 2.2.0-preview1-34066 2.2.0-preview1-34066 + 2.2.0-preview1-34066 2.2.0-preview1-34066 2.2.0-preview1-34066 2.2.0-preview1-34066 diff --git a/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj b/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj index d79a5ec5d9..acaebe6958 100644 --- a/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj +++ b/test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj @@ -10,13 +10,14 @@ - + False + diff --git a/test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs b/test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs index 890bd248d3..a47e95aa99 100644 --- a/test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs +++ b/test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs @@ -1,19 +1,18 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; -using System.Threading; using System.Threading.Tasks; -using System.Xml.Linq; using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.Extensions.CommandLineUtils; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; using Xunit; using Xunit.Abstractions; using Xunit.Sdk; - namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { public class StartupTests : LoggedTest @@ -26,8 +25,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [Fact] public async Task ExpandEnvironmentVariableInWebConfig() { - var architecture = RuntimeArchitecture.x64; - var dotnetLocation = $"%USERPROFILE%\\.dotnet\\{architecture.ToString()}\\dotnet.exe"; +#if NET461 + // use the dotnet on PATH + var dotnetLocation = "dotnet"; +#else + var dotnetLocation = DotNetMuxer.MuxerPathOrDefault(); +#endif using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger("HelloWorldTest"); @@ -35,7 +38,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentParameters = GetBaseDeploymentParameters(); // Point to dotnet installed in user profile. - deploymentParameters.EnvironmentVariables["DotnetPath"] = Environment.ExpandEnvironmentVariables(dotnetLocation); // Path to dotnet. + deploymentParameters.EnvironmentVariables["DotnetPath"] = dotnetLocation; using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) { @@ -72,7 +75,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { var logger = loggerFactory.CreateLogger("HelloWorldTest"); var deploymentParameters = GetBaseDeploymentParameters(); - + // Point to dotnet installed in user profile. deploymentParameters.EnvironmentVariables["DotnetPath"] = Environment.ExpandEnvironmentVariables(dotnetLocation); // Path to dotnet. @@ -101,7 +104,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests using (StartLog(out var loggerFactory)) { var logger = loggerFactory.CreateLogger("HelloWorldTest"); - + var deploymentParameters = GetBaseDeploymentParameters(); using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) @@ -171,7 +174,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests #else #error Target frameworks need to be updated #endif - + [Fact] public async Task DetectsOveriddenServer() {