Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netstandard1.0 and uap10.0 support #2596

Merged
merged 13 commits into from
Oct 21, 2020
159 changes: 86 additions & 73 deletions scripts/build.ps1

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Verify-Nuget-Packages($packageDirectory)
"Microsoft.TestPlatform.Build" = 19;
"Microsoft.TestPlatform.CLI" = 350;
"Microsoft.TestPlatform.Extensions.TrxLogger" = 33;
"Microsoft.TestPlatform.ObjectModel" = 91;
"Microsoft.TestPlatform.ObjectModel" = 178;
Haplois marked this conversation as resolved.
Show resolved Hide resolved
"Microsoft.TestPlatform.Portable" = 566;
"Microsoft.TestPlatform.TestHost" = 197;
"Microsoft.TestPlatform.TranslationLayer" = 121}
Expand Down
10 changes: 5 additions & 5 deletions scripts/verify-sign.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ function Verify-Assemblies
elseif ($signature.SignerCertificate.Thumbprint -eq "5EAD300DC7E4D637948ECB0ED829A072BD152E17") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
# For some dlls e.g. "Interop.UIAutomationClient.dll", sign certificate is different signature. Skip such binaries.
# For some dlls e.g. "Interop.UIAutomationClient.dll", sign certificate is different signature. Skip such binaries.
elseif ($signature.SignerCertificate.Thumbprint -eq "67B1757863E3EFF760EA9EBB02849AF07D3A8080") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
# For some dlls e.g. "Microsoft.VisualStudio.ArchitectureTools.PEReader.dll", sign certificate is different signature. Skip such binaries.
# For some dlls e.g. "Microsoft.VisualStudio.ArchitectureTools.PEReader.dll", sign certificate is different signature. Skip such binaries.
elseif ($signature.SignerCertificate.Thumbprint -eq "9DC17888B5CFAD98B3CB35C1994E96227F061675") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
# For some dlls sign certificate is different signature. Skip such binaries.
# For some dlls sign certificate is different signature. Skip such binaries.
elseif ($signature.SignerCertificate.Thumbprint -eq "62009AAABDAE749FD47D19150958329BF6FF4B34") {
Write-Log "Valid (Prod Signed): $($_.FullName)."
}
Expand Down Expand Up @@ -99,9 +99,9 @@ function Verify-NugetPackages
Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v4.6.1/nuget.exe -OutFile $nugetInstallPath
}

Write-Log "Using nuget.exe installed at $nugetInstallPath"
Write-Log "Using nuget.exe installed at $nugetInstallPath"

$artifactsDirectory = Join-Path $env:TP_OUT_DIR $TPB_Configuration
$artifactsDirectory = Join-Path $env:TP_OUT_DIR $TPB_Configuration
$packagesDirectory = Join-Path $artifactsDirectory "packages"
Get-ChildItem -Filter *.nupkg $packagesDirectory | % {
& $nugetInstallPath verify -signature -CertificateFingerprint 3F9001EA83C560D712C24CF213C3D312CB3BFF51EE89435D3430BD06B5D0EECE $_.FullName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !NETSTANDARD1_0

namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers
{
using System;
using System.IO;

using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
Expand All @@ -14,6 +13,9 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;

using System;
using System.IO;

public class DotnetHostHelper : IDotnetHostHelper
{
public const string MONOEXENAME = "mono";
Expand Down Expand Up @@ -88,3 +90,5 @@ private bool TryGetExecutablePath(string executableBaseName, out string executab
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers
{
using System;
using ObjectModel;

using System;

public class EnvironmentHelper
{
public const string VstestConnectionTimeout = "VSTEST_CONNECTION_TIMEOUT";
Expand All @@ -16,7 +17,13 @@ public class EnvironmentHelper
/// </summary>
public static int GetConnectionTimeout()
{

#if NETSTANDARD1_0
var envVarValue = string.Empty;
#else
var envVarValue = Environment.GetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout);
#endif

if (!string.IsNullOrEmpty(envVarValue) && int.TryParse(envVarValue, out int value) && value >= 0)
{
EqtTrace.Info("EnvironmentHelper.GetConnectionTimeout: {0} value set to {1}.", EnvironmentHelper.VstestConnectionTimeout, value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !NETSTANDARD1_0

namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers
{
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;

/// <summary>
/// The file helper.
/// </summary>
Expand Down Expand Up @@ -140,3 +142,5 @@ public void Delete(string path)
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ namespace Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces
/// </summary>
public interface IFileHelper
{
#if !NETSTANDARD1_0
/// <summary>
/// Creates a directory.
/// </summary>
/// <param name="path">Path of the directory.</param>
/// <returns><see cref="DirectoryInfo"/> for the created directory.</returns>
DirectoryInfo CreateDirectory(string path);

#endif
/// <summary>
/// Gets the current directory
/// </summary>
Expand All @@ -39,6 +41,7 @@ public interface IFileHelper
/// <returns>True if directory exists <see cref="bool"/>.</returns>
bool DirectoryExists(string path);

#if !NETSTANDARD1_0
/// <summary>
/// Gets a stream for the file.
/// </summary>
Expand Down Expand Up @@ -73,6 +76,7 @@ public interface IFileHelper
/// <param name="path">Full path of the file.</param>
/// <returns>Attributes of the file.</returns>
FileAttributes GetFileAttributes(string path);
#endif

/// <summary>
/// Gets the version information of the file.
Expand Down Expand Up @@ -125,6 +129,7 @@ public interface IFileHelper
/// </param>
void DeleteEmptyDirectroy(string directoryPath);

#if !NETSTANDARD1_0
/// <summary>
/// Gets all files in directory based on search pattern
/// </summary>
Expand All @@ -133,6 +138,7 @@ public interface IFileHelper
/// <param name="searchOption">Search option</param>
/// <returns>string[]</returns>
string[] GetFiles(string path, string searchPattern, SearchOption searchOption);
#endif

/// <summary>
/// Deletes the specified file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,40 @@
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.TestPlatform.CoreUtilities</AssemblyName>
<TargetFrameworks>netstandard2.0;netstandard1.3;net451</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.3</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard1.3;netstandard1.0;net451;net45;uap10.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard2.0;netstandard1.3;netstandard1.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0'">
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<NugetTargetMoniker>UAP,Version=v10.0</NugetTargetMoniker>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<TargetFrameworkIdentifier>.NETPortable</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants>

<!-- On non windows environment, make UAP behave like desktop .NET framework -->
<TargetFrameworkIdentifier Condition="'$(OS)' != 'Windows_NT'">.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion Condition="'$(OS)' != 'Windows_NT'">v4.5.1</TargetFrameworkVersion>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\Resources.resx" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<PackageReference Include="Microsoft.Internal.Dia.Interop">
<Version>14.0.0</Version>
</PackageReference>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' OR '$(TargetFramework)' == 'net45' ">
<PackageReference Include="Microsoft.Internal.Dia.Interop" Version="14.0.0" />

<Reference Include="System.Configuration" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net451' ">
<PackageReference Include="System.Diagnostics.FileVersionInfo">
<Version>4.0.0</Version>
</PackageReference>

<ItemGroup Condition=" '$(TargetFramework)' != 'net451' AND '$(TargetFramework)' != 'net45' AND '$(TargetFramework)' != 'netstandard1.0' ">
<PackageReference Include="System.Diagnostics.FileVersionInfo" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<Compile Update="Resources\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand All @@ -39,8 +54,9 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.TestPlatform.PlatformAbstractions\Microsoft.TestPlatform.PlatformAbstractions.csproj" />
<ProjectReference Include="..\Microsoft.TestPlatform.PlatformAbstractions\Microsoft.TestPlatform.PlatformAbstractions.csproj" />
</ItemGroup>

<PropertyGroup Label="Configuration">
<RootNamespace>Microsoft.VisualStudio.TestPlatform.CoreUtilities</RootNamespace>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !NETSTANDARD1_0 && !WINDOWS_UWP

namespace Microsoft.VisualStudio.TestPlatform.Utilities
{
using System;
Expand Down Expand Up @@ -86,3 +88,5 @@ public void Write(string message, OutputLevel level)
}
}
}

#endif
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !NETSTANDARD1_0 && !WINDOWS_UWP

namespace Microsoft.VisualStudio.TestPlatform.Utilities
{
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources;

using System;
using System.Globalization;

using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Resources;

/// <summary>
/// Utility Methods for sending output to IOutput.
/// </summary>
Expand Down Expand Up @@ -153,3 +155,5 @@ private static void SetColorForAction(ConsoleColor foregroundColor, Action actio
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]


# if !NETSTANDARD1_0
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d472046e-ed17-4750-a2a3-29935b5215f6")]
#endif
23 changes: 16 additions & 7 deletions src/Microsoft.TestPlatform.CoreUtilities/Tracing/EqtTrace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ public static bool InitializeTrace(string customLogFile, PlatformTraceLevel trac
[Conditional("TRACE")]
public static void Fail(string message)
{
Error(message);
Debug.Fail(message);
Fail(message, null);
}

/// <summary>
Expand All @@ -188,10 +187,9 @@ public static void Fail(string message)
public static void Fail(string format, params object[] args)
{
string message = string.Format(CultureInfo.InvariantCulture, format, args);

Error(message);
#if DEBUG
Debug.Fail(message);
#endif
FailDebugger(message);
}

/// <summary>
Expand Down Expand Up @@ -328,7 +326,7 @@ public static void ErrorAssert(string format, params object[] args)
Debug.Assert(format != null, "format != null");
var message = string.Format(CultureInfo.InvariantCulture, format, args);
Error(message);
Debug.Fail(message);
FailDebugger(message);
}

/// <summary>
Expand Down Expand Up @@ -806,7 +804,7 @@ private static void WriteAtLevel(PlatformTraceLevel level, string message)
Verbose(message);
break;
default:
Debug.Fail("We should never get here!");
FailDebugger("We should never get here!");
break;
}
}
Expand All @@ -816,5 +814,16 @@ private static void WriteAtLevel(PlatformTraceLevel level, string format, params
Debug.Assert(format != null, "format != null");
WriteAtLevel(level, string.Format(CultureInfo.InvariantCulture, format, args));
}

private static void FailDebugger(string message)
{
#if DEBUG
#if NETSTANDARD1_0
Debug.Assert(false, message);
#else
Debug.Fail(message);
#endif
#endif
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !NETSTANDARD1_0

namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing
{
using System.Diagnostics.Tracing;
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Tracing.Interfaces;

using System.Diagnostics.Tracing;

/// <inheritdoc/>
[EventSource(Name = "TestPlatform")]
public class TestPlatformEventSource : EventSource, ITestPlatformEventSource
Expand Down Expand Up @@ -281,3 +284,5 @@ public void TranslationLayerTestRunAttachmentsProcessingStop()
}
}
}

#endif
7 changes: 6 additions & 1 deletion src/Microsoft.TestPlatform.ObjectModel/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ public static class Constants
/// <summary>
/// Default results directory.
/// </summary>
public static readonly string DefaultResultsDirectory = Path.Combine(Directory.GetCurrentDirectory(), ResultsDirectoryName);
public static readonly string DefaultResultsDirectory =
#if NETSTANDARD1_0
Sanan07 marked this conversation as resolved.
Show resolved Hide resolved
Path.Combine(".", ResultsDirectoryName);
#else
Path.Combine(Directory.GetCurrentDirectory(), ResultsDirectoryName);
#endif

/// <summary>
/// Default treatment of error from test adapters.
Expand Down
Loading