--- /dev/null
+<Project>
+ <!--
+ This file is imported by the test projects from the artifacts dir or the src/tests dir. It
+ provides basic info needed for restore and build with the vanilla SDK.
+ -->
+</Project>
<Project>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />
- <Import Project="$(MSBuildThisFileDirectory)MNADeprecationWorkaround.props" />
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), TestProjects.props))\TestProjects.props" />
+
+ <ItemGroup>
+ <RestoreTestFallbackSource Include="$(ArtifactsShippingPackagesDir)" />
+ <RestoreTestSource Include="$(RestoreSources)" />
+ <RestoreTestSource Include="https://api.nuget.org/v3/index.json" />
+ </ItemGroup>
+
+ <PropertyGroup>
+ <RestoreSources>@(RestoreTestSource);@(RestoreTestFallbackSource)</RestoreSources>
+ <RestorePackagesPath>$(TestRestorePackagesPath)</RestorePackagesPath>
+ <RestoreNoCache>true</RestoreNoCache>
+ </PropertyGroup>
+
</Project>
--- /dev/null
+<Project>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), TestProjects.targets))\TestProjects.targets" />
+
+ <!--
+ Some known framework references are downstream of Core-Setup and don't exist with the build's
+ versions. Remove them before the SDK tries to download them.
+ -->
+ <Target Name="RemoveUpstackKnownFrameworkReferences"
+ BeforeTargets="ResolveFrameworkReferences">
+ <ItemGroup>
+ <KnownFrameworkReference Remove="Microsoft.AspNetCore.App" />
+ </ItemGroup>
+ </Target>
+
+</Project>
<PackageReference Include="Microsoft.NETCore.App.Internal" Version="$(MNAVersion)" />
</ItemGroup>
+ <PropertyGroup>
+ <DisableImplicitNETCorePlatformsReference>true</DisableImplicitNETCorePlatformsReference>
+ </PropertyGroup>
+
</Project>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
- <!--
- Work around "dotnet store" relying on Microsoft.NETCore.App. See MNADeprecationWorkaround.props.
-
- Explicit Sdk.targets import is required to override this.
- -->
-
- <!-- BEGIN copy: Taken and modified from 'Tools\dotnetcli\sdk\2.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets' -->
-
- <Target Name="_RestoreCrossgen"
- DependsOnTargets="PrepforRestoreForComposeStore;
- _SetupStageForCrossgen;"
- Condition="$(SkipOptimization) != 'true' ">
- <!-- Was:
- <MSBuild Projects="$(MSBuildProjectFullPath)"
- Targets="Restore"
- Properties="RestoreGraphProjectInput=$(MSBuildProjectFullPath);
- DisableImplicitFrameworkReferences=true;
- RestoreOutputPath=$(_CrossProjFileDir);
- StorePackageName=$(MicrosoftNETPlatformLibrary);
- StorePackageVersion=$(RuntimeFrameworkVersion);"/>
- -->
- <MSBuild Projects="$(MSBuildProjectFullPath)"
- Targets="Restore"
- Properties="RestoreGraphProjectInput=$(MSBuildProjectFullPath);
- DisableImplicitFrameworkReferences=true;
- RestoreOutputPath=$(_CrossProjFileDir);
- StorePackageName=Microsoft.NETCore.App.Internal;
- StorePackageVersion=$(RuntimeFrameworkVersion);"/>
-
- <ResolvePublishAssemblies ProjectPath="$(MSBuildProjectFullPath)"
- AssetsFilePath="$(_CrossProjAssetsFile)"
- TargetFramework="$(_TFM)"
- RuntimeIdentifier="$(RuntimeIdentifier)"
- PlatformLibraryName="$(MicrosoftNETPlatformLibrary)"
- ExcludeFromPublishPackageReferences="@(_ExcludeFromPublishPackageReference)"
- IsSelfContained="$(SelfContained)"
- PreserveStoreLayout="false">
-
- <Output TaskParameter="AssembliesToPublish" ItemName="CrossgenResolvedAssembliesToPublish" />
- </ResolvePublishAssemblies>
-
- <!-- Copy managed files to a flat temp directory for passing it as ref for crossgen -->
- <Copy SourceFiles = "@(CrossgenResolvedAssembliesToPublish)"
- DestinationFolder="$(_NetCoreRefDir)"
- OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
- Retries="$(CopyRetryCount)"
- RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
- UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
- UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">
-
- <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
- </Copy>
- </Target>
-
- <!-- END copy -->
-
</Project>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" />
- <PackageReference Include="xunit" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="xunit.netcore.extensions" Version="1.0.0-prerelease-00206" />
<PackageReference Include="dotnet-test-xunit" Version="1.0.0-rc2-192208-24" />
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170106-08" />
- <PackageReference Include="xunit" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="xunit.netcore.extensions" Version="1.0.0-prerelease-00206" />
<PackageReference Include="dotnet-test-xunit" Version="1.0.0-rc2-192208-24" />
<PropertyGroup>
<Description>Apphost Bundle Tests</Description>
- <TargetFramework>netcoreapp2.0</TargetFramework>
+ <TargetFramework>$(NETCoreAppFramework)</TargetFramework>
<AssemblyName>AppHost.Bundle.Tests</AssemblyName>
<PackageId>AppHost.Bundle.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
+ <!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
+ <TestsOutputName>ahb</TestsOutputName>
+ <UsesTestAssets>true</UsesTestAssets>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Helpers\BundleHelper.csproj" />
</ItemGroup>
- <ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
- <PackageReference Include="xunit" Version="2.2.0" />
- <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
- </ItemGroup>
-
</Project>
<ProjectReference Include="..\..\..\managed\Microsoft.NET.HostModel\Microsoft.NET.HostModel.csproj" />
</ItemGroup>
- <ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
- </ItemGroup>
-
</Project>
<PropertyGroup>
<Description>Microsoft.NET.HostModel.Bundle Tests</Description>
- <TargetFramework>netcoreapp2.0</TargetFramework>
+ <TargetFramework>$(NETCoreAppFramework)</TargetFramework>
<AssemblyName>Microsoft.NET.HostModel.Bundle.Tests</AssemblyName>
<PackageId>Microsoft.NET.HostModel.Bundle.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
+ <!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
+ <TestsOutputName>hmb</TestsOutputName>
+ <UsesTestAssets>true</UsesTestAssets>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Helpers\BundleHelper.csproj" />
</ItemGroup>
- <ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
- <PackageReference Include="xunit" Version="2.2.0" />
- <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
- </ItemGroup>
-
</Project>
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\Directory.Build.props" />
+<Project>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.props))\Directory.Build.props" />
<PropertyGroup>
- <TestDir>$(ProjectDir)/src/test</TestDir>
- <TestAssetsDir>$(TestDir)/Assets</TestAssetsDir>
+ <TestDir>$(ProjectDir)src\test\</TestDir>
+ <TestAssetsDir>$(TestDir)Assets\</TestAssetsDir>
+ <TestRestorePackagesPath>$(ObjDir)TestPackageCache\</TestRestorePackagesPath>
</PropertyGroup>
- <ItemGroup>
- <TestProjects Include="$(TestDir)/HostActivation.Tests/HostActivation.Tests.csproj" />
- <TestProjects Include="$(TestDir)/Microsoft.Extensions.DependencyModel.Tests/Microsoft.Extensions.DependencyModel.Tests.csproj" />
- <TestProjects Include="$(TestDir)/BundleTests/Microsoft.NET.HostModel.Bundle.Tests/Microsoft.NET.HostModel.Bundle.Tests.csproj" />
- <TestProjects Include="$(TestDir)/BundleTests/AppHost.Bundle.Tests/AppHost.Bundle.Tests.csproj" />
- </ItemGroup>
- <ItemGroup>
- <RestoreTestFallbackSource Include="$(CoreHostOutputDir.TrimEnd('/').TrimEnd('\'))" />
- <RestoreTestFallbackSource Include="$(PackagesBasePath)packages" />
- <RestoreTestSource Include="@(DotnetSourceList)" />
- </ItemGroup>
</Project>
--- /dev/null
+<Project>
+
+ <Target Name="RefreshProjectTestAssets"
+ Condition="'$(UsesTestAssets)' == 'true'"
+ DependsOnTargets="DetermineTestOutputDirectory"
+ BeforeTargets="RunTests">
+ <!-- Build PrepareTestAssets once for all tests. -->
+ <MSBuild
+ Projects="$(TestDir)PrepareTestAssets\PrepareTestAssets.proj"
+ Targets="PrepareTestAssets" />
+
+ <!--
+ Set up the shared framework copy this set of tests should use. There's no known reason to have
+ one per test project, but RepoDirectoriesProvider may need some tweaking to share.
+ -->
+ <ItemGroup>
+ <SharedFrameworkPublishFiles Include="$(SharedFrameworkPublishDir)**" />
+ </ItemGroup>
+
+ <Copy
+ SourceFiles="@(SharedFrameworkPublishFiles)"
+ DestinationFiles="@(SharedFrameworkPublishFiles->'$(TestsOutputDir)sharedFrameworkPublish/%(RecursiveDir)%(Filename)%(Extension)')" />
+
+ <!-- Create file with a name that describes what a test dir is. Useful if path abbreviated. -->
+ <WriteLinesToFile
+ File="$(TestsOutputRootDir)$(TestsOutputName)-is-$(MSBuildProjectName).txt"
+ Overwrite="true"
+ Lines="$(MSBuildProjectName) intermediates are located in '$(TestsOutputName)'. Abbreviated to work around path limits on Windows."
+ Condition="'$(TestsOutputName)' != '$(MSBuildProjectName)'" />
+ </Target>
+
+ <Target Name="DetermineTestOutputDirectory">
+ <GetTargetMachineInfo>
+ <Output TaskParameter="RuntimeIdentifier" PropertyName="_HostRid" />
+ </GetTargetMachineInfo>
+
+ <PropertyGroup>
+ <TestTargetRid Condition="'$(TestTargetRid)' == ''">$(_HostRid)</TestTargetRid>
+ <TestsOutputName Condition="'$(TestsOutputName)' == ''">$(MSBuildProjectName)</TestsOutputName>
+
+ <TestsOutputRootDir Condition="'$(TestsOutputRootDir)' == ''">$(ArtifactsDir)tests/$(ConfigurationGroup)/</TestsOutputRootDir>
+ <TestsOutputDir Condition="'$(TestsOutputDir)' == ''">$(TestsOutputRootDir)$(TestsOutputName)/</TestsOutputDir>
+ </PropertyGroup>
+ </Target>
+
+ <Target Name="SetupTextFixtureEnvironment"
+ DependsOnTargets="
+ GetProductVersions;
+ DetermineTestOutputDirectory"
+ BeforeTargets="RunTests">
+ <PropertyGroup>
+ <!-- The tests use the TEST_ARTIFACTS env variable to determine the artifacts folder and then later compare that path to its expected path.
+ So, the TEST_ARTIFACTS variable has to have system specific path separators or the string compoarison will fail. -->
+ <DirectorySeparatorChar>$([System.IO.Path]::DirectorySeparatorChar)</DirectorySeparatorChar>
+ <SystemPathTestsOutputDir>$([System.String]::Copy('$(TestsOutputDir)').Replace('/', '$(DirectorySeparatorChar)'))</SystemPathTestsOutputDir>
+ <SystemPathTestsOutputDir>$([System.String]::Copy('$(SystemPathTestsOutputDir)').Replace('\', '$(DirectorySeparatorChar)'))</SystemPathTestsOutputDir>
+ </PropertyGroup>
+
+ <!-- Set properties used inside tests as environment variables. -->
+ <ItemGroup>
+ <TestRunnerEnvironmentVariable Include="NUGET_PACKAGES=$(PackagesDir)" />
+ <TestRunnerEnvironmentVariable Include="TEST_ARTIFACTS=$(SystemPathTestsOutputDir)" />
+ <TestRunnerEnvironmentVariable Include="TEST_TARGETRID=$(TestTargetRid)" />
+ <TestRunnerEnvironmentVariable Include="BUILDRID=$(OutputRid)" />
+ <TestRunnerEnvironmentVariable Include="BUILD_ARCHITECTURE=$(TargetArchitecture)" />
+ <TestRunnerEnvironmentVariable Include="BUILD_CONFIGURATION=$(ConfigurationGroup)" />
+ <TestRunnerEnvironmentVariable Include="MNA_VERSION=$(ProductVersion)" />
+ <TestRunnerEnvironmentVariable Include="MNA_TFM=$(NETCoreAppFramework)" />
+ <TestRunnerEnvironmentVariable Include="DOTNET_SDK_PATH=$(DotNetRoot)" />
+ </ItemGroup>
+ </Target>
+
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory).., Directory.Build.targets))\Directory.Build.targets" />
+
+ <!--
+ Rewrite Arcade RunTests target to add TestRunnerEnvironmentVariable support. In the future we
+ should switch to a file to transfer this information, or derive the info from information on
+ disk. Env vars are not likely to be supported in upstream Arcade.
+
+ See https://github.com/dotnet/arcade/issues/3077.
+ -->
+ <!-- <OVERRIDE> https://github.com/dotnet/arcade/blob/dc538a29793fd56618d0fa3186e2388d47d00c19/src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.targets#L25-L120 -->
+ <!--
+ Include '*' target to force running tests even if the input assemblies haven't changed and the outputs are present.
+ This matches the common expectations that test command always runs all tests in scope.
+ -->
+ <Target Name="RunTests"
+ Inputs="@(TestToRun);*"
+ Outputs="%(TestToRun.ResultsStdOutPath);%(TestToRun.ResultsXmlPath);%(TestToRun.ResultsHtmlPath)">
+
+ <PropertyGroup>
+ <_TestEnvironment>%(TestToRun.EnvironmentDisplay)</_TestEnvironment>
+ <_TestAssembly>%(TestToRun.Identity)</_TestAssembly>
+ <_TestRuntime>%(TestToRun.TestRuntime)</_TestRuntime>
+ <_TestRunnerAdditionalArguments>%(TestToRun.TestRunnerAdditionalArguments)</_TestRunnerAdditionalArguments>
+
+ <!-- Always use net472 for desktop to enable displaying source location from Portable PDBs in stack traces -->
+ <_TestRunnerTargetFramework>net472</_TestRunnerTargetFramework>
+ <_TestRunnerTargetFramework Condition="'$(_TestRuntime)' == 'Core'">netcoreapp2.0</_TestRunnerTargetFramework>
+ <_TestRunnerTargetFramework Condition="%(TestToRun.TargetFramework) == 'netcoreapp1.1' or %(TestToRun.TargetFramework) == 'netcoreapp1.0'">netcoreapp1.0</_TestRunnerTargetFramework>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(_TestRuntime)' == 'Core'">
+ <_TargetFileNameNoExt>$([System.IO.Path]::GetFileNameWithoutExtension('$(_TestAssembly)'))</_TargetFileNameNoExt>
+ <_TargetDir>$([System.IO.Path]::GetDirectoryName('$(_TestAssembly)'))\</_TargetDir>
+ <_CoreRuntimeConfigPath>$(_TargetDir)$(_TargetFileNameNoExt).runtimeconfig.json</_CoreRuntimeConfigPath>
+ <_CoreDepsPath>$(_TargetDir)$(_TargetFileNameNoExt).deps.json</_CoreDepsPath>
+
+ <_TestRunner Condition="'%(TestToRun.Architecture)'=='x86' And Exists('$(DotNetRoot)x86\dotnet.exe')">$(DotNetRoot)x86\dotnet.exe</_TestRunner>
+ <_TestRunner Condition="'$(_TestRunner)'==''">$(DotNetTool)</_TestRunner>
+
+ <_TestRunnerArgs>exec --depsfile "$(_CoreDepsPath)" --runtimeconfig "$(_CoreRuntimeConfigPath)" $(TestRuntimeAdditionalArguments) "$(NuGetPackageRoot)xunit.runner.console/$(XUnitVersion)/tools/$(_TestRunnerTargetFramework)/xunit.console.dll" "$(_TestAssembly)" -noautoreporters -xml "%(TestToRun.ResultsXmlPath)" -html "%(TestToRun.ResultsHtmlPath)" $(_TestRunnerAdditionalArguments)</_TestRunnerArgs>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(_TestRuntime)' != 'Core'">
+ <_XUnitConsoleExe>xunit.console.exe</_XUnitConsoleExe>
+ <_XUnitConsoleExe Condition="'%(TestToRun.Architecture)' == 'x86'">xunit.console.x86.exe</_XUnitConsoleExe>
+ <_XUnitConsoleExePath>$(NuGetPackageRoot)xunit.runner.console\$(XUnitVersion)\tools\$(_TestRunnerTargetFramework)\$(_XUnitConsoleExe)</_XUnitConsoleExePath>
+
+ <_TestRunnerArgs>"$(_TestAssembly)" -noshadow -xml "%(TestToRun.ResultsXmlPath)" -html "%(TestToRun.ResultsHtmlPath)" $(_TestRunnerAdditionalArguments)</_TestRunnerArgs>
+ <_TestRunnerArgs Condition="'$(_TestRuntime)' == 'Mono'">$(TestRuntimeAdditionalArguments) "$(_XUnitConsoleExePath)" $(_TestRunnerArgs)</_TestRunnerArgs>
+
+ <_TestRunner Condition="'$(_TestRuntime)' == 'Mono'">$(MonoTool)</_TestRunner>
+ <_TestRunner Condition="'$(_TestRuntime)' != 'Mono'">$(_XUnitConsoleExePath)</_TestRunner>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <_TestRunnerCommand>"$(_TestRunner)" $(_TestRunnerArgs)</_TestRunnerCommand>
+
+ <!--
+ Redirect std output of the runner.
+ Note that xUnit outputs failure info to both STDOUT (stack trace, message) and STDERR (failed test name)
+ -->
+ <_TestRunnerCommand Condition="'$(TestCaptureOutput)' != 'false'">$(_TestRunnerCommand) > "%(TestToRun.ResultsStdOutPath)" 2>&1</_TestRunnerCommand>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <_OutputFiles Include="%(TestToRun.ResultsXmlPath)" />
+ <_OutputFiles Include="%(TestToRun.ResultsHtmlPath)" />
+ <_OutputFiles Include="%(TestToRun.ResultsStdOutPath)" />
+ </ItemGroup>
+
+ <MakeDir Directories="@(_OutputFiles->'%(RootDir)%(Directory)')"/>
+ <Delete Files="@(_OutputFiles)" />
+
+ <Message Text="Running tests: $(_TestAssembly) [$(_TestEnvironment)]" Importance="high"/>
+ <!-- <CHANGE> Add env var parameter, taking TestRunnerEnvironmentVariable items. -->
+ <Exec
+ Command='$(_TestRunnerCommand)'
+ EnvironmentVariables="@(TestRunnerEnvironmentVariable)"
+ LogStandardErrorAsError="false"
+ WorkingDirectory="$(_TargetDir)"
+ IgnoreExitCode="true">
+ <!-- </CHANGE> -->
+ <Output TaskParameter="ExitCode" PropertyName="_TestErrorCode" />
+ </Exec>
+
+ <!--
+ Add command line to the log.
+ -->
+ <WriteLinesToFile File="%(TestToRun.ResultsStdOutPath)"
+ Overwrite="false"
+ Lines=";=== COMMAND LINE ===;$(_TestRunnerCommand)"
+ Condition="'$(TestCaptureOutput)' != 'false'" />
+
+ <!--
+ Report test status.
+ -->
+ <Message Text="Tests succeeded: $(_TestAssembly) [$(_TestEnvironment)]" Condition="'$(_TestErrorCode)' == '0'" Importance="high" />
+
+ <PropertyGroup>
+ <_ResultsFileToDisplay>%(TestToRun.ResultsHtmlPath)</_ResultsFileToDisplay>
+ <_ResultsFileToDisplay Condition="!Exists('$(_ResultsFileToDisplay)')">%(TestToRun.ResultsStdOutPath)</_ResultsFileToDisplay>
+ </PropertyGroup>
+
+ <!--
+ Ideally we would set ContinueOnError="ErrorAndContinue" so that when a test fails in multi-targeted test project
+ we'll still run tests for all target frameworks. ErrorAndContinue doesn't work well on Linux though: https://github.com/Microsoft/msbuild/issues/3961.
+ -->
+ <Error Text="Tests failed: $(_ResultsFileToDisplay) [$(_TestEnvironment)]" Condition="'$(_TestErrorCode)' != '0'" File="XUnit" />
+
+ <ItemGroup>
+ <FileWrites Include="@(_OutputFiles)"/>
+ </ItemGroup>
+ </Target>
+ <!-- </OVERRIDE> -->
+
+</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>netcoreapp2.0</TargetFramework>
+ <TargetFramework>$(NETCoreAppFramework)</TargetFramework>
<AssemblyName>HostActivation.Tests</AssemblyName>
<PackageId>HostActivation.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<DefineConstants Condition="'$(OSGroup)' == 'Windows_NT'">$(DefineConstants);WINDOWS</DefineConstants>
+ <!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
+ <TestsOutputName>ha</TestsOutputName>
+ <UsesTestAssets>true</UsesTestAssets>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
- <PackageReference Include="xunit" Version="2.2.0" />
- <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
<PropertyGroup>
<Description>Microsoft.DotNet.Tools.Tests.Utilities Class Library</Description>
- <TargetFramework>netcoreapp2.0</TargetFramework>
+ <TargetFramework>$(NETCoreAppFramework)</TargetFramework>
<AssemblyName>Microsoft.Extensions.DependencyModel.Tests</AssemblyName>
- <AssemblyOriginatorKeyFile>../../../tools-local/setuptools/Key.snk</AssemblyOriginatorKeyFile>
+ <StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Microsoft.Extensions.DependencyModel.Tests</PackageId>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
- <PackageReference Include="xunit" Version="2.2.0" />
- <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="FluentAssertions" Version="4.19.4" />
<PackageReference Include="Moq" Version="4.7.142" />
<ProjectReference Include="..\..\managed\Microsoft.Extensions.DependencyModel\Microsoft.Extensions.DependencyModel.csproj" />
</ItemGroup>
+ <!--
+ This test project gets internals from the implementation project, which uses the
+ System.Text.Json source package. This results in duplicate types. Resolve this by removing the
+ reference to System.Text.Json here in the test project.
+ -->
+ <Target Name="RemoveSystemTextJsonRef" AfterTargets="ResolveTargetingPacks">
+ <ItemGroup>
+ <Reference Remove="@(Reference)" Condition="'%(Reference.Filename)' == 'System.Text.Json'" />
+ </ItemGroup>
+ </Target>
+
</Project>
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <Target Name="PrepareTestAssets"
+ DependsOnTargets="
+ GetProductVersions;
+ DetermineTestOutputDirectory">
+ <!-- Ensure installers (and therefore shared framework projects) are built first. -->
+ <MSBuild Projects="$(SourceDir)pkg\packaging\installers.proj" Targets="Build" />
+
+ <PropertyGroup>
+ <TempFolderRoot>$(IntermediateOutputPath)temp\</TempFolderRoot>
+ <TestTargetRid Condition="'$(TestTargetRid)' == ''">$(_HostRid)</TestTargetRid>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <DirsToClean Include="$(TestDir)\**\bin" />
+ <DirsToClean Include="$(TestDir)\**\obj" />
+ <DirsToClean Include="$(TestRestorePackagesPath)" />
+ <DirsToClean Include="$(TempFolderRoot)$(TargetArchitecture)" />
+
+ <TestAssetProjectToRestore Include="$(TestAssetsDir)**\*.csproj" />
+
+ <AllTestRestoreSources Include="@(RestoreTestSource)"/>
+ <AllTestRestoreSources Include="@(RestoreTestFallbackSource)"/>
+ </ItemGroup>
+
+ <RemoveDir Directories="@(DirsToClean)" />
+
+ <Message Importance="High" Text="Running NuGet Restore for test asset projects..." />
+
+ <MSBuild
+ Projects="@(TestAssetProjectToRestore)"
+ Targets="Restore"
+ Properties="
+ ArtifactsShippingPackagesDir=$(ArtifactsShippingPackagesDir);
+ TestTargetRid=$(TestTargetRid);
+ MNAVersion=$(ProductVersion)" />
+ </Target>
+
+</Project>
using System;
+using System.Collections;
using System.IO;
namespace Microsoft.DotNet.CoreSetup.Test
{
RepoRoot = repoRoot ?? GetRepoRootDirectory();
- string baseArtifactsFolder = artifacts ?? Path.Combine(RepoRoot, "bin");
+ string baseArtifactsFolder = artifacts ?? Path.Combine(RepoRoot, "artifacts");
+ string baseBinFolder = artifacts ?? Path.Combine(baseArtifactsFolder, "bin");
+ string baseObjFolder = artifacts ?? Path.Combine(baseArtifactsFolder, "obj");
TargetRID = Environment.GetEnvironmentVariable("TEST_TARGETRID");
BuildRID = Environment.GetEnvironmentVariable("BUILDRID");
throw new InvalidOperationException("ERROR: Test SDK folder not found.");
}
- Artifacts = Path.Combine(baseArtifactsFolder, osPlatformConfig);
+ Artifacts = Path.Combine(baseBinFolder, osPlatformConfig);
HostArtifacts = artifacts ?? Path.Combine(Artifacts, "corehost");
NugetPackages = nugetPackages ?? Path.Combine(RepoRoot, "packages");
CorehostPackages = corehostPackages ?? Path.Combine(Artifacts, "corehost");
- BuiltDotnet = builtDotnet ?? Path.Combine(baseArtifactsFolder, "obj", osPlatformConfig, "sharedFrameworkPublish");
+ BuiltDotnet = builtDotnet ?? Path.Combine(baseObjFolder, osPlatformConfig, "sharedFrameworkPublish");
}
private static string GetRepoRootDirectory()
private TestProject CopyTestProject(TestProject sourceTestProject)
{
- EnsureDirectoryBuildProps(TestArtifact.TestArtifactsPath);
+ EnsureDirectoryBuildFiles(TestArtifact.TestArtifactsPath);
return sourceTestProject.Copy();
}
- private void EnsureDirectoryBuildProps(string testArtifactDirectory)
+ private void EnsureDirectoryBuildFiles(string testArtifactDirectory)
{
- string directoryBuildPropsPath = Path.Combine(testArtifactDirectory, "Directory.Build.props");
Directory.CreateDirectory(testArtifactDirectory);
- for(int i = 0; i < 3 && !File.Exists(directoryBuildPropsPath); i++)
+ // write an empty Directory.Build.* file to ensure that msbuild doesn't pick up
+ // the repo's root Directory.Build.*.
+ EnsureTestProjectsFileContent(testArtifactDirectory, "props");
+ EnsureTestProjectsFileContent(testArtifactDirectory, "targets");
+ }
+
+ private void EnsureTestProjectsFileContent(string dir, string type) => EnsureFileWithContent(
+ Path.Combine(dir, $"Directory.Build.{type}"),
+ string.Join(
+ Environment.NewLine,
+ "<Project>",
+ $" <Import Project=\"$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), TestProjects.{type}))\\TestProjects.{type}\" />",
+ "</Project>"));
+
+ private void EnsureFileWithContent(string path, string content)
+ {
+ for(int i = 0; i < 3 && !File.Exists(path); i++)
{
try
{
- StringBuilder propsFile = new StringBuilder();
-
- propsFile.AppendLine("<Project>");
- propsFile.AppendLine(" <Import Project=\"$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), TestProjects.props))\\TestProjects.props\" />");
- propsFile.AppendLine("</Project>");
-
- // write an empty Directory.Build.props to ensure that msbuild doesn't pick up
- // the repo's root Directory.Build.props.
- File.WriteAllText(directoryBuildPropsPath, propsFile.ToString());
+ File.WriteAllText(path, content);
}
catch (IOException)
{}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="Directory.Build.props" />
- <UsingTask TaskName="GetTargetMachineInfo" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />
-
- <PropertyGroup>
- <BuildTestTargets>
- DetermineTestOutputDirectory;
- RestoreTests;
- BuildTests;
- RunTests;
- </BuildTestTargets>
- </PropertyGroup>
-
- <Target Name="Build" DependsOnTargets="$(BuildTestTargets)" />
-
- <Target Name="DetermineTestOutputDirectory">
- <GetTargetMachineInfo>
- <Output TaskParameter="RuntimeIdentifier" PropertyName="_HostRid" />
- </GetTargetMachineInfo>
- <PropertyGroup>
- <TestTargetRid Condition="'$(TestTargetRid)' == ''">$(_HostRid)</TestTargetRid>
- <TestOSPlatformConfig>$(TestTargetRid).$(ConfigurationGroup)</TestOSPlatformConfig>
- <TestsOutputDir Condition="'$(TestsOutputDir)' == ''">$(BaseOutputPath)tests/$(TestOSPlatformConfig)/</TestsOutputDir>
- </PropertyGroup>
- </Target>
-
- <Target Name="RestoreTests">
- <ItemGroup>
- <RestoreTest Include="$(TestDir)/**/*.csproj" />
- </ItemGroup>
-
- <PropertyGroup>
- <TempFolderRoot Condition="'$(OSGroup)' == 'Windows_NT'">$(USERPROFILE)\.dotnet\</TempFolderRoot>
- <TempFolderRoot Condition="'$(OSGroup)' != 'Windows_NT'">$(HOME)/.dotnet/</TempFolderRoot>
- </PropertyGroup>
- <ItemGroup>
- <DirsToClean Include="$(TestDir)\**\bin" />
- <DirsToClean Include="$(TestDir)\**\obj" />
- <DirsToClean Include="$(TempFolderRoot)$(TargetArchitecture)" />
- </ItemGroup>
-
- <RemoveDir Directories="@(DirsToClean)" />
- <MakeDir Directories="$(TempFolderRoot)NuGetFallbackFolder" />
-
- <PropertyGroup>
- <RestoreSourceArg>@(RestoreTestSource->'--source %(Identity)', ' ')</RestoreSourceArg>
- <RestoreSourceArg>$(RestoreSourceArg) @(RestoreTestFallbackSource->'--source %(Identity)', ' ')</RestoreSourceArg>
- <RestoreArgs>--packages "$(PackagesDir.TrimEnd('/').TrimEnd('\'))" $(RestoreSourceArg)</RestoreArgs>
- <RestoreArgs>$(RestoreArgs) $(MSBuildPassThroughPropertyList) /p:MNAVersion=$(ProductVersion) /p:TestTargetRid=$(TestTargetRid)</RestoreArgs>
- <RestorePrefix Condition="'$(OsEnvironment)' != 'Windows_NT'">DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1</RestorePrefix>
- </PropertyGroup>
-
- <Exec Command="$(RestorePrefix) $(DotnetToolCommand) restore $(RestoreArgs) %(RestoreTest.Identity)"
- EnvironmentVariables="NUGET_PACKAGES=$(PackagesDir.TrimEnd('/').TrimEnd('\'))" />
- </Target>
-
- <Target Name="BuildTests"
- DependsOnTargets="DetermineTestOutputDirectory">
-
- <PropertyGroup>
- <BuildArgs>--no-restore $(MSBuildPassThroughPropertyList)</BuildArgs>
- </PropertyGroup>
-
- <Message Text="Building Tests" Importance="High" />
- <Message Importance="High" Text="TestProjects: @(TestProjects)" />
- <Exec Command="$(DotnetToolCommand) build $(BuildArgs) %(TestProjects.Identity)"
- WorkingDirectory="$([System.IO.Path]::GetDirectoryName(%(TestProjects.Identity)))"
- EnvironmentVariables="NUGET_PACKAGES=$(PackagesDir.TrimEnd('/').TrimEnd('\'))" />
- </Target>
-
- <Target Name="RunTest"
- DependsOnTargets="DetermineTestOutputDirectory"
- Inputs="%(TestProjects.Identity)"
- Outputs="fake">
- <PropertyGroup>
- <TestProject>%(TestProjects.Identity)</TestProject>
- <TestProjectFilename>%(TestProjects.Filename)</TestProjectFilename>
- <TestWorkingDirectory>$([System.IO.Path]::GetDirectoryName($(TestProject)))</TestWorkingDirectory>
- <DirectorySeparatorChar>$([System.IO.Path]::DirectorySeparatorChar)</DirectorySeparatorChar>
- <!-- The tests use the TEST_ARTIFACTS env variable to determine the artifacts folder and then later compare that path to its expected path.
- So, the TEST_ARTIFACTS variable has to have system specific path separators or the string compoarison will fail. -->
- <SystemPathTestsOutputDir>$([System.String]::Copy('$(TestsOutputDir)').Replace('/', '$(DirectorySeparatorChar)'))</SystemPathTestsOutputDir>
- <SystemPathTestsOutputDir>$([System.String]::Copy('$(SystemPathTestsOutputDir)').Replace('\', '$(DirectorySeparatorChar)'))</SystemPathTestsOutputDir>
- </PropertyGroup>
- <PropertyGroup>
- <TestArgs>--no-restore $(MSBuildPassThroughPropertyList)</TestArgs>
- <IsCrossArch>false</IsCrossArch>
- <IsCrossArch Condition="'$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'armel'">true</IsCrossArch>
- <TestResultsXml>$(SystemPathTestsOutputDir)$(TestProjectFilename)-testResults.trx</TestResultsXml>
- </PropertyGroup>
- <Exec Command="$(DotnetToolCommand) test $(TestArgs) --logger "trx;LogFileName=$(TestResultsXml)""
- WorkingDirectory="$(TestWorkingDirectory)"
- EnvironmentVariables="NUGET_PACKAGES=$(PackagesDir);TEST_ARTIFACTS=$(SystemPathTestsOutputDir);TEST_TARGETRID=$(TestTargetRid);BUILDRID=$(OutputRid);BUILD_ARCHITECTURE=$(TargetArchitecture);BUILD_CONFIGURATION=$(ConfigurationGroup);MNA_VERSION=$(ProductVersion);MNA_TFM=$(NETCoreAppFramework);DOTNET_SDK_PATH=$(DotnetCliPath)"
- Condition="'$(TestProjectFilename)' != 'HostActivation.Tests' or '$(IsCrossArch)' != 'true'"
- ContinueOnError="true"
- IgnoreStandardErrorWarningFormat="true"
- IgnoreExitCode="true">
- <Output TaskParameter="ExitCode" PropertyName="_ErrorCode" />
- </Exec>
-
- <ItemGroup>
- <TestResults Include="$(TestProject)">
- <ResultsXml>$(TestResultsXml)</ResultsXml>
- <ExitCode>$(_ErrorCode)</ExitCode>
- <ExitCode Condition="'$(_ErrorCode)' == ''">0</ExitCode>
- </TestResults>
- </ItemGroup>
- <Message Importance="High" Condition="'$(_ErrorCode)' != '0' and '$(_ErrorCode)' != ''" Text="Test run failed with exit code '$(_ErrorCode)', see $(TestResultsXml)" />
- </Target>
-
- <Target Name="RunTests"
- DependsOnTargets="PrepareTestFolders;RunTest">
- <ItemGroup>
- <FailedTests Include="@(TestResults)" Condition="'%(TestResults.ExitCode)' != '0'">
- </FailedTests>
- </ItemGroup>
- <Message Importance="High" Condition="'@(FailedTests)' != ''" Text="Failed test summary" />
- <Message Importance="High" Condition="'@(FailedTests)' != ''" Text=" %(FailedTests.Identity) failed with exit code %(FailedTests.ExitCode), see %(FailedTests.ResultsXml)" />
- <Error Condition="'@(FailedTests)' != ''" Text="One or more test runs failed." />
- </Target>
-
- <Target Name="PrepareTestFolders"
- DependsOnTargets="DetermineTestOutputDirectory">
- <ItemGroup>
- <SharedFrameworkPublishFiles Include="$(IntermediateOutputRootPath)sharedFrameworkPublish/**" />
- </ItemGroup>
-
- <Copy SourceFiles="@(SharedFrameworkPublishFiles)"
- DestinationFiles="@(SharedFrameworkPublishFiles->'$(TestsOutputDir)sharedFrameworkPublish/%(RecursiveDir)%(Filename)%(Extension)')" />
- </Target>
-
-</Project>