Skip to content

Commit

Permalink
Delete FX_PRODUCT_VERSION host key/value pair (#35455)
Browse files Browse the repository at this point in the history
It is no longer necessary now that the whole runtime is being built together in dotnet/runtime repo.
  • Loading branch information
jkotas authored Apr 26, 2020
1 parent ae1b5b2 commit 7d4f73c
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 165 deletions.
74 changes: 6 additions & 68 deletions src/coreclr/src/vm/eventreporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
#include "eventreporter.h"
#include "typestring.h"
#include "debugdebugger.h"
#include "clrversion.h"

#include <configuration.h>

#include "../dlls/mscorrc/resource.h"

#include "getproductversionnumber.h"

//---------------------------------------------------------------------------------------
//
// A constructor for EventReporter. The header of the log is generated here.
Expand Down Expand Up @@ -90,35 +89,12 @@ EventReporter::EventReporter(EventReporterType type)
m_Description.Append(ssMessage);
}

BOOL fHasVersion = FALSE;
DWORD dwMajorVersion = 0;
DWORD dwMinorVersion = 0;
DWORD dwBuild = 0;
DWORD dwRevision = 0;
EventReporter::GetCoreCLRInstanceProductVersion(&dwMajorVersion, &dwMinorVersion, &dwBuild, &dwRevision);
m_Description.AppendPrintf(W("%lu.%lu.%lu.%lu\n"),dwMajorVersion, dwMinorVersion, dwBuild, dwRevision);
fHasVersion = TRUE;

if (!fHasVersion)
{
ssMessage.Clear();
if(!ssMessage.LoadResource(CCompRC::Optional, IDS_ER_UNKNOWN))
m_Description.Append(W("unknown\n"));
else
{
m_Description.Append(ssMessage);
m_Description.Append(W("\n"));
}
}
m_Description.Append(VER_FILEVERSION_STR_L);
m_Description.Append(W("\n"));

// Log the .NET Version if we can get it
LPCWSTR fxProductVersion = Configuration::GetKnobStringValue(W("FX_PRODUCT_VERSION"));
if (fxProductVersion != nullptr)
{
m_Description.Append(W(".NET Version: "));
m_Description.Append(fxProductVersion);
m_Description.Append(W("\n"));
}
m_Description.Append(W(".NET Version: "));
m_Description.Append(CLR_PRODUCT_VERSION_L);
m_Description.Append(W("\n"));

ssMessage.Clear();

Expand Down Expand Up @@ -723,41 +699,3 @@ void DoReportForUnhandledNativeException(PEXCEPTION_POINTERS pExceptionInfo)
reporter.Report();
}
}

// This function will return the product version of CoreCLR
// instance we are executing in.
void EventReporter::GetCoreCLRInstanceProductVersion(DWORD * pdwMajor, DWORD * pdwMinor, DWORD * pdwBuild, DWORD * pdwRevision)
{
STATIC_CONTRACT_THROWS;

// Get the instance of the runtime
HMODULE hModRuntime = GetCLRModule();
_ASSERTE(hModRuntime != NULL);

// Get the path to the runtime
PathString runtimePath;
DWORD ret = WszGetModuleFileName(hModRuntime, runtimePath);
if (ret != 0)
{
// Got the path - get the file version from the path
SString path;
path.Clear();
path.Append(runtimePath);
DWORD dwVersionMS = 0;
DWORD dwVersionLS = 0;
GetProductVersionNumber(path, &dwVersionMS, &dwVersionLS);

// Get the Major.Minor.Build.Revision details from the returned values
*pdwMajor = HIWORD(dwVersionMS);
*pdwMinor = LOWORD(dwVersionMS);
*pdwBuild = HIWORD(dwVersionLS);
*pdwRevision = LOWORD(dwVersionLS);
LOG((LF_CORDB, LL_INFO100, "GetCoreCLRInstanceVersion: Got CoreCLR version: %lu.%lu.%lu.%lu\n",
*pdwMajor, *pdwMinor, *pdwBuild, *pdwRevision));
}
else
{
// Failed to get the path
LOG((LF_CORDB, LL_INFO100, "GetCoreCLRInstanceVersion: Unable to get CoreCLR version.\n"));
}
}
2 changes: 0 additions & 2 deletions src/coreclr/src/vm/eventreporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class EventReporter
// Flag to indicate if the buffer is full
BOOL fBufferFull;

static void GetCoreCLRInstanceProductVersion(DWORD * pdwMajor, DWORD * pdwMinor, DWORD * pdwBuild, DWORD * pdwRevision);

public:
// Construct
EventReporter(EventReporterType type);
Expand Down
1 change: 0 additions & 1 deletion src/installer/corehost/cli/hostpolicy/coreclr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ namespace
_X("APP_CONTEXT_DEPS_FILES"),
_X("FX_DEPS_FILE"),
_X("PROBING_DIRECTORIES"),
_X("FX_PRODUCT_VERSION"),
_X("STARTUP_HOOKS"),
_X("APP_PATHS"),
_X("APP_NI_PATHS"),
Expand Down
1 change: 0 additions & 1 deletion src/installer/corehost/cli/hostpolicy/coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ enum class common_property
AppContextDepsFiles,
FxDepsFile,
ProbingDirectories,
FxProductVersion,
StartUpHooks,
AppPaths,
AppNIPaths,
Expand Down
1 change: 0 additions & 1 deletion src/installer/corehost/cli/hostpolicy/deps_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ void deps_resolver_t::init_known_entry_path(const deps_entry_t& entry, const pal
if (m_coreclr_path.empty() && ends_with(path, DIR_SEPARATOR + pal::string_t(LIBCORECLR_NAME), false))
{
m_coreclr_path = path;
m_coreclr_library_version = entry.library_version;
return;
}
}
Expand Down
8 changes: 0 additions & 8 deletions src/installer/corehost/cli/hostpolicy/deps_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ class deps_resolver_t
return m_fx_definitions;
}

const pal::string_t& get_coreclr_library_version() const
{
return m_coreclr_library_version;
}

bool is_framework_dependent() const
{
return m_is_framework_dependent;
Expand Down Expand Up @@ -255,9 +250,6 @@ class deps_resolver_t
// Special entry for coreclr path
pal::string_t m_coreclr_path;

// Special entry for coreclr library version
pal::string_t m_coreclr_library_version;

// The filepaths for the app custom deps
std::vector<pal::string_t> m_additional_deps_files;

Expand Down
11 changes: 0 additions & 11 deletions src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,6 @@ int hostpolicy_context_t::initialize(hostpolicy_init_t &hostpolicy_init, const a
++fx_curr;
}

pal::string_t clr_library_version;
if (resolver.is_framework_dependent())
{
clr_library_version = get_root_framework(fx_definitions).get_found_version();
}
else
{
clr_library_version = resolver.get_coreclr_library_version();
}

// Build properties for CoreCLR instantiation
pal::string_t app_base = resolver.get_app_dir();
coreclr_properties.add(common_property::TrustedPlatformAssemblies, probe_paths.tpa.c_str());
Expand All @@ -168,7 +158,6 @@ int hostpolicy_context_t::initialize(hostpolicy_init_t &hostpolicy_init, const a
coreclr_properties.add(common_property::AppContextDepsFiles, app_context_deps_str.c_str());
coreclr_properties.add(common_property::FxDepsFile, fx_deps_str.c_str());
coreclr_properties.add(common_property::ProbingDirectories, resolver.get_lookup_probe_directories().c_str());
coreclr_properties.add(common_property::FxProductVersion, clr_library_version.c_str());
coreclr_properties.add(common_property::RuntimeIdentifier, get_current_runtime_id(true /*use_fallback*/).c_str());

bool set_app_paths = false;
Expand Down
8 changes: 2 additions & 6 deletions src/installer/test/Assets/TestProjects/PortableApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.InteropServices;

namespace PortableApp
{
Expand All @@ -12,15 +13,10 @@ public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine(string.Join(Environment.NewLine, args));
Console.WriteLine($"Framework Version:{GetFrameworkVersionFromAppDomain()}");
Console.WriteLine(RuntimeInformation.FrameworkDescription);

// A small operation involving NewtonSoft.Json to ensure the assembly is loaded properly
var t = typeof(Newtonsoft.Json.JsonReader);
}

private static string GetFrameworkVersionFromAppDomain()
{
return System.AppDomain.CurrentDomain.GetData("FX_PRODUCT_VERSION") as string;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.InteropServices;

namespace SharedFxLookupPortableApp
{
Expand All @@ -12,15 +13,10 @@ public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine(string.Join(Environment.NewLine, args));
Console.WriteLine($"Framework Version:{GetFrameworkVersionFromAppDomain()}");
Console.WriteLine(RuntimeInformation.FrameworkDescription);

// A small operation involving NewtonSoft.Json to ensure the assembly is loaded properly
var t = typeof(Newtonsoft.Json.JsonReader);
}

private static string GetFrameworkVersionFromAppDomain()
{
return System.AppDomain.CurrentDomain.GetData("FX_PRODUCT_VERSION") as string;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.InteropServices;

namespace StandaloneApp
{
Expand All @@ -12,15 +13,10 @@ public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine(string.Join(Environment.NewLine, args));
Console.WriteLine($"Framework Version:{GetFrameworkVersionFromAppDomain()}");
Console.WriteLine(RuntimeInformation.FrameworkDescription);

// A small operation involving NewtonSoft.Json to ensure the assembly is loaded properly
var t = typeof(Newtonsoft.Json.JsonReader);
}

private static string GetFrameworkVersionFromAppDomain()
{
return System.AppDomain.CurrentDomain.GetData("FX_PRODUCT_VERSION") as string;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine(string.Join(Environment.NewLine, args));
Console.WriteLine($"Framework Version:{GetFrameworkVersionFromAppDomain()}");
Console.WriteLine(RuntimeInformation.FrameworkDescription);

#if WINDOWS
#if WINDOWS
Version osVersion = RtlGetVersion();
if (osVersion == null)
{
Expand All @@ -33,12 +33,7 @@ public static void Main(string[] args)
Console.WriteLine($"Reported OS version is lower than the true OS version - shims in use.");
}
}
#endif
}

private static string GetFrameworkVersionFromAppDomain()
{
return System.AppDomain.CurrentDomain.GetData("FX_PRODUCT_VERSION") as string;
#endif
}

#if WINDOWS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void AppHost_FrameworkDependent_Succeeds()
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);


// Verify running from within the working directory
Expand All @@ -276,7 +276,7 @@ public void AppHost_FrameworkDependent_Succeeds()
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}

[Theory]
Expand Down Expand Up @@ -315,7 +315,7 @@ public void AppHost_FrameworkDependent_GlobalLocation_Succeeds(bool useRegistere
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);

// Verify running from within the working directory
Command.Create(appExe)
Expand All @@ -329,7 +329,7 @@ public void AppHost_FrameworkDependent_GlobalLocation_Succeeds(bool useRegistere
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}
}

Expand Down
23 changes: 1 addition & 22 deletions src/installer/test/HostActivation.Tests/RuntimeProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,6 @@ public RuntimeProperties(RuntimeProperties.SharedTestState fixture)
sharedState = fixture;
}

[Fact]
public void CommonProperty_AppCanGetData()
{
var fixture = sharedState.RuntimePropertiesFixture
.Copy();

string name = "FX_PRODUCT_VERSION";
string value = fixture.RepoDirProvider.MicrosoftNETCoreAppVersion;

var dotnet = fixture.BuiltDotnet;
var appDll = fixture.TestProject.AppDll;
dotnet.Exec(appDll, name)
.EnvironmentVariable("COREHOST_TRACE", "1")
.CaptureStdErr()
.CaptureStdOut()
.Execute()
.Should().Pass()
.And.HaveStdErrContaining($"Property {name} = {value}")
.And.HaveStdOutContaining($"AppContext.GetData({name}) = {value}");
}

[Fact]
public void AppConfigProperty_AppCanGetData()
{
Expand Down Expand Up @@ -102,7 +81,7 @@ public void DuplicateCommonProperty_Fails()
var fixture = sharedState.RuntimePropertiesFixture
.Copy();

string name = "FX_PRODUCT_VERSION";
string name = "RUNTIME_IDENTIFIER";
RuntimeConfig.FromFile(fixture.TestProject.RuntimeConfigJson)
.WithProperty(name, sharedState.AppTestPropertyValue)
.Save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void Running_Build_Output_Standalone_EXE_with_DepsJson_and_RuntimeConfig_
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}

[Fact]
Expand All @@ -59,7 +59,7 @@ public void Running_Publish_Output_Standalone_EXE_with_DepsJson_and_RuntimeConfi
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}

[Fact]
Expand Down Expand Up @@ -136,7 +136,7 @@ public void Running_Publish_Output_Standalone_EXE_By_Renaming_apphost_exe_Succee
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}

[Fact]
Expand Down Expand Up @@ -172,7 +172,7 @@ public void Running_Publish_Output_Standalone_EXE_With_Relative_Embedded_Path_Su
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}

[Fact]
Expand Down Expand Up @@ -234,7 +234,7 @@ public void Running_Publish_Output_Standalone_EXE_with_Bound_AppHost_Succeeds()
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}

[Fact]
Expand Down
Loading

0 comments on commit 7d4f73c

Please sign in to comment.