It is no longer necessary now that the whole runtime is being built together in dotnet/runtime repo.
#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.
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();
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"));
- }
-}
// 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);
_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"),
AppContextDepsFiles,
FxDepsFile,
ProbingDirectories,
- FxProductVersion,
StartUpHooks,
AppPaths,
AppNIPaths,
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;
}
}
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;
// 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;
++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());
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;
// See the LICENSE file in the project root for more information.
using System;
+using System.Runtime.InteropServices;
namespace PortableApp
{
{
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;
- }
}
}
// See the LICENSE file in the project root for more information.
using System;
+using System.Runtime.InteropServices;
namespace SharedFxLookupPortableApp
{
{
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;
- }
}
}
// See the LICENSE file in the project root for more information.
using System;
+using System.Runtime.InteropServices;
namespace StandaloneApp
{
{
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;
- }
}
}
{
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)
{
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
.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
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}
[Theory]
.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)
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}
}
}
[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()
{
var fixture = sharedState.RuntimePropertiesFixture
var fixture = sharedState.RuntimePropertiesFixture
.Copy();
- string name = "FX_PRODUCT_VERSION";
+ string name = "RUNTIME_IDENTIFIER";
RuntimeConfig.FromFile(fixture.TestProject.RuntimeConfigJson)
.WithProperty(name, sharedState.AppTestPropertyValue)
.Save();
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}
[Fact]
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}
[Fact]
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}
[Fact]
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}
[Fact]
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
- .And.HaveStdOutContaining($"Framework Version:{sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion}");
+ .And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
}
[Fact]
{
get
{
- // FX_PRODUCT_VERSION is expected to be set by the host
- // Use AssemblyInformationalVersionAttribute as fallback if the exact product version is not specified by the host
- string? versionString = AppContext.GetData("FX_PRODUCT_VERSION") as string ??
- typeof(object).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
+ string? versionString = typeof(object).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
ReadOnlySpan<char> versionSpan = versionString.AsSpan();
{
if (s_frameworkDescription == null)
{
- string? versionString = AppContext.GetData("FX_PRODUCT_VERSION") as string;
+ string? versionString = typeof(object).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
- if (versionString == null)
+ // Strip the git hash if there is one
+ if (versionString != null)
{
- // Use AssemblyInformationalVersionAttribute as fallback if the exact product version is not specified by the host
- versionString = typeof(object).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
-
- // Strip the git hash if there is one
- if (versionString != null)
+ int plusIndex = versionString.IndexOf('+');
+ if (plusIndex != -1)
{
- int plusIndex = versionString.IndexOf('+');
- if (plusIndex != -1)
- {
- versionString = versionString.Substring(0, plusIndex);
- }
+ versionString = versionString.Substring(0, plusIndex);
}
}