diff --git a/scripts/build.sh b/scripts/build.sh
index b2534008c9..4c22bfa5a6 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -87,6 +87,7 @@ DOTNET_RUNTIME_VERSION="2.0.0-preview2-25331-01"
# Build configuration
#
TPB_Solution="TestPlatform.sln"
+TPB_TargetFramework="net46"
TPB_TargetFrameworkCore="netcoreapp2.0"
TPB_TargetFrameworkCore10="netcoreapp1.0"
TPB_Configuration=$CONFIGURATION
@@ -203,8 +204,6 @@ function invoke_build()
log ".. .. Build: Source: $TPB_Solution"
if $TPB_HasMono; then
- # Workaround for https://github.com/dotnet/sdk/issues/335
- export FrameworkPathOverride=/usr/lib/mono/4.5/
if [ -z "$PROJECT_NAME_PATTERNS" ]
then
$dotnet build $TPB_Solution --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild -p:LocalizedBuild=$TPB_LocalizedBuild || failed=true
@@ -259,57 +258,71 @@ function publish_package()
log "publish_package: Started."
local start=$SECONDS
- coreCLRPackageDir=$TP_OUT_DIR/$TPB_Configuration/$TPB_TargetFrameworkCore
-
- PROJECTPACKAGEOUTPUTMAP=( \
- $TP_PACKAGE_PROJ_DIR/package.csproj:$coreCLRPackageDir \
- $TP_ROOT_DIR/src/vstest.console/vstest.console.csproj:$coreCLRPackageDir \
- $TP_ROOT_DIR/src/datacollector/datacollector.csproj:$coreCLRPackageDir
+ local packageDir=$TP_OUT_DIR/$TPB_Configuration/$TPB_TargetFramework/$TPB_TargetRuntime
+ local coreCLRPackageDir=$TP_OUT_DIR/$TPB_Configuration/$TPB_TargetFrameworkCore
+ local frameworkPackageDirMap=( \
+ $TPB_TargetFrameworkCore:$coreCLRPackageDir \
+ $TPB_TargetFramework:$packageDir
)
-
- for item in "${PROJECTPACKAGEOUTPUTMAP[@]}" ;
+
+ for fxpkg in "${frameworkPackageDirMap[@]}" ;
do
- projectToPackage="${item%%:*}"
- packageOutputPath="${item##*:}"
- log "Package: Publish $projectToPackage"
- $dotnet publish $projectToPackage --configuration $TPB_Configuration --framework $TPB_TargetFrameworkCore --output $packageOutputPath -v:minimal -p:LocalizedBuild=$TPB_LocalizedBuild
+ local framework="${fxpkg%%:*}"
+ local packageDir="${fxpkg##*:}"
+ local projects=( \
+ $TP_PACKAGE_PROJ_DIR/package.csproj \
+ $TP_ROOT_DIR/src/vstest.console/vstest.console.csproj \
+ $TP_ROOT_DIR/src/datacollector/datacollector.csproj
+ )
+
+ if [ "$framework" == "net46" ] && ! $TPB_HasMono; then
+ # Skip publish if mono is not available
+ continue
+ fi
+
+ log "Package: Publish projects for $framework"
+ for project in "${projects[@]}" ;
+ do
+ log ".. Package: Publish $project"
+ $dotnet publish $project --configuration $TPB_Configuration --framework $framework --output $packageDir -v:minimal -p:LocalizedBuild=$TPB_LocalizedBuild
+ done
+
+ # Copy TestHost for desktop targets if we've built net46
+ # packages with mono
+ if $TPB_HasMono; then
+ local testhost=$packageDir/TestHost
+ mkdir -p $testhost
+ cp -r src/testhost/bin/$TPB_Configuration/net46/win7-x64/* $testhost
+ cp -r src/testhost.x86/bin/$TPB_Configuration/net46/win7-x64/* $testhost
+ fi
+
+ # Copy over the logger assemblies to the Extensions folder.
+ local extensionsDir="$packageDir/Extensions"
+ # Create an extensions directory.
+ mkdir -p $extensionsDir
+
+ # Note Note: If there are some dependencies for the logger assemblies, those need to be moved too.
+ # Ideally we should just be publishing the loggers to the Extensions folder.
+ loggers=("Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll" "Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.pdb")
+ for i in ${loggers[@]}; do
+ mv $packageDir/${i} $extensionsDir
+ done
+
+ # Note Note: If there are some dependencies for the TestHostRuntimeProvider assemblies, those need to be moved too.
+ runtimeproviders=("Microsoft.TestPlatform.TestHostRuntimeProvider.dll" "Microsoft.TestPlatform.TestHostRuntimeProvider.pdb")
+ for i in ${runtimeproviders[@]}; do
+ mv $packageDir/${i} $extensionsDir
+ done
+ newtonsoft=$TP_PACKAGES_DIR/newtonsoft.json/9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
+ cp $newtonsoft $packageDir
done
# Publish TestHost for netcoreapp1.0 target
- log "Package: Publish testhost.csproj"
+ log ".. Package: Publish testhost.csproj"
local projectToPackage=$TP_ROOT_DIR/src/testhost/testhost.csproj
local packageOutputPath=$TP_OUT_DIR/$TPB_Configuration/Microsoft.TestPlatform.TestHost/$TPB_TargetFrameworkCore10
$dotnet publish $projectToPackage --configuration $TPB_Configuration --framework $TPB_TargetFrameworkCore10 --output $packageOutputPath -v:minimal -p:LocalizedBuild=$TPB_LocalizedBuild
- # Copy TestHost for desktop targets if we've built net46
- # packages with mono
- if $TPB_HasMono; then
- local testhost=$coreCLRPackageDir/TestHost
- mkdir -p $testhost
- cp -r src/testhost/bin/$TPB_Configuration/net46/win7-x64/* $testhost
- cp -r src/testhost.x86/bin/$TPB_Configuration/net46/win7-x64/* $testhost
- fi
-
- # Copy over the logger assemblies to the Extensions folder.
- coreCLRExtensionsDir="$coreCLRPackageDir/Extensions"
- # Create an extensions directory.
- mkdir -p $coreCLRExtensionsDir
-
- # Note Note: If there are some dependencies for the logger assemblies, those need to be moved too.
- # Ideally we should just be publishing the loggers to the Extensions folder.
- loggers=("Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.dll" "Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger.pdb")
- for i in ${loggers[@]}; do
- mv $coreCLRPackageDir/${i} $coreCLRExtensionsDir
- done
-
- # Note Note: If there are some dependencies for the TestHostRuntimeProvider assemblies, those need to be moved too.
- runtimeproviders=("Microsoft.TestPlatform.TestHostRuntimeProvider.dll" "Microsoft.TestPlatform.TestHostRuntimeProvider.pdb")
- for i in ${runtimeproviders[@]}; do
- mv $coreCLRPackageDir/${i} $coreCLRExtensionsDir
- done
- newtonsoft=$TP_PACKAGES_DIR/newtonsoft.json/9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
- cp $newtonsoft $coreCLRPackageDir
-
# For libraries that are externally published, copy the output into artifacts. These will be signed and packaged independently.
packageName="Microsoft.TestPlatform.Build"
binariesDirectory="src/$packageName/bin/$TPB_Configuration/**"
@@ -397,6 +410,11 @@ log "Test platform environment variables: "
log "Test platform build variables: "
(set | grep ^TPB_)
+if $TPB_HasMono; then
+ # Workaround for https://github.com/dotnet/sdk/issues/335
+ export FrameworkPathOverride=/usr/lib/mono/4.5/
+fi
+
if [ -z "$PROJECT_NAME_PATTERNS" ]
then
install_cli && restore_package && invoke_build && publish_package && create_package
diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/DotnetHostHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/DotnetHostHelper.cs
index 4bf0dfdd16..3d82aff821 100644
--- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/DotnetHostHelper.cs
+++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/DotnetHostHelper.cs
@@ -10,17 +10,22 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+ using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions;
+ using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
public class DotnetHostHelper : IDotnetHostHelper
{
+ public const string MONOEXENAME = "mono";
+
private readonly IFileHelper fileHelper;
+ private readonly IEnvironment environment;
///
/// Initializes a new instance of the class.
///
- public DotnetHostHelper() : this(new FileHelper())
+ public DotnetHostHelper() : this(new FileHelper(), new PlatformEnvironment())
{
}
@@ -28,41 +33,59 @@ public DotnetHostHelper() : this(new FileHelper())
/// Initializes a new instance of the class.
///
/// File Helper
- public DotnetHostHelper(IFileHelper fileHelper)
+ public DotnetHostHelper(IFileHelper fileHelper, IEnvironment environment)
{
this.fileHelper = fileHelper;
+ this.environment = environment;
}
///
- public string GetDotnetHostFullPath()
+ public string GetDotnetPath()
{
- char separator = ';';
- var dotnetExeName = "dotnet.exe";
+ if (!TryGetExecutablePath("dotnet", out string dotnetPath))
+ {
+ string errorMessage = string.Format(Resources.NoDotnetExeFound, "dotnet");
+
+ EqtTrace.Error(errorMessage);
+ throw new FileNotFoundException(errorMessage);
+ }
-#if !NET46
- // Use semicolon(;) as path separator for windows
- // colon(:) for Linux and OSX
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ return dotnetPath;
+ }
+
+ public string GetMonoPath()
+ {
+ if (!TryGetExecutablePath(MONOEXENAME, out string monoPath))
{
- separator = ':';
- dotnetExeName = "dotnet";
+ string errorMessage = string.Format(Resources.NoDotnetExeFound, MONOEXENAME);
+
+ EqtTrace.Error(errorMessage);
+ throw new FileNotFoundException(errorMessage);
}
-#endif
+ return monoPath;
+ }
+
+ private bool TryGetExecutablePath(string executableBaseName, out string executablePath)
+ {
+ if (this.environment.OperatingSystem.Equals(PlatformOperatingSystem.Windows))
+ {
+ executableBaseName = executableBaseName + ".exe";
+ }
+
+ executablePath = string.Empty;
var pathString = Environment.GetEnvironmentVariable("PATH");
- foreach (string path in pathString.Split(separator))
+ foreach (string path in pathString.Split(Path.PathSeparator))
{
- string exeFullPath = Path.Combine(path.Trim(), dotnetExeName);
+ string exeFullPath = Path.Combine(path.Trim(), executableBaseName);
if (this.fileHelper.Exists(exeFullPath))
{
- return exeFullPath;
+ executablePath = exeFullPath;
+ return true;
}
}
- string errorMessage = string.Format(Resources.NoDotnetExeFound, dotnetExeName);
-
- EqtTrace.Error(errorMessage);
- throw new FileNotFoundException(errorMessage);
+ return false;
}
}
}
diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IDotnetHostHelper.cs b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IDotnetHostHelper.cs
index 05cb904c39..6793748a4b 100644
--- a/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IDotnetHostHelper.cs
+++ b/src/Microsoft.TestPlatform.CoreUtilities/Helpers/Interfaces/IDotnetHostHelper.cs
@@ -9,10 +9,16 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces
public interface IDotnetHostHelper
{
///
- /// Get full path for the .net host
+ /// Gets the full path for of .net core host.
///
/// Full path to dotnet executable
/// Debuggers require the full path of executable to launch it.
- string GetDotnetHostFullPath();
+ string GetDotnetPath();
+
+ ///
+ /// Gets the full path of mono host.
+ ///
+ /// Full path to mono executable
+ string GetMonoPath();
}
}
diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Resources/Resources.resx b/src/Microsoft.TestPlatform.CoreUtilities/Resources/Resources.resx
index a57060159f..ba520ac0b1 100644
--- a/src/Microsoft.TestPlatform.CoreUtilities/Resources/Resources.resx
+++ b/src/Microsoft.TestPlatform.CoreUtilities/Resources/Resources.resx
@@ -154,7 +154,7 @@
Unhandled exception occurred while processing a job from the '{0}' queue: {1}
- Could not find {0}. Make sure that the dotnet is installed on the machine.
+ Could not find '{0}' host. Make sure that '{0}' is installed on the machine and is available in PATH environment variable.The {0} queue has already been disposed.
diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.CoreUtilities/Resources/xlf/Resources.cs.xlf
index 7418168e24..aaaff15cd5 100644
--- a/src/Microsoft.TestPlatform.CoreUtilities/Resources/xlf/Resources.cs.xlf
+++ b/src/Microsoft.TestPlatform.CoreUtilities/Resources/xlf/Resources.cs.xlf
@@ -156,9 +156,9 @@
fuzzyMatch="15" wordcount="4" adjWordcount="3.4" curWordcount="3.4"
-
- Nejde najít {0}. Ujistěte se, že na počítači je nainstalovaný dotnet.
-
+
+ Nejde najít {0}. Ujistěte se, že na počítači je nainstalovaný dotnet.
+