Skip to content

Commit 3d2bf86

Browse files
authored
Don't rely on USERPROFILE to find the path to dotnet.exe (#803)
1 parent 238024d commit 3d2bf86

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

build/dependencies.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<MicrosoftBuildUtilitiesCorePackageVersion>15.6.82</MicrosoftBuildUtilitiesCorePackageVersion>
2222
<MicrosoftExtensionsBuffersMemoryPoolSourcesPackageVersion>2.2.0-preview1-34066</MicrosoftExtensionsBuffersMemoryPoolSourcesPackageVersion>
2323
<MicrosoftExtensionsBuffersSourcesPackageVersion>2.2.0-preview1-34066</MicrosoftExtensionsBuffersSourcesPackageVersion>
24+
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>2.2.0-preview1-34066</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
2425
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.2.0-preview1-34066</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
2526
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.2.0-preview1-34066</MicrosoftExtensionsConfigurationJsonPackageVersion>
2627
<MicrosoftExtensionsLoggingAbstractionsPackageVersion>2.2.0-preview1-34066</MicrosoftExtensionsLoggingAbstractionsPackageVersion>

test/IISIntegration.FunctionalTests/IISIntegration.FunctionalTests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010

1111
<ItemGroup>
1212
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Server.IISIntegration\Microsoft.AspNetCore.Server.IISIntegration.csproj" />
13-
<ProjectReference Include="..\WebSites\**\*.csproj" >
13+
<ProjectReference Include="..\WebSites\**\*.csproj">
1414
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
1515
</ProjectReference>
1616
</ItemGroup>
1717

1818
<ItemGroup>
1919
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(MicrosoftAspNetCoreServerIntegrationTestingPackageVersion)" />
20+
<PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion)" />
2021
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsLoggingPackageVersion)" />
2122
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
2223
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(MicrosoftExtensionsLoggingDebugPackageVersion)" />

test/IISIntegration.FunctionalTests/Inprocess/StartupTests.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
14
using System;
2-
using System.Collections.Generic;
35
using System.IO;
4-
using System.Linq;
56
using System.Net;
6-
using System.Threading;
77
using System.Threading.Tasks;
8-
using System.Xml.Linq;
98
using Microsoft.AspNetCore.Server.IntegrationTesting;
9+
using Microsoft.Extensions.CommandLineUtils;
1010
using Microsoft.Extensions.Logging;
1111
using Microsoft.Extensions.Logging.Testing;
1212
using Xunit;
1313
using Xunit.Abstractions;
1414
using Xunit.Sdk;
1515

16-
1716
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
1817
{
1918
public class StartupTests : LoggedTest
@@ -26,16 +25,20 @@ public StartupTests(ITestOutputHelper output) : base(output)
2625
[Fact]
2726
public async Task ExpandEnvironmentVariableInWebConfig()
2827
{
29-
var architecture = RuntimeArchitecture.x64;
30-
var dotnetLocation = $"%USERPROFILE%\\.dotnet\\{architecture.ToString()}\\dotnet.exe";
28+
#if NET461
29+
// use the dotnet on PATH
30+
var dotnetLocation = "dotnet";
31+
#else
32+
var dotnetLocation = DotNetMuxer.MuxerPathOrDefault();
33+
#endif
3134
using (StartLog(out var loggerFactory))
3235
{
3336
var logger = loggerFactory.CreateLogger("HelloWorldTest");
3437

3538
var deploymentParameters = GetBaseDeploymentParameters();
3639

3740
// Point to dotnet installed in user profile.
38-
deploymentParameters.EnvironmentVariables["DotnetPath"] = Environment.ExpandEnvironmentVariables(dotnetLocation); // Path to dotnet.
41+
deploymentParameters.EnvironmentVariables["DotnetPath"] = dotnetLocation;
3942

4043
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
4144
{
@@ -72,7 +75,7 @@ public async Task InvalidProcessPath_ExpectServerError()
7275
{
7376
var logger = loggerFactory.CreateLogger("HelloWorldTest");
7477
var deploymentParameters = GetBaseDeploymentParameters();
75-
78+
7679
// Point to dotnet installed in user profile.
7780
deploymentParameters.EnvironmentVariables["DotnetPath"] = Environment.ExpandEnvironmentVariables(dotnetLocation); // Path to dotnet.
7881

@@ -101,7 +104,7 @@ public async Task StandaloneApplication_ExpectCorrectPublish()
101104
using (StartLog(out var loggerFactory))
102105
{
103106
var logger = loggerFactory.CreateLogger("HelloWorldTest");
104-
107+
105108
var deploymentParameters = GetBaseDeploymentParameters();
106109

107110
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
@@ -171,7 +174,7 @@ public async Task StandaloneApplication_AbsolutePathToExe_ExpectCorrectPublish()
171174
#else
172175
#error Target frameworks need to be updated
173176
#endif
174-
177+
175178
[Fact]
176179
public async Task DetectsOveriddenServer()
177180
{

0 commit comments

Comments
 (0)