Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

[release/3.1] Remove duplicate entries from dotnet --info #9186

Merged
merged 1 commit into from
Oct 22, 2021

Conversation

ericstj
Copy link
Member

@ericstj ericstj commented Oct 15, 2021

Backport of dotnet/runtime#60446

Tests not ported due to missing infrastructure

Customer Impact

Customers see duplicate entries in dotnet --info for all SDKs and all frameworks when running in the default install on Windows. Regression introduced in RC2. This isn't blocking but it looks pretty bad.

Testing

Manually tested end-to-end to verify fix (shown below). Added automated regression test.

Risk

Very low. Leverages existing method in a new place.

Root cause

We are writing a trailing slash on InstallLocation and the host didn't remove this when considering paths (though it does for other paths). The result is that it considers C:\Program Files\dotnet and C:\Program Files\dotnet\ to be separate paths, causing duplicates. Fixing this to avoid the trailing slash in the installer requires a custom action. The reason it worked before was because the installer was using hard-coded strings to write these values. We changed that in ARM64 work to calculate these directories. MSI insists on directories ending in a trailing slash.

Result before:

dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.2.21505.57
 Commit:    ab39070116

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\

Host (useful for support):
  Version: 6.0.0-rc.2.21480.5
  Commit:  6b11d64e7e

.NET SDKs installed:
  5.0.202 [C:\Program Files\dotnet\sdk]
  5.0.202 [C:\Program Files\dotnet\sdk]
  5.0.400-preview.21328.4 [C:\Program Files\dotnet\sdk]
  5.0.400-preview.21328.4 [C:\Program Files\dotnet\sdk]
  6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk]
  6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.6.21355.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.6.21355.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.6.21352.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.6.21352.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21418.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21418.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.6.21353.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.6.21353.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

After:

dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.2.21505.57
 Commit:    ab39070116

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\

Host (useful for support):
  Version: 7.0.0-dev
  Commit:  N/A

.NET SDKs installed:
  5.0.202 [C:\Program Files\dotnet\sdk]
  5.0.400-preview.21328.4 [C:\Program Files\dotnet\sdk]
  6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.6.21355.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.6.21352.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21418.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.6.21353.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

@ericstj ericstj added the Servicing-consider Issue for next servicing release review label Oct 15, 2021
@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Oct 19, 2021
@leecow
Copy link
Member

leecow commented Oct 19, 2021

Can go into November if we rebuild. Otherwise, December.

@ericstj
Copy link
Member Author

ericstj commented Oct 20, 2021

There is a host test failure here we should look at.

@ericstj
Copy link
Member Author

ericstj commented Oct 20, 2021

https://dev.azure.com/dnceng/_apis/resources/Containers/8495699/Logs-Windows_x64-Debug?itemPath=Logs-Windows_x64-Debug%2Fartifacts%2Flog%2FDebug%2FHostActivation.Tests_netcoreapp3.0_x64.log

      Expected command to pass but it did not."
File Name: D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\dotnet.exe
Arguments: --fx-version 9999.0.1 D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.dll
Exit Code: 57005
StdOut:

StdErr:
Tracing enabled @ Fri Oct 15 22:42:34 2021 GMT
--- Invoked dotnet [version: 3.1.21, commit hash: fbf38451056e873132e3f109a09b46cd71b84f21] main = {
D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\dotnet.exe
--fx-version
9999.0.1
D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.dll
}
Reading fx resolver directory=[D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\host\fxr]
Considering fxr version=[3.1.21]...
Detected latest fxr version=[D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\host\fxr\3.1.21]...
Resolved fxr [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\host\fxr\3.1.21\hostfxr.dll]...
Loaded library from D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\host\fxr\3.1.21\hostfxr.dll
Invoking fx resolver [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\host\fxr\3.1.21\hostfxr.dll] v2
Host path: [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\dotnet.exe]
Dotnet path: [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\]
App path: [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\dotnet.dll]
Tracing enabled @ Fri Oct 15 22:42:34 2021 GMT
--- Invoked hostfxr_main_startupinfo [commit hash: fbf38451056e873132e3f109a09b46cd71b84f21]
Checking if CoreCLR path exists=[D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\coreclr.dll]
--- Executing in muxer mode...
Parsed known arg --fx-version = 9999.0.1
Using the provided arguments to determine the application to execute.
Using dotnet root path [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\]
App runtimeconfig.json from [D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.dll]
Runtime config is cfg=D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.runtimeconfig.json dev=D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.runtimeconfig.dev.json
Attempting to read runtime config: D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.runtimeconfig.json
Attempting to read dev runtime config: D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.runtimeconfig.dev.json
Runtime config [D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.runtimeconfig.json] is valid=[1]
--- The specified framework 'Microsoft.NETCore.App', version '9999.0.1', apply_patches=0, version_compatibility_range=exact is compatible with the previously referenced version '9999.0.1'.
--- Resolving FX directory, name 'Microsoft.NETCore.App' version '9999.0.1'
Searching FX directory in [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe]
Did not roll forward because apply_patches=0, version_compatibility_range=exact chose [9999.0.1]
Chose FX version [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1]
Runtime config is cfg=D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1\Microsoft.NETCore.App.runtimeconfig.json dev=D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1\Microsoft.NETCore.App.runtimeconfig.dev.json
Attempting to read runtime config: D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1\Microsoft.NETCore.App.runtimeconfig.json
Attempting to read dev runtime config: D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1\Microsoft.NETCore.App.runtimeconfig.dev.json
Runtime config [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1\Microsoft.NETCore.App.runtimeconfig.json] is valid=[1]
--- Summary of all frameworks:
     framework:'Microsoft.NETCore.App', lowest requested version='9999.0.1', found version='9999.0.1', effective reference version='9999.0.1' apply_patches=0, version_compatibility_range=exact, roll_to_highest_version=0, folder=D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1
Ignoring host interpreted additional probing path C:\Users\cloudtest\.dotnet\store\x64\netcoreapp3.1 as it does not exist.
Executing as a framework-dependent app as per config file [D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.runtimeconfig.json]
--- Resolving hostpolicy.dll version from deps json [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1\Microsoft.NETCore.App.deps.json]
Resolved version 3.1.21 from dependency manifest file [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1\Microsoft.NETCore.App.deps.json]
Did not find hostpolicy.dll in directory C:\Program Files (x86)\coreservicing\pkgs\runtime.win-x64.Microsoft.NETCore.DotNetHostPolicy\3.1.21\runtimes\win-x64\native
The expected hostpolicy.dll directory is [D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1]
Loaded library from D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\shared\Microsoft.NETCore.App\9999.0.1\hostpolicy.dll
Tracing enabled @ Fri Oct 15 22:42:34 2021 GMT
Reading from host interface version: [0x16041101:240] to initialize policy version: [0x16041101:240]
--- Invoked hostpolicy [commit hash: fbf38451056e873132e3f109a09b46cd71b84f21] [runtime.win-x64.Microsoft.NETCore.DotNetHostPolicy,3.1.21,runtimes/win-x64/native][x64] corehost_main = {
D:\a\_work\1\s\artifacts\tests\Debug\ha\dotnetMultilevelSharedFxLookup\0\exe\dotnet.exe
D:\a\_work\1\s\artifacts\tests\Debug\ha\1\SharedFxLookupPortableApp\bin\SharedFxLookupPortableApp.dll
}
Deps file: 
Additional probe dir: D:\a\_work\1\s\artifacts\obj\TestPackageCache
Can't get the size of the SDK location registry value or it's empty, result: 0x2
"
      Stack Trace:
           at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message)
           at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)
           at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message)
           at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args)
        /_/src/test/TestUtils/Assertions/CommandResultAssertions.cs(31,0): at Microsoft.DotNet.CoreSetup.Test.CommandResultAssertions.Pass()
        /_/src/test/HostActivation.Tests/MultilevelSharedFxLookup.cs(274,0): at Microsoft.DotNet.CoreSetup.Test.HostActivation.MultilevelSharedFxLookup.SharedMultilevelFxLookup_Must_Not_Roll_Forward_If_Framework_Version_Is_Specified_Through_Argument()

@ericstj
Copy link
Member Author

ericstj commented Oct 20, 2021

Interesting part of that log is Can't get the size of the SDK location registry value or it's empty, result: 0x2

Which is from

result = ::RegGetValueW(hkey, nullptr, value, RRF_RT_REG_SZ, nullptr, nullptr, &size);
if (result != ERROR_SUCCESS || size == 0)
{
trace::verbose(_X("Can't get the size of the SDK location registry value or it's empty, result: 0x%X"), result);
::RegCloseKey(hkey);
return false;
}

The test that's failing is

dotnet.Exec("--fx-version", "9999.0.1", appDll)
.WorkingDirectory(_currentWorkingDir)
.WithUserProfile(_userDir)
.EnvironmentVariable("COREHOST_TRACE", "1")
.EnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "1")
.EnvironmentVariable(Constants.TestOnlyEnvironmentVariables.GloballyRegisteredPath, _regDir)
.CaptureStdOut()
.CaptureStdErr()
.Execute()
.Should().Pass()
.And.HaveStdErrContaining(Path.Combine(_exeSelectedMessage, "9999.0.1"));

Which sets

public const string GloballyRegisteredPath = "_DOTNET_TEST_GLOBALLY_REGISTERED_PATH";

Which should have short-circuited the failing line here:

if (test_only_getenv(_X("_DOTNET_TEST_GLOBALLY_REGISTERED_PATH"), &environmentOverride))
{
recv->assign(environmentOverride);
return true;
}

Perhaps something is going wrong enabling Test-only behavior. @vitek-karas any ideas?

@ericstj
Copy link
Member Author

ericstj commented Oct 20, 2021

I have a local repro of this, will debug when I have a chance.

@ericstj
Copy link
Member Author

ericstj commented Oct 20, 2021

I may have spoken too soon. The local repro I see is a different failing test (MultipleHives) which is failing because dotnet.exe is being passed an empty assembly to run.

File.WriteAllText(Path.Combine(testAppDir, "FrameworkReferenceApp.dll"), string.Empty);

@ericstj ericstj force-pushed the fixDuplicateDotnetInfo-3.1 branch from 2e20516 to 3201788 Compare October 20, 2021 18:49
@ericstj
Copy link
Member Author

ericstj commented Oct 22, 2021

We will be rebuilding for 3.1 so merging this.

@ericstj ericstj merged commit 5714f72 into dotnet:release/3.1 Oct 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants