diff --git a/NuGet.config b/NuGet.config
index abef7d7e43..23206d2001 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -13,6 +13,7 @@
+
diff --git a/scripts/build.ps1 b/scripts/build.ps1
index a17998919e..5941903c34 100644
--- a/scripts/build.ps1
+++ b/scripts/build.ps1
@@ -570,7 +570,7 @@ function Create-VsixPackage
$testPlatformExternalsVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.TestPlatformExternalsVersion
# Copy legacy dependencies
- $legacyDir = Join-Path $env:TP_PACKAGES_DIR "Microsoft.Internal.TestPlatform.Extensions\$testPlatformExternalsVersion-patched4\contentFiles\any\any"
+ $legacyDir = Join-Path $env:TP_PACKAGES_DIR "Microsoft.Internal.TestPlatform.Extensions\$testPlatformExternalsVersion-patched5\contentFiles\any\any"
Copy-Item -Recurse $legacyDir\* $packageDir -Force
# Copy Microsoft.VisualStudio.ArchitectureTools.PEReader to Extensions
@@ -686,6 +686,10 @@ function Create-NugetPackages
# Pass Newtonsoft.Json version to nuget pack to keep the version consistent across all nuget packages.
$JsonNetVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.JsonNetVersion
+ # Additional external dependency folders
+ $microsoftFakesVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.MicrosoftFakesVersion
+ $FakesPackageDir = Join-Path $env:TP_PACKAGES_DIR "Microsoft.VisualStudio.TestPlatform.Fakes\$microsoftFakesVersion\lib"
+
# package them from stagingDir
foreach ($file in $nuspecFiles) {
$additionalArgs = ""
@@ -694,7 +698,7 @@ function Create-NugetPackages
}
Write-Verbose "$nugetExe pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version $additionalArgs"
- & $nugetExe pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version`;JsonNetVersion=$JsonNetVersion`;Runtime=$TPB_TargetRuntime`;NetCoreTargetFramework=$TPB_TargetFrameworkCore20 $additionalArgs
+ & $nugetExe pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version`;JsonNetVersion=$JsonNetVersion`;Runtime=$TPB_TargetRuntime`;NetCoreTargetFramework=$TPB_TargetFrameworkCore20`;FakesPackageDir=$FakesPackageDir $additionalArgs
Set-ScriptFailedOnError
}
diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props
index 1a5df47c2d..8d0c290a0e 100644
--- a/scripts/build/TestPlatform.Dependencies.props
+++ b/scripts/build/TestPlatform.Dependencies.props
@@ -32,6 +32,7 @@
9.0.1
4.7.63
16.0.0-preview-2148743
+ 16.6.3-beta.20169.2
16.0.461
$(MicrosoftBuildPackageVersion)
diff --git a/scripts/vsts-prebuild.ps1 b/scripts/vsts-prebuild.ps1
index 2114e74ea5..f49ad135a2 100644
--- a/scripts/vsts-prebuild.ps1
+++ b/scripts/vsts-prebuild.ps1
@@ -27,4 +27,8 @@ Write-Host "##vso[task.setvariable variable=PackageVersion;]$packageVersion"
# "Nuget.exe pack" required JsonNetVersion property for creating nuget package.
$JsonNetVersion = ([xml](Get-Content $TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.JsonNetVersion
-Write-Host "##vso[task.setvariable variable=JsonNetVersion;]$JsonNetVersion"
\ No newline at end of file
+Write-Host "##vso[task.setvariable variable=JsonNetVersion;]$JsonNetVersion"
+
+$microsoftFakesVersion = ([xml](Get-Content $TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.MicrosoftFakesVersion
+$FakesPackageDir = Join-Path $TP_ROOT_DIR "packages\Microsoft.VisualStudio.TestPlatform.Fakes\$microsoftFakesVersion\lib"
+Write-Host "##vso[task.setvariable variable=FakesPackageDir;]$FakesPackageDir"
diff --git a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs
index b772c39551..5f15e51c06 100644
--- a/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs
+++ b/src/Microsoft.TestPlatform.Common/Utilities/FakesUtilities.cs
@@ -7,9 +7,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
-#if NET451
using System.Reflection;
-#endif
using System.Xml;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
@@ -44,12 +42,6 @@ public static string GenerateFakesSettingsForRunConfiguration(string[] sources,
throw new ArgumentNullException(nameof(runSettingsXml));
}
- // do not generate fakes for netcore
- if (IsNetCoreFramework(runSettingsXml))
- {
- return runSettingsXml;
- }
-
var doc = new XmlDocument();
using (var xmlReader = XmlReader.Create(
new StringReader(runSettingsXml),
@@ -58,15 +50,17 @@ public static string GenerateFakesSettingsForRunConfiguration(string[] sources,
doc.Load(xmlReader);
}
- return !TryAddFakesDataCollectorSettings(doc, sources) ? runSettingsXml : doc.OuterXml;
+ return !TryAddFakesDataCollectorSettings(doc, sources, GetFramework(runSettingsXml))
+ ? runSettingsXml
+ : doc.OuterXml;
}
- private static bool IsNetCoreFramework(string runSettingsXml)
+ private static FrameworkVersion GetFramework(string runSettingsXml)
{
var config = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettingsXml);
-
- return config.TargetFramework.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0
- || config.TargetFramework.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0;
+#pragma warning disable CS0618 // Type or member is obsolete
+ return config.TargetFrameworkVersion;
+#pragma warning restore CS0618 // Type or member is obsolete
}
///
@@ -77,7 +71,8 @@ private static bool IsNetCoreFramework(string runSettingsXml)
/// true if runSettings was modified; false otherwise.
private static bool TryAddFakesDataCollectorSettings(
XmlDocument runSettings,
- IEnumerable sources)
+ IEnumerable sources,
+ FrameworkVersion framework)
{
// If user provided fakes settings don't do anything
if (XmlRunSettingsUtilities.ContainsDataCollector(runSettings.CreateNavigator(), FakesMetadata.DataCollectorUri))
@@ -85,16 +80,60 @@ private static bool TryAddFakesDataCollectorSettings(
return false;
}
- Func, string> configurator;
+ // A new Fakes Congigurator API makes the decision to add the right datacollector uri to the configuration
+ // There now exist two data collector URIs to support two different scenarios. The new scenario involves
+ // using the CLRIE profiler, and the old involves using the Intellitrace profiler (which isn't supported in
+ // .NET Core scenarios). The old API still exists for fallback measures.
- // fakes supported?
- if (!TryGetFakesDataCollectorConfigurator(out configurator))
+ var newConfigurator = TryGetFakesNewDataCollectorConfigurator();
+ if (newConfigurator != null)
+ {
+ var sourceTFMMap = CreateDictionary(sources, framework);
+ var fakesSettings = newConfigurator(sourceTFMMap);
+ XmlRunSettingsUtilities.InsertDataCollectorsNode(runSettings.CreateNavigator(), fakesSettings);
+ return true;
+ }
+
+ return AddFallbackFakesSettings(runSettings, sources, framework);
+ }
+
+ private static IDictionary CreateDictionary(IEnumerable sources, FrameworkVersion framework)
+ {
+ var dict = new Dictionary();
+ foreach(var source in sources)
+ {
+ if (!dict.ContainsKey(source))
+ {
+ dict.Add(source, framework);
+ }
+ }
+
+ return dict;
+ }
+
+ private static bool AddFallbackFakesSettings(
+ XmlDocument runSettings,
+ IEnumerable sources,
+ FrameworkVersion framework)
+ {
+
+ // The fallback settings is for the old implementation of fakes
+ // that only supports .Net Framework versions
+ if (framework != FrameworkVersion.Framework35 &&
+ framework != FrameworkVersion.Framework40 &&
+ framework != FrameworkVersion.Framework45)
+ {
+ return false;
+ }
+
+ Func, string> oldConfigurator = TryGetFakesDataCollectorConfigurator();
+ if (oldConfigurator == null)
{
return false;
}
// if no fakes, return settings unchanged
- var fakesConfiguration = configurator(sources);
+ var fakesConfiguration = oldConfigurator(sources);
if (fakesConfiguration == null)
{
return false;
@@ -116,6 +155,7 @@ private static bool TryAddFakesDataCollectorSettings(
fakesSettings.Configuration = doc.DocumentElement;
XmlRunSettingsUtilities.InsertDataCollectorsNode(runSettings.CreateNavigator(), fakesSettings);
+
return true;
}
@@ -138,22 +178,17 @@ private static void EnsureSettingsNode(XmlDocument settings, TestRunSettings set
}
}
- private static bool TryGetFakesDataCollectorConfigurator(out Func, string> configurator)
+ private static Func, string> TryGetFakesDataCollectorConfigurator()
{
#if NET451
try
{
Assembly assembly = Assembly.Load(FakesConfiguratorAssembly);
-
var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false);
- if (type != null)
+ var method = type?.GetMethod(ConfiguratorMethodName, new Type[] { typeof(IEnumerable) });
+ if (method != null)
{
- var method = type.GetMethod(ConfiguratorMethodName, BindingFlags.Public | BindingFlags.Static);
- if (method != null)
- {
- configurator = (Func, string>)method.CreateDelegate(typeof(Func, string>));
- return true;
- }
+ return (Func, string>)method.CreateDelegate(typeof(Func, string>));
}
}
catch (Exception ex)
@@ -164,8 +199,30 @@ private static bool TryGetFakesDataCollectorConfigurator(out Func, DataCollectorSettings> TryGetFakesNewDataCollectorConfigurator()
+ {
+ try
+ {
+ Assembly assembly = Assembly.Load(FakesConfiguratorAssembly);
+ var type = assembly?.GetType(ConfiguratorAssemblyQualifiedName, false);
+ var method = type?.GetMethod(ConfiguratorMethodName, new Type[] { typeof(IEnumerable), typeof(FrameworkVersion) });
+ if (method != null)
+ {
+ return (Func, DataCollectorSettings>)method.CreateDelegate(typeof(Func, DataCollectorSettings>));
+ }
+ }
+ catch (Exception ex)
+ {
+ if (EqtTrace.IsInfoEnabled)
+ {
+ EqtTrace.Info("Failed to create newly implemented Fakes Configurator. Reason:{0} ", ex);
+ }
+ }
+
+ return null;
}
///
@@ -205,4 +262,4 @@ internal static class FakesMetadata
public const string DataCollectorAssemblyQualifiedName = "Microsoft.VisualStudio.TraceCollector.UnitTestIsolationDataCollector, Microsoft.VisualStudio.TraceCollector, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
}
}
-}
+}
\ No newline at end of file
diff --git a/src/package/external/external.csproj b/src/package/external/external.csproj
index 19bf12b12a..fdf04d853d 100644
--- a/src/package/external/external.csproj
+++ b/src/package/external/external.csproj
@@ -50,7 +50,7 @@
All
- $(TestPlatformExternalsVersion)-patched4
+ $(TestPlatformExternalsVersion)-patched5
All
@@ -81,6 +81,10 @@
15.6.815-master284DF69C
All
+
+ $(MicrosoftFakesVersion)
+ All
+
diff --git a/src/package/nuspec/Microsoft.TestPlatform.nuspec b/src/package/nuspec/Microsoft.TestPlatform.nuspec
index ef6cf820dc..0b1e015931 100644
--- a/src/package/nuspec/Microsoft.TestPlatform.nuspec
+++ b/src/package/nuspec/Microsoft.TestPlatform.nuspec
@@ -142,7 +142,6 @@
-
@@ -456,5 +455,8 @@
+
+
+
diff --git a/src/package/sign/sign.proj b/src/package/sign/sign.proj
index 43e1f8d838..25db6a5c03 100644
--- a/src/package/sign/sign.proj
+++ b/src/package/sign/sign.proj
@@ -120,7 +120,6 @@
-