Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $

# VS Test Explorer support for libraries
if ($vs) {
Write-Host "!!! VS Test Explorer now works without the -vs switch. The switch will be removed eventually. !!! "
. $PSScriptRoot\common\tools.ps1

# Microsoft.DotNet.CoreSetup.sln is special - hosting tests are currently meant to run on the
Expand Down
14 changes: 13 additions & 1 deletion eng/testing/coverage.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
We need to filter the data to only the assembly being tested. Otherwise we will gather tons of data about other assemblies.
If the code being tested is part of the runtime itself, it requires special treatment.
-->
<PropertyGroup Condition="'$(AssemblyBeingTested)' == ''">
<PropertyGroup Condition="'$(AssemblyBeingTested)' == '' and '$(CreateIntermediateRunSettingsFile)' != 'true'">
<_ProjectDirectoryUnderSourceDir>$(MSBuildProjectDirectory.SubString($(LibrariesProjectRoot.Length)))</_ProjectDirectoryUnderSourceDir>
<AssemblyBeingTested>$(_ProjectDirectoryUnderSourceDir.SubString(0, $(_ProjectDirectoryUnderSourceDir.IndexOfAny("\\/"))))</AssemblyBeingTested>
</PropertyGroup>
Expand Down Expand Up @@ -74,4 +74,16 @@

<Exec Command="$(CoverageReportCommand)" />
</Target>


<!--
Clean the test results directory to guarantee that a report is generated from the
newest coverage results file.
Tracking issue https://github.com/microsoft/vstest/issues/2378.
-->
<Target Name="ClearTestResults"
BeforeTargets="VSTest"
Condition="'$(Coverage)' == 'true'">
<RemoveDir Directories="$(OutDir)TestResults" />
</Target>
</Project>
26 changes: 12 additions & 14 deletions eng/testing/runsettings.targets
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<Project>
<PropertyGroup>
<RunSettingsInputFilePath Condition="'$(RunSettingsInputFilePath)' == ''">$(MSBuildThisFileDirectory).runsettings</RunSettingsInputFilePath>
<RunSettingsOutputFilePath Condition="'$(RunSettingsOutputFilePath)' == ''">$(OutDir).runsettings</RunSettingsOutputFilePath>
<RunSettingsInputFilePath>$(MSBuildThisFileDirectory).runsettings</RunSettingsInputFilePath>
<RunSettingsIntermediateOutputFilePath>$(ArtifactsObjDir)$(TargetOS)-$(Configuration)-$(TargetArchitecture).runsettings</RunSettingsIntermediateOutputFilePath>
<RunSettingsAppOutputFilePath>$(OutDir).runsettings</RunSettingsAppOutputFilePath>

<CreateIntermediateRunSettingsFile Condition="'$(CreateIntermediateRunSettingsFile)' == ''">false</CreateIntermediateRunSettingsFile>
<RunSettingsOutputFilePath Condition="'$(CreateIntermediateRunSettingsFile)' == 'true'">$(RunSettingsIntermediateOutputFilePath)</RunSettingsOutputFilePath>
<RunSettingsOutputFilePath Condition="'$(CreateIntermediateRunSettingsFile)' != 'true'">$(RunSettingsAppOutputFilePath)</RunSettingsOutputFilePath>

<!-- Set RunSettingsFilePath property which is read by VSTest. -->
<RunSettingsFilePath Condition="Exists('$(RunSettingsOutputFilePath)')">$(RunSettingsOutputFilePath)</RunSettingsFilePath>
<RunSettingsFilePath Condition="Exists('$(RunSettingsAppOutputFilePath)')">$(RunSettingsAppOutputFilePath)</RunSettingsFilePath>
<!-- Use an intermediate runsettings file if the app hasn't been built yet to enable VSTest discovery. -->
<RunSettingsFilePath Condition="'$(RunSettingsFilePath)' == '' and Exists('$(RunSettingsIntermediateOutputFilePath)')">$(RunSettingsIntermediateOutputFilePath)</RunSettingsFilePath>

<PrepareForRunDependsOn>GenerateRunSettingsFile;$(PrepareForRunDependsOn)</PrepareForRunDependsOn>
</PropertyGroup>

Expand Down Expand Up @@ -41,15 +50,4 @@
<RunSettingsFilePath>$(RunSettingsOutputFilePath)</RunSettingsFilePath>
</PropertyGroup>
</Target>

<!--
Clean the test results directory to guarantee that a report is generated from the
newest coverage results file.
Tracking issue https://github.com/microsoft/vstest/issues/2378.
-->
<Target Name="ClearTestResults"
BeforeTargets="VSTest"
Condition="'$(Coverage)' == 'true'">
<RemoveDir Directories="$(OutDir)TestResults" />
</Target>
</Project>
1 change: 0 additions & 1 deletion eng/testing/tests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@
<!-- This app is now can be consumed by xharness CLI to deploy on a device or simulator -->
</Target>

<Import Project="$(MSBuildThisFileDirectory)runsettings.targets" />
<Import Project="$(MSBuildThisFileDirectory)xunit\xunit.targets" Condition="'$(TestFramework)' == 'xunit'" />

<!-- Main test targets -->
Expand Down
4 changes: 3 additions & 1 deletion src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@

<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<EnableTestSupport>true</EnableTestSupport>
<EnableCoverageSupport>true</EnableCoverageSupport>
<!-- TODO: Remove these conditions when VSTest is used in CI. -->
<EnableRunSettingsSupport Condition="'$(ContinuousIntegrationBuild)' != 'true'">true</EnableRunSettingsSupport>
<EnableCoverageSupport Condition="'$(ContinuousIntegrationBuild)' != 'true'">true</EnableCoverageSupport>
</PropertyGroup>

<Import Project="$(RepositoryEngineeringDir)testing\tests.props" Condition="'$(EnableTestSupport)' == 'true'" />
Expand Down
5 changes: 3 additions & 2 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@
<Import Project="$(RepositoryEngineeringDir)codeOptimization.targets" />
<Import Project="$(RepositoryEngineeringDir)references.targets" />
<Import Project="$(RepositoryEngineeringDir)resolveContract.targets" />
<Import Project="$(RepositoryEngineeringDir)testing\runtimeConfiguration.targets" />
<Import Project="$(RepositoryEngineeringDir)testing\tests.targets" Condition="'$(EnableTestSupport)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)testing\coverage.targets" Condition="'$(EnableCoverageSupport)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)testing\runtimeConfiguration.targets" />
<Import Project="$(RepositoryEngineeringDir)testing\runsettings.targets" Condition="'$(EnableRunSettingsSupport)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)testing\coverage.targets" Condition="'$(EnableRunSettingsSupport)' == 'true' or '$(EnableCoverageSupport)' == 'true'" />

<Import Sdk="Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk" Project="Sdk.targets" />
<Import Project="$(RepositoryEngineeringDir)restore\repoRestore.targets" Condition="'$(DisableProjectRestore)' == 'true'" />
Expand Down
11 changes: 11 additions & 0 deletions src/libraries/pretest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<NETCoreAppFrameworkIdentifier>$(TargetFrameworkIdentifier)</NETCoreAppFrameworkIdentifier>
</PropertyGroup>

<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
<!-- Create an intermediate runsettings file to enable VSTest discovery. -->
<EnableRunSettingsSupport>true</EnableRunSettingsSupport>
<CreateIntermediateRunSettingsFile>true</CreateIntermediateRunSettingsFile>
</PropertyGroup>

<!-- Explicitly build the runtime.depproj project first to correctly set up the testhost. -->
<ItemGroup>
<RuntimeProject Include="restore\runtime\runtime.depproj" />
Expand All @@ -19,6 +25,11 @@
Properties="$(TraversalGlobalProperties)" />
</Target>

<Target Name="CreateIntermediateRunSettingsFile"
Condition="'$(CreateIntermediateRunSettingsFile)' == 'true'"
DependsOnTargets="GenerateRunSettingsFile"
BeforeTargets="Build" />

<!-- Microsoft.XmlSerializer.Generator should not be marked as a platform item and be copy-local instead. -->
<Target Name="CollectSharedFrameworkRuntimeFiles"
Condition="'$(PlatformManifestFile)' != '' and '$(BuildingNETCoreAppVertical)' == 'true'">
Expand Down