From 5cbbe28169f350057e0abe2665904663e22ebebd Mon Sep 17 00:00:00 2001
From: Medeni Baykal <433724+Haplois@users.noreply.github.com>
Date: Wed, 10 Mar 2021 15:33:49 +0100
Subject: [PATCH] Missing assembly added to TestAdapter package.

---
 TestFx.sln                                    |  5 +--
 scripts/Build.ps1                             | 42 +++++++++++--------
 scripts/common.lib.ps1                        |  6 ++-
 src/Package/MSTest.TestAdapter.Enu.nuspec     |  9 ++--
 src/Package/MSTest.TestAdapter.nuspec         |  5 ++-
 src/Package/MSTest.TestAdapter.symbols.nuspec | 12 +++---
 src/Package/MSTest.TestFramework.enu.nuspec   | 18 ++++----
 .../MSTest.TestFramework.symbols.nuspec       | 14 +++----
 8 files changed, 63 insertions(+), 48 deletions(-)

diff --git a/TestFx.sln b/TestFx.sln
index 33d02154c5..71f533abb3 100644
--- a/TestFx.sln
+++ b/TestFx.sln
@@ -86,7 +86,6 @@ EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{E374A3A6-C364-4890-B315-D60F5C682B6E}"
 	ProjectSection(SolutionItems) = preProject
 		src\Package\MSTest.Internal.TestFx.Documentation.nuspec = src\Package\MSTest.Internal.TestFx.Documentation.nuspec
-		src\Package\MSTest.TestAdapter.Dotnet.nuspec = src\Package\MSTest.TestAdapter.Dotnet.nuspec
 		src\Package\MSTest.TestAdapter.Enu.nuspec = src\Package\MSTest.TestAdapter.Enu.nuspec
 		src\Package\MSTest.TestAdapter.nuspec = src\Package\MSTest.TestAdapter.nuspec
 		src\Package\MSTest.TestAdapter.symbols.nuspec = src\Package\MSTest.TestAdapter.symbols.nuspec
@@ -142,8 +141,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "targets", "targets", "{F60B
 	ProjectSection(SolutionItems) = preProject
 		scripts\build\TestFx.Loc.targets = scripts\build\TestFx.Loc.targets
 		scripts\build\TestFx.Settings.targets = scripts\build\TestFx.Settings.targets
-		scripts\build\TestFx.Versions.targets = scripts\build\TestFx.Versions.targets
 		scripts\build\TestFx.targets = scripts\build\TestFx.targets
+		scripts\build\TestFx.Versions.targets = scripts\build\TestFx.Versions.targets
 	EndProjectSection
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{BCF525B1-E67F-486D-B091-06A8BB8A2793}"
@@ -186,7 +185,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeploymentTestProjectNetCor
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TimeoutTestProjectNetCore", "test\E2ETests\TestAssets\TimeoutTestProjectNetCore\TimeoutTestProjectNetCore.csproj", "{ED27A844-6870-4FE6-8FEF-3ABDD1ED6564}"
 EndProject
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpTestProject", "test\E2ETests\TestAssets\FSharpTestProject\FSharpTestProject.fsproj", "{E5E58613-82FC-44CD-B75F-4F1C7ED52D0D}"
+Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpTestProject", "test\E2ETests\TestAssets\FSharpTestProject\FSharpTestProject.fsproj", "{E5E58613-82FC-44CD-B75F-4F1C7ED52D0D}"
 EndProject
 Global
 	GlobalSection(SharedMSBuildProjectFiles) = preSolution
diff --git a/scripts/Build.ps1 b/scripts/Build.ps1
index 618ab1f4d3..1e83bcd096 100644
--- a/scripts/Build.ps1
+++ b/scripts/Build.ps1
@@ -49,6 +49,9 @@ Param(
   [Alias("tpv")]
   [string] $TestPlatformVersion = $null,
 
+  [Alias("np")]
+  [Switch] $DisallowPrereleaseMSBuild,
+
   [Alias("f")]
   [Switch] $Force, 
 
@@ -111,20 +114,23 @@ function Print-Help {
   Write-Host -object ""
   Write-Host -object "********* MSTest Adapter Build Script *********"
   Write-Host -object ""
-  Write-Host -object "  Help (-h)                     - [Switch] - Prints this help message."
-  Write-Host -object "  Clean (-cl)                   - [Switch] - Indicates that this should be a clean build."
-  Write-Host -object "  SkipRestore (-sr)             - [Switch] - Indicates nuget package restoration should be skipped."
-  Write-Host -object "  ClearPackageCache (-cache)    - [Switch] - Indicates local package cache should be cleared before restore."
-  Write-Host -object "  Updatexlf (-uxlf)             - [Switch] - Indicates that there are resource changes and that these need to be copied to other languages as well."
-  Write-Host -object "  IsLocalizedBuild (-loc)       - [Switch] - Indicates that the build needs to generate resource assemblies as well."
-  Write-Host -object "  Official                      - [Switch] - Indicates that this is an official build. Only used in CI builds."
-  Write-Host -object "  Full                          - [Switch] - Indicates to perform a full build which includes Adapter, Framework"
+  Write-Host -object "  Help (-h)                        - [switch]   - Prints this help message."
+  Write-Host -object "  Clean (-cl)                      - [switch]   - Indicates that this should be a clean build."
+  Write-Host -object "  SkipRestore (-sr)                - [switch]   - Indicates nuget package restoration should be skipped."
+  Write-Host -object "  ClearPackageCache (-cache)       - [switch]   - Indicates local package cache should be cleared before restore."
+  Write-Host -object "  Updatexlf (-uxlf)                - [switch]   - Indicates that there are resource changes and that these need to be copied to other languages as well."
+  Write-Host -object "  IsLocalizedBuild (-loc)          - [switch]   - Indicates that the build needs to generate resource assemblies as well."
+  Write-Host -object "  Official                         - [switch]   - Indicates that this is an official build. Only used in CI builds."
+  Write-Host -object "  Full                             - [switch]   - Indicates to perform a full build which includes Adapter, Framework"
+  Write-Host -object "  DisallowPrereleaseMSBuild (-np)  - [switch]   - Uses an RTM version of MSBuild to build the projects"
+  Write-Host -object ""                                               
+  Write-Host -object "  Configuration (-c)               - [string]   - Specifies the build configuration. Defaults to 'Debug'."
+  Write-Host -object "  FrameworkVersion (-fv)           - [string]   - Specifies the version of the Test Framework nuget package."
+  Write-Host -object "  AdapterVersion (-av)             - [string]   - Specifies the version of the Test Adapter nuget package."
+  Write-Host -object "  VersionSuffix (-vs)              - [string]   - Specifies the version suffix for the nuget packages."
+  Write-Host -object "  Target                           - [string]   - Specifies the build target. Defaults to 'Build'."
   Write-Host -object ""
-  Write-Host -object "  Configuration (-c)            - [String] - Specifies the build configuration. Defaults to 'Debug'."
-  Write-Host -object "  FrameworkVersion (-fv)        - [String] - Specifies the version of the Test Framework nuget package."
-  Write-Host -object "  AdapterVersion (-av)          - [String] - Specifies the version of the Test Adapter nuget package."
-  Write-Host -object "  VersionSuffix (-vs)           - [String] - Specifies the version suffix for the nuget packages."
-  Write-Host -object "  Target                        - [String] - Specifies the build target. Defaults to 'Build'."
+  Write-Host -object "  Steps (-s)                       - [string[]] - List of build steps to run, valid steps: `"UpdateTPVersion`", `"Restore`", `"Build`", `"Publish`""
 
   Write-Host -object ""
   Exit 0
@@ -259,6 +265,8 @@ function Create-NugetPackages {
     Copy-Item $tfSrcPackageDir\$file $stagingDir -Force
   }
 
+  Copy-Item -Path "$($env:TF_PACKAGES_DIR)\microsoft.testplatform.adapterutilities\$TestPlatformVersion\lib" -Destination "$($stagingDir)\Microsoft.TestPlatform.AdapterUtilities" -Recurse -Force
+
   # Copy over LICENSE file to staging directory
   $licenseFilePath = Join-Path $env:TF_ROOT_DIR "LICENSE"
   Copy-Item $licenseFilePath $stagingDir -Force
@@ -279,7 +287,7 @@ function Create-NugetPackages {
     }
 
     Write-Verbose "$nugetExe pack $stagingDir\$file -OutputDirectory $packageOutDir -Version=$version -Properties Version=$version"
-    & $nugetExe pack $stagingDir\$file -OutputDirectory $packageOutDir -Version $version -Properties Version=$version`;Srcroot=$env:TF_SRC_DIR`;Packagesroot=$env:TF_PACKAGES_DIR
+    & $nugetExe pack $stagingDir\$file -OutputDirectory $packageOutDir -Version $version -Properties Version=$version`;Srcroot=$env:TF_SRC_DIR`;Packagesroot=$env:TF_PACKAGES_DIR`;TestPlatformVersion=$TestPlatformVersion
 
     if ($lastExitCode -ne 0) {
       throw "Nuget pack failed with an exit code of '$lastExitCode'."
@@ -299,17 +307,15 @@ function Replace-InFile($File, $RegEx, $ReplaceWith) {
 }
 
 function Sync-PackageVersions {
-  $versionsFile = "$PSScriptRoot\build\TestFx.Versions.targets"
-
   $versionsRegex = '(?mi)<(TestPlatformVersion.*?)>(.*?)<\/TestPlatformVersion>'
   $packageRegex = '(?mi)<package id="Microsoft\.TestPlatform([0-9a-z.]+)?" version="([0-9a-z.-]*)"'
   $sourceRegex = '(?mi)(.+[a-z =]+\@\")Microsoft\.TestPlatform\.([0-9.-a-z]+)\";'
 
   if ([String]::IsNullOrWhiteSpace($TestPlatformVersion)) {
-    $TestPlatformVersion = (([XML](Get-Content $versionsFile)).Project.PropertyGroup.TestPlatformVersion).InnerText
+    $TestPlatformVersion = (([XML](Get-Content $TF_VERSIONS_FILE)).Project.PropertyGroup.TestPlatformVersion).InnerText
   }
   else {
-    Replace-InFile -File $versionsFile -RegEx $versionsRegex -ReplaceWith "<`$1>$TestPlatformVersion</TestPlatformVersion>"
+    Replace-InFile -File $TF_VERSIONS_FILE -RegEx $versionsRegex -ReplaceWith "<`$1>$TestPlatformVersion</TestPlatformVersion>"
   }
 
   (Get-ChildItem "$PSScriptRoot\..\src\*packages.config", "$PSScriptRoot\..\test\*packages.config" -Recurse) | ForEach-Object {
diff --git a/scripts/common.lib.ps1 b/scripts/common.lib.ps1
index 213eae1fe1..91785b438c 100644
--- a/scripts/common.lib.ps1
+++ b/scripts/common.lib.ps1
@@ -20,6 +20,10 @@ $env:TF_SRC_DIR = Join-Path $env:TF_ROOT_DIR "src"
 $env:TF_TEST_DIR = Join-Path $env:TF_ROOT_DIR "test"
 $env:TF_PACKAGES_DIR = Join-Path $env:TF_ROOT_DIR "packages"
 
+$TF_VERSIONS_FILE = "$PSScriptRoot\build\TestFx.Versions.targets"
+if ([String]::IsNullOrWhiteSpace($TestPlatformVersion)) {
+    $TestPlatformVersion = (([XML](Get-Content $TF_VERSIONS_FILE)).Project.PropertyGroup.TestPlatformVersion).InnerText
+}
 
 function Create-Directory([string[]] $path) {
   if (!(Test-Path -path $path)) {
@@ -136,7 +140,7 @@ function Locate-VsInstallPath($hasVsixExtension = "false") {
 
   Write-Verbose "$vswhere -latest -products * -requires $requiredPackageIds -property installationPath"
   try {
-    if ($Official) {
+    if ($Official -or $DisallowPrereleaseMSBuild) {
       $vsInstallPath = & $vswhere -latest -products * -requires $requiredPackageIds -property installationPath
     }
     else {
diff --git a/src/Package/MSTest.TestAdapter.Enu.nuspec b/src/Package/MSTest.TestAdapter.Enu.nuspec
index 03e0416cc1..2982e37653 100644
--- a/src/Package/MSTest.TestAdapter.Enu.nuspec
+++ b/src/Package/MSTest.TestAdapter.Enu.nuspec
@@ -24,16 +24,16 @@
     <dependencies>
       <group targetFramework="netcoreapp1.0">
         <dependency id="NETStandard.Library" version="1.6.1" />
-        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="[16.9.1, )" />
+        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="$TestPlatformVersion$" />
         <dependency id="System.Diagnostics.TextWriterTraceListener" version="4.3.0" />
       </group>
 
       <group targetFramework="net45">
-        <dependency id="Microsoft.TestPlatform.AdapterUtilities" />
+        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="$TestPlatformVersion$" />
       </group>
 
       <group targetFramework="uap10.0">
-        <dependency id="Microsoft.TestPlatform.AdapterUtilities" />
+        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="$TestPlatformVersion$" />
       </group>
     </dependencies>
   </metadata>
@@ -46,15 +46,18 @@
     <!-- NetCore -->
     <file src="Build\NetCore\MSTest.TestAdapter.props" target="build\netcoreapp1.0\" />
     <file src="PlatformServices.NetCore\netstandard1.5\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll" target="build\netcoreapp1.0\" />
+    <file src="Microsoft.TestPlatform.AdapterUtilities\netstandard1.0\" target="build\netcoreapp1.0\" />
 
     <!-- UWP -->
     <file src="Build\Universal\MSTest.TestAdapter.props" target="build\uap10.0\MSTest.TestAdapter.props" />
     <file src="Build\Universal\MSTest.TestAdapter.targets" target="build\uap10.0\MSTest.TestAdapter.targets" />
     <file src="PlatformServices.Universal\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll" target="build\uap10.0\" />
+    <file src="Microsoft.TestPlatform.AdapterUtilities\uap10.0\" target="build\uap10.0\" />
 
     <!-- Desktop -->
     <file src="Build\Desktop\MSTest.TestAdapter.props" target="build\net45\MSTest.TestAdapter.props" />
     <file src="Build\Desktop\MSTest.TestAdapter.targets" target="build\net45\MSTest.TestAdapter.targets" />
+    <file src="Microsoft.TestPlatform.AdapterUtilities\netstandard2.0\" target="build\net45\" />
 
     <!-- LICENSE -->
     <!-- Workaround for https://github.com/NuGet/Home/issues/7601 -->
diff --git a/src/Package/MSTest.TestAdapter.nuspec b/src/Package/MSTest.TestAdapter.nuspec
index f639e0599b..a89adf275c 100644
--- a/src/Package/MSTest.TestAdapter.nuspec
+++ b/src/Package/MSTest.TestAdapter.nuspec
@@ -21,7 +21,7 @@
     <copyright>© Microsoft Corporation. All rights reserved.</copyright>
     <tags>MSTest TestFramework TestAdapter VisualStudio Unittest MSTestV2 Microsoft</tags>
     <dependencies>
-        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="[16.9.1, )" />
+        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="$TestPlatformVersion$" />
     </dependencies>
   </metadata>
   <files>
@@ -75,6 +75,7 @@
     <!-- NetCore -->
     <file src="Build\NetCore\MSTest.TestAdapter.props" target="build\netcoreapp1.0\" />
     <file src="PlatformServices.NetCore\netstandard1.5\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll" target="build\netcoreapp1.0\" />
+    <file src="Microsoft.TestPlatform.AdapterUtilities\netstandard1.0\" target="build\netcoreapp1.0\" />
 
     <!-- <file src="PlatformServices.NetCore\netstandard1.5\zh-Hans\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources.dll" target="\build\netcoreapp1.0\zh-Hans" />
     <file src="PlatformServices.NetCore\netstandard1.5\zh-Hant\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources.dll" target="\build\netcoreapp1.0\zh-Hant" />
@@ -94,10 +95,12 @@
     <file src="Build\Universal\MSTest.TestAdapter.props" target="build\uap10.0\MSTest.TestAdapter.props" />
     <file src="Build\Universal\MSTest.TestAdapter.targets" target="build\uap10.0\MSTest.TestAdapter.targets" />
     <file src="PlatformServices.Universal\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll" target="build\uap10.0\" />
+    <file src="Microsoft.TestPlatform.AdapterUtilities\uap10.0\" target="build\uap10.0\" />
 
     <!-- Desktop -->
     <file src="Build\Desktop\MSTest.TestAdapter.props" target="build\net45\MSTest.TestAdapter.props" />
     <file src="Build\Desktop\MSTest.TestAdapter.targets" target="build\net45\MSTest.TestAdapter.targets" />
+    <file src="Microsoft.TestPlatform.AdapterUtilities\netstandard2.0\" target="build\net45\" />
 
     <!-- LICENSE -->
     <!-- Workaround for https://github.com/NuGet/Home/issues/7601 -->
diff --git a/src/Package/MSTest.TestAdapter.symbols.nuspec b/src/Package/MSTest.TestAdapter.symbols.nuspec
index df91647c7f..84d1743c8b 100644
--- a/src/Package/MSTest.TestAdapter.symbols.nuspec
+++ b/src/Package/MSTest.TestAdapter.symbols.nuspec
@@ -20,11 +20,11 @@
     <iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>
     <copyright>© Microsoft Corporation. All rights reserved.</copyright>
     <tags>MSTest TestFramework TestAdapter VisualStudio Unittest MSTestV2 Microsoft</tags>
-	<dependencies>
-	    <group targetFramework="netcoreapp1.0">
-			<dependency id="NETStandard.Library" version="1.6.1" />
-			<dependency id="System.Diagnostics.TextWriterTraceListener" version="4.3.0" />
-	    </group>      
+  <dependencies>
+      <group targetFramework="netcoreapp1.0">
+      <dependency id="NETStandard.Library" version="1.6.1" />
+      <dependency id="System.Diagnostics.TextWriterTraceListener" version="4.3.0" />
+      </group>      
     </dependencies>
   </metadata>
   <files>
@@ -33,7 +33,7 @@
     <file src="PlatformServices.Desktop\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll" target="build\_common\" />
     <file src="MSTest.Core\Microsoft.VisualStudio.TestPlatform.TestFramework.dll" target="build\_common\" />
 
-	<!-- NetCore -->
+  <!-- NetCore -->
     <file src="Build\NetCore\MSTest.TestAdapter.props" target="build\netcoreapp1.0\" />
     <file src="PlatformServices.NetCore\netstandard1.5\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll" target="build\netcoreapp1.0\" />
 
diff --git a/src/Package/MSTest.TestFramework.enu.nuspec b/src/Package/MSTest.TestFramework.enu.nuspec
index 8b0aa95e2c..9ed64007c4 100644
--- a/src/Package/MSTest.TestFramework.enu.nuspec
+++ b/src/Package/MSTest.TestFramework.enu.nuspec
@@ -9,14 +9,14 @@
     <owners>Microsoft</owners>
     <summary>This is MSTest V2, the evolution of Microsoft's Test Framework.</summary>
     <description>
-	This is MSTest V2, the evolution of Microsoft's Test Framework.
+  This is MSTest V2, the evolution of Microsoft's Test Framework.
 
-	Supported platforms:
-	- .NET 4.5.0+
-	- .NET Core 1.0+ (Universal Windows Apps 10+, DNX Core 5+)
-	- ASP.NET Core 1.0+
+  Supported platforms:
+  - .NET 4.5.0+
+  - .NET Core 1.0+ (Universal Windows Apps 10+, DNX Core 5+)
+  - ASP.NET Core 1.0+
 
-	To discover and execute tests install MSTest.TestAdapter. 
+  To discover and execute tests install MSTest.TestAdapter. 
 
   To discover and execute tests for project.json based projects install dotnet-test-mstest.
     </description>
@@ -29,16 +29,16 @@
     <dependencies>
       <group targetFramework="netstandard1.0">
         <dependency id="NETStandard.Library" version="1.6.1" />
-        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="[16.9.1, )" />
+        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="$TestPlatformVersion$" />
         <dependency id="System.Diagnostics.TextWriterTraceListener" version="4.3.0" />
       </group>
 
       <group targetFramework="net45">
-        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="[16.9.1, )" />
+        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="$TestPlatformVersion$" />
       </group>
 
       <group targetFramework="uap10.0">
-        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="[16.9.1, )" />
+        <dependency id="Microsoft.TestPlatform.AdapterUtilities" version="$TestPlatformVersion$" />
       </group>
     </dependencies>
   </metadata>
diff --git a/src/Package/MSTest.TestFramework.symbols.nuspec b/src/Package/MSTest.TestFramework.symbols.nuspec
index 11166e7c73..f394319e7c 100644
--- a/src/Package/MSTest.TestFramework.symbols.nuspec
+++ b/src/Package/MSTest.TestFramework.symbols.nuspec
@@ -8,14 +8,14 @@
     <authors>Microsoft</authors>
     <owners>Microsoft</owners>
     <description>
-	This is MSTest V2, the evolution of Microsoft's Test Framework.
+  This is MSTest V2, the evolution of Microsoft's Test Framework.
 
-	Supported platforms:
-	- .NET 4.5.0+
-	- .NET Core 1.0+ (Universal Windows Apps 10+, DNX Core 5+)
-	- ASP.NET Core 1.0+
+  Supported platforms:
+  - .NET 4.5.0+
+  - .NET Core 1.0+ (Universal Windows Apps 10+, DNX Core 5+)
+  - ASP.NET Core 1.0+
 
-	To discover and execute tests install MSTest.TestAdapter. 
+  To discover and execute tests install MSTest.TestAdapter. 
 
   To discover and execute tests for project.json based projects install dotnet-test-mstest.
     </description>
@@ -35,7 +35,7 @@
     <!-- Symbols -->
     <file src="MSTest.Core\Microsoft.VisualStudio.TestPlatform.TestFramework.pdb" target="lib\netstandard1.0\" />
     <file src="Extension.Core\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.pdb" target="lib\netstandard1.0" />
-	
+  
     <!-- net45 -->
     <file src="MSTest.Core\Microsoft.VisualStudio.TestPlatform.TestFramework.dll" target="lib\net45\" />
     <file src="MSTest.Core\Microsoft.VisualStudio.TestPlatform.TestFramework.xml" target="lib\net45\" />
