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

Create a proper MSBuild ToolTask based VSTestTask #2702

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4479d26
Rename VSTestTask to VSTestForwardingTask (#680)
mcartoixa Jul 2, 2022
2258b9f
Refactor the VSTestForwardingTask to use the MSBuild infrastructure (…
mcartoixa Jul 2, 2022
d6d11ad
Create a ToolTask based VSTestTask that integrates nicely in the MSBu…
mcartoixa Jul 2, 2022
e57eea0
Initialize the VsTestUseConsole property during acceptance tests
mcartoixa Jul 7, 2022
16e75ab
Fix various issues raised by the latest review
mcartoixa Jul 12, 2022
a99fe16
Simplify the handling of null values
mcartoixa Jul 17, 2022
2155366
Log messages to MSBuild instead of to the console
mcartoixa Jul 17, 2022
886a2d6
Integrate changes from the latest code review
mcartoixa Jul 31, 2022
37ba20b
Merge branch 'main' into vstesttask-complete
nohwnd Sep 29, 2023
6f6fdda
Patch dotnet with newest build task
nohwnd Sep 29, 2023
61e5df5
Merge branch 'main' into vstesttask-complete
nohwnd Oct 12, 2023
dc4da9e
wip
nohwnd Oct 12, 2023
cf3fb90
rnm
nohwnd Oct 12, 2023
3d98927
revert tests
nohwnd Oct 12, 2023
4824364
tests
nohwnd Oct 12, 2023
399d9a8
Try adding msbuild specialized logger to output errors on tests
nohwnd Oct 12, 2023
3198356
Use simpler logger
nohwnd Oct 13, 2023
db4cde3
wip
nohwnd Nov 10, 2023
2255f3e
fix no-source
nohwnd Nov 14, 2023
a0b5639
fix no-source
nohwnd Nov 14, 2023
3585554
add message for full error
nohwnd Nov 15, 2023
b7760e6
Revert playground
nohwnd Nov 15, 2023
d46898c
Revert console logger
nohwnd Nov 15, 2023
f2df5fa
Revert integration tests
nohwnd Nov 15, 2023
9f17c68
Revert change in integration tests
nohwnd Nov 15, 2023
47058ee
Fix test
nohwnd Nov 15, 2023
bafd154
Revert test unignore
nohwnd Nov 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
100 changes: 0 additions & 100 deletions src/Microsoft.TestPlatform.Build/ArgumentEscaper.cs

This file was deleted.

102 changes: 73 additions & 29 deletions src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets
Expand Up @@ -14,9 +14,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup>
<VSTestTaskAssemblyFile Condition="$(VSTestTaskAssemblyFile) == ''">Microsoft.TestPlatform.Build.dll</VSTestTaskAssemblyFile>
<VSTestConsolePath Condition="$(VSTestConsolePath) == ''">$([System.IO.Path]::Combine($(MSBuildThisFileDirectory),"vstest.console.dll"))</VSTestConsolePath>
<VSTestNoBuild Condition="'$(VSTestNoBuild)' == ''">False</VSTestNoBuild>
<VsTestUseMSBuildOutput Condition="'$(VsTestUseMSBuildOutput)' == ''">False</VsTestUseMSBuildOutput>
</PropertyGroup>
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.VSTestTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.VSTestTask2" AssemblyFile="$(VSTestTaskAssemblyFile)" />

<!--
============================================================
Expand All @@ -25,11 +28,52 @@ Copyright (c) .NET Foundation. All rights reserved.
============================================================
-->
<Target Name="VSTest" DependsOnTargets="ShowInfoMessageIfProjectHasNoIsTestProjectProperty">
<!-- Unloggable colorized output (cf. https://github.com/microsoft/vstest/issues/680) -->
<CallTarget Targets="_VSTestConsole" Condition="!$(VsTestUseMSBuildOutput)" />
<!-- Proper MSBuild integration, but no custom colorization -->
<CallTarget Targets="_VSTestMSBuild" Condition="$(VsTestUseMSBuildOutput)" />
</Target>

<!-- Used when called from dotnet msbuild command line: uses MSBuild logs but does not allow for console colorization -->
<Target Name="_VSTestMSBuild" Condition="'$(IsTestProject)' == 'true'">
<CallTarget Condition="!$(VSTestNoBuild)" Targets="BuildProject" />

<VSTestTask2
TestFileFullPath="$(TargetPath)"
VSTestSetting="$([MSBuild]::ValueOrDefault($(VSTestSetting), '$(RunSettingsFilePath)'))"
VSTestTestAdapterPath="$(VSTestTestAdapterPath)"
VSTestFramework="$(TargetFrameworkMoniker)"
VSTestPlatform="$(PlatformTarget)"
VSTestTestCaseFilter="$(VSTestTestCaseFilter)"
VSTestLogger="$(VSTestLogger)"
VSTestListTests="$(VSTestListTests)"
VSTestDiag="$(VSTestDiag)"
VSTestCLIRunSettings="$(VSTestCLIRunSettings)"
VSTestConsolePath="$(VSTestConsolePath)"
VSTestResultsDirectory="$(VSTestResultsDirectory)"
VSTestVerbosity="$(VSTestVerbosity)"
VSTestCollect="$(VSTestCollect)"
VSTestBlame="$(VSTestBlame)"
VSTestBlameCrash="$(VSTestBlameCrash)"
VSTestBlameCrashDumpType="$(VSTestBlameCrashDumpType)"
VSTestBlameCrashCollectAlways="$(VSTestBlameCrashCollectAlways)"
VSTestBlameHang="$(VSTestBlameHang)"
VSTestBlameHangDumpType="$(VSTestBlameHangDumpType)"
VSTestBlameHangTimeout="$(VSTestBlameHangTimeout)"
VSTestTraceDataCollectorDirectoryPath="$(TraceDataCollectorDirectoryPath)"
VSTestArtifactsProcessingMode="$(VSTestArtifactsProcessingMode)"
VSTestSessionCorrelationId="$(VSTestSessionCorrelationId)"
VSTestNoLogo="$(VSTestNoLogo)"
/>
</Target>

<!-- Used when called from dotnet test command line: does not use MSBuild logs to allow for console colorization -->
<Target Name="_VSTestConsole">
<CallTarget Condition="'$(VSTestNoBuild)' != 'true' AND '$(IsTestProject)' == 'true'" Targets="BuildProject" />

<CallTarget Targets="ShowCallOfVSTestTaskWithParameter" />

<Microsoft.TestPlatform.Build.Tasks.VSTestTask
<VSTestTask
TestFileFullPath="$(TargetPath)"
VSTestSetting="$([MSBuild]::ValueOrDefault($(VSTestSetting), '$(RunSettingsFilePath)'))"
VSTestTestAdapterPath="$(VSTestTestAdapterPath)"
Expand Down Expand Up @@ -60,47 +104,47 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="ShowInfoMessageIfProjectHasNoIsTestProjectProperty" Condition="'$(IsTestProject)' == ''">
<Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask LogType="NoIsTestProjectProperty" ProjectFilePath="$(MSBuildProjectFullPath)" />
<VSTestLogsTask LogType="NoIsTestProjectProperty" ProjectFilePath="$(MSBuildProjectFullPath)" />
</Target>

<Target Name="BuildProject">
<CallTarget Targets="ShowMsbuildWithParameter" />

<Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask LogType="BuildStarted" />
<VSTestLogsTask LogType="BuildStarted" />
<MSBuild Projects ="$(MSBuildProjectFullPath)" />
<Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask LogType="BuildCompleted" />
<VSTestLogsTask LogType="BuildCompleted" />

<Message Text="Done Building project $(MSBuildProjectFullPath) for TargetFramework=$(TargetFramework)" Importance="low" />
<Message Importance="Low" Text="Done Building project $(MSBuildProjectFullPath) for TargetFramework=$(TargetFramework)" />
</Target>

<Target Name="ShowMsbuildWithParameter">
<Message Text="Building project $(MSBuildProjectFullPath) for TargetFramework=$(TargetFramework)" Importance="low"/>
<Message Text="Value passed to msbuild are..." Importance="low" />
<Message Text="Configuration = $(Configuration)" Importance="low" />
<Message Text="TargetFramework = $(TargetFramework)" Importance="low" />
<Message Text="Platform = $(PlatformTarget)" Importance="low" />
<Message Text="OutputPath = $(OutputPath)" Importance="low" />
<Message Importance="Low" Text="Building project $(MSBuildProjectFullPath) for TargetFramework=$(TargetFramework)" />
<Message Importance="Low" Text="Value passed to msbuild are..." />
<Message Importance="Low" Text="Configuration = $(Configuration)" />
<Message Importance="Low" Text="TargetFramework = $(TargetFramework)" />
<Message Importance="Low" Text="Platform = $(PlatformTarget)" />
<Message Importance="Low" Text="OutputPath = $(OutputPath)" />
</Target>

<Target Name="ShowCallOfVSTestTaskWithParameter">
<Message Text="Calling task Microsoft.TestPlatform.Build.Tasks.VSTestTask with following parameter..." Importance="low" />
<Message Text="TestFileFullPath = $(TargetPath)" Importance="low" />
<Message Text="VSTestSetting = $(VSTestSetting)" Importance="low" />
<Message Text="VSTestTestAdapterPath = $(VSTestTestAdapterPath)" Importance="low" />
<Message Text="VSTestFramework = $(TargetFrameworkMoniker)" Importance="low" />
<Message Text="VSTestPlatform = $(PlatformTarget)" Importance="low" />
<Message Text="VSTestTestCaseFilter = $(VSTestTestCaseFilter)" Importance="low" />
<Message Text="VSTestLogger = $(VSTestLogger)" Importance="low" />
<Message Text="VSTestListTests = $(VSTestListTests)" Importance="low" />
<Message Text="VSTestDiag = $(VSTestDiag)" Importance="low" />
<Message Text="VSTestCLIRunSettings = $(VSTestCLIRunSettings)" Importance="low" />
<Message Text="VSTestResultsDirectory = $(VSTestResultsDirectory)" Importance="low" />
<Message Text="VSTestConsolePath = $(VSTestConsolePath)" Importance="low" />
<Message Text="VSTestVerbosity = $(VSTestVerbosity)" Importance="low" />
<Message Text="VSTestCollect = $(VSTestCollect)" Importance="low" />
<Message Text="VSTestBlame = $(VSTestBlame)" Importance="low" />
<Message Text="VSTestTraceDataCollectorDirectoryPath = $(TraceDataCollectorDirectoryPath)" Importance="low" />
<Message Text="VSTestNoLogo = $(VSTestNoLogo)" Importance="low" />
<Message Importance="Low" Text="Calling task Microsoft.TestPlatform.Build.Tasks.VSTestTask with following parameter..." />
<Message Importance="Low" Text="TestFileFullPath = $(TargetPath)" />
<Message Importance="Low" Text="VSTestSetting = $(VSTestSetting)" />
<Message Importance="Low" Text="VSTestTestAdapterPath = $(VSTestTestAdapterPath)" />
<Message Importance="Low" Text="VSTestFramework = $(TargetFrameworkMoniker)" />
<Message Importance="Low" Text="VSTestPlatform = $(PlatformTarget)" />
<Message Importance="Low" Text="VSTestTestCaseFilter = $(VSTestTestCaseFilter)" />
<Message Importance="Low" Text="VSTestLogger = $(VSTestLogger)" />
<Message Importance="Low" Text="VSTestListTests = $(VSTestListTests)" />
<Message Importance="Low" Text="VSTestDiag = $(VSTestDiag)" />
<Message Importance="Low" Text="VSTestCLIRunSettings = $(VSTestCLIRunSettings)" />
<Message Importance="Low" Text="VSTestResultsDirectory = $(VSTestResultsDirectory)" />
<Message Importance="Low" Text="VSTestConsolePath = $(VSTestConsolePath)" />
<Message Importance="Low" Text="VSTestVerbosity = $(VSTestVerbosity)" />
<Message Importance="Low" Text="VSTestCollect = $(VSTestCollect)" />
<Message Importance="Low" Text="VSTestBlame = $(VSTestBlame)" />
<Message Importance="Low" Text="VSTestTraceDataCollectorDirectoryPath = $(TraceDataCollectorDirectoryPath)" />
<Message Importance="Low" Text="VSTestNoLogo = $(VSTestNoLogo)" />
</Target>

</Project>