-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify the use of the AltCover MSBuild tasks via the associated pac…
…kage-level `.targets` file
- Loading branch information
1 parent
3aacf27
commit e58cc3a
Showing
9 changed files
with
228 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<PropertyGroup> | ||
<AltCoverInPlace Condition="'$(AltCoverInPlace)' == ''">false</AltCoverInPlace> | ||
<AltCoverVerbosity Condition="'$(AltCoverVerbosity)' == ''">Info</AltCoverVerbosity> | ||
<AltCoverPreFlightCheck Condition="Exists('$(AltCoverSavedDirectory)_$(ProjectName)') AND '$(AltCoverInPlace)' != 'false'">Fail</AltCoverPreFlightCheck> | ||
<AltCoverPreFlightCheck Condition="!Exists('$(AltCoverSavedDirectory)_$(ProjectName)') OR '$(AltCoverInPlace)' == 'false'">OK</AltCoverPreFlightCheck> | ||
</PropertyGroup> | ||
|
||
<Target Name="AltCoverPreFlight" Condition="'$(AltCover)' == 'true' AND '$(AltCoverInPlace)' == 'false'"> | ||
<Message Condition="Exists('$(AltCoverInstrumentedDirectory)_$(ProjectName)') AND '$(AltCoverForce)' == 'true'" | ||
Importance="High" | ||
Text="Directory '$(AltCoverInstrumentedDirectory)_$(ProjectName)' exists from a previous run. Forcibly deleting it" /> | ||
<RemoveDir Directories="$(AltCoverInstrumentedDirectory)_$(ProjectName)" | ||
Condition="Exists('$(AltCoverInstrumentedDirectory)_$(ProjectName)') AND '$(AltCoverForce)' == 'true'" /> | ||
</Target> | ||
|
||
<Target Name="AltCoverPreFlight" Condition="'$(AltCover)' == 'true' AND '$(AltCoverInPlace)' != 'false'"> | ||
<Error Condition="Exists('$(AltCoverSavedDirectory)_$(ProjectName)') AND '$(AltCoverForce)' != 'true'" | ||
Text="Directory '$(AltCoverSavedDirectory)_$(ProjectName)' exists from a previous run. Either manually examine and delete it, or run with '/p:AltCoverForce=true' to force deletion" /> | ||
<Warning Condition="Exists('$(AltCoverSavedDirectory)_$(ProjectName)') AND '$(AltCoverForce)' == 'true'" | ||
Text="Directory '$(AltCoverSavedDirectory)_$(ProjectName)' exists from a previous run. Forcibly deleting it" /> | ||
<RemoveDir Directories="$(AltCoverSavedDirectory)_$(ProjectName)" | ||
Condition="Exists('$(AltCoverSavedDirectory)_$(ProjectName)') AND '$(AltCoverForce)' == 'true'" /> | ||
</Target> | ||
|
||
<Target Name="AltCoverRunPreparation" Condition="'$(AltCover)' == 'true'"> | ||
<ItemGroup> | ||
<AltCoverXmlOutput Include="$([MSBuild]::Unescape($(AltCoverReport)))" /> | ||
<AltCoverInputDirectory Include="$(TargetDir)" /> | ||
<AltCoverOutputDirectory Condition="'$(AltCoverInPlace)' == 'false'" Include="$(AltCoverInstrumentedDirectory)_$(ProjectName)" /> | ||
<AltCoverOutputDirectory Condition="'$(AltCoverInPlace)' != 'false'" Include="$(AltCoverSavedDirectory)_$(ProjectName)" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<AltCoverDollarChar>$</AltCoverDollarChar> | ||
<AltCoverProjectName>$(AltCoverDollarChar)(ProjectName)</AltCoverProjectName> | ||
<AltCoverSolutionDir>$(AltCoverDollarChar)(SolutionDir)</AltCoverSolutionDir> | ||
<AltCoverNewGuid>$(AltCoverDollarChar)([System.Guid]::NewGuid())</AltCoverNewGuid> | ||
<AltCoverReport Condition="'$(AltCoverReport)' != '' AND '$(TargetFrameworks)' != ''">%(AltCoverXmlOutput.RootDir)/%(AltCoverXmlOutput.Directory)/%(AltCoverXmlOutput.Filename).$(TargetFramework)%(AltCoverXmlOutput.Extension)</AltCoverReport> | ||
<AltCoverReport Condition="'$(AltCoverReport)' == '' AND '$(TargetFrameworks)' == ''">$(ProjectDir)coverage$(AltCoverFileExtension)</AltCoverReport> | ||
<AltCoverReport Condition="'$(AltCoverReport)' == '' AND '$(TargetFrameworks)' != ''">$(ProjectDir)coverage.$(TargetFramework)$(AltCoverFileExtension)</AltCoverReport> | ||
<AltCoverShowStatic Condition="'$(AltCoverShowStatic' != '+' AND '$(AltCoverShowStatic' != '++'">-</AltCoverShowStatic> | ||
<AltCoverReportFormat Condition="'$(AltCoverReportFormat)' == ''">OpenCover</AltCoverReportFormat> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<AltCoverReport1>$(AltCoverReport.Replace($(AltCoverProjectName),$(ProjectName)).Replace($(AltCoverNewGuid),$([System.Guid]::NewGuid().ToString())))</AltCoverReport1> | ||
<AltCoverReport2 Condition="'$(SolutionDir)' == ''">$(AltCoverReport1.Replace($(AltCoverSolutionDir),'')</AltCoverReport2> | ||
<AltCoverReport2 Condition="'$(SolutionDir)' != ''">$(AltCoverReport1.Replace($(AltCoverSolutionDir),$(SolutionDir)))</AltCoverReport2> | ||
</PropertyGroup> | ||
|
||
<AltCover.PowerShell Condition="'$(AltCoverImportModule)' == 'true'" /> | ||
<AltCover.GetVersion Condition="'$(AltCoverGetVersion)' == 'true'" /> | ||
<AltCover.Prepare | ||
InputDirectories="@(AltCoverInputDirectory)" | ||
OutputDirectories="@(AltCoverOutputDirectory)" | ||
InPlace="$(AltCoverInPlace)" | ||
SymbolDirectories="$(AltCoverSymbolDirectories.Split('|'))" | ||
Dependencies="$(AltCoverDependencyList.Trim('|').Split('|'))" | ||
Keys="$(AltCoverKeys.Split('|'))" | ||
StrongNameKey="$(AltCoverStrongNameKey)" | ||
Report="$(AltCoverReport2)" | ||
FileFilter="$(AltCoverFileFilter.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
AssemblyFilter="$(AltCoverAssemblyFilter.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
AssemblyExcludeFilter="$(AltCoverAssemblyExcludeFilter.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
TypeFilter="$(AltCoverTypeFilter.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
MethodFilter="$(AltCoverMethodFilter.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
AttributeFilter="$(AltCoverAttributeFilter.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
PathFilter="$(AltCoverPathFilter.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
AttributeTopLevel="$(AltCoverAttributeTopLevel.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
TypeTopLevel="$(AltCoverTypeTopLevel.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
MethodTopLevel="$(AltCoverMethodTopLevel.Replace('\',%00).Replace('||',%01).Split('|'))" | ||
ReportFormat="$(AltCoverReportFormat)" | ||
CallContext="$(AltCoverCallContext.Split('|'))" | ||
ZipFile="$(AltCoverZipFile)" | ||
MethodPoint="$(AltCoverMethodPoint)" | ||
SingleVisit="$(AltCoverSingle)" | ||
LineCover="$(AltCoverLineCover)" | ||
BranchCover="$(AltCoverBranchCover)" | ||
SourceLink="$(AltCoverSourceLink)" | ||
LocalSource="$(AltCoverLocalSource)" | ||
VisibleBranches="$(AltCoverVisibleBranches)" | ||
ShowStatic="$(AltCoverShowStatic)" | ||
ShowGenerated="$(AltCoverShowGenerated)" | ||
Verbosity="$(AltCoverVerbosity)" | ||
Trivia="$(AltCoverTrivia)" /> | ||
</Target> | ||
|
||
<!-- Override Microsoft.TestPlatform.targets to do coverage work --> | ||
<Target Name="VSTest" DependsOnTargets="ShowInfoMessageIfProjectHasNoIsTestProjectProperty"> | ||
<CallTarget Targets="AltCoverVSTestPreFlight" ContinueOnError="ErrorAndStop" /> | ||
<CallTarget Targets="AltCoverVSTestCore" /> | ||
</Target> | ||
|
||
<!-- As per the first part of Microsoft.TestPlatform.targets v2.1.300, but with pre-flight checks clause --> | ||
<Target Name="AltCoverVSTestPreFlight"> | ||
<CallTarget Targets="AltCoverPreFlight" Condition="'$(IsTestProject)' == 'true'" /> | ||
<CallTarget Condition="'$(VSTestNoBuild)' != 'true' AND '$(IsTestProject)' == 'true'" Targets="BuildProject" /> | ||
<CallTarget Condition="'$(IsTestProject)' != 'true'" Targets="ShowCallOfVSTestTaskWithParameter" /> | ||
<CallTarget Condition="'$(IsTestProject)' == 'true'" Targets="AltCoverRunPreparation" ContinueOnError="ErrorAndStop" /> | ||
</Target> | ||
|
||
<!-- As per the second part Microsoft.TestPlatform.targets v2.1.809, but with OnError clause --> | ||
<Target Name="AltCoverVSTestCore"> | ||
<PropertyGroup> | ||
<AltCoverTestTargetPath Condition="'$(AltCover)' != 'true' OR '$(AltCoverInPlace)' != 'false'">$(TargetPath)</AltCoverTestTargetPath> | ||
<AltCoverTestTargetPath Condition="'$(AltCover)' == 'true' AND '$(AltCoverInPlace)' == 'false'">$([System.IO.Path]::Combine($(AltCoverInstrumentedDirectory)_$(ProjectName), $(TargetFileName)))</AltCoverTestTargetPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<AltCoverBuildItem Include="@(ApplicationDefinition)" /> | ||
<AltCoverBuildItem Include="@(EditorConfigFiles)" /> | ||
<AltCoverBuildItem Include="@(XamlAppDef)" /> | ||
<AltCoverBuildItem Include="@(DesignData)" /> | ||
<AltCoverBuildItem Include="@(CodeAnalysisDictionary)" /> | ||
<AltCoverBuildItem Include="@(None)" /> | ||
<AltCoverBuildItem Include="@(Resource)" /> | ||
<AltCoverBuildItem Include="@(EntityDeploy)" /> | ||
<AltCoverBuildItem Include="@(Compile)" /> | ||
<AltCoverBuildItem Include="@(SplashScreen)" /> | ||
<AltCoverBuildItem Include="@(Content)" /> | ||
<AltCoverBuildItem Include="@(EmbeddedResource)" /> | ||
<AltCoverBuildItem Include="@(Page)" /> | ||
<AltCoverBuildItem Include="@(DesignDataWithDesignTimeCreatableTypes)" /> | ||
<AltCoverBuildItem Include="@(AdditionalFiles)" /> | ||
</ItemGroup> | ||
|
||
<AltCover.ContingentCopy | ||
Condition="'$(AltCoverTestTargetPath)' != '$(TargetPath)' AND ('%(AltCoverBuildItem.CopyToOutputDirectory)' == 'Always' OR '%(AltCoverBuildItem.CopyToOutputDirectory)' == 'PreserveNewest' )" | ||
RelativeDir="%(AltCoverBuildItem.RelativeDir)" | ||
ProjectDir="$(ProjectDir)" | ||
CopyToOutputDirectory="%(AltCoverBuildItem.CopyToOutputDirectory)" | ||
FileName="%(AltCoverBuildItem.FullPath)" | ||
BuildOutputDirectory="$(TargetDir)" | ||
InstrumentDirectory="$(AltCoverInstrumentedDirectory)_$(ProjectName)" /> | ||
|
||
<AltCover.RunSettings | ||
TestSetting="$(VSTestSetting)" | ||
Verbosity="$(AltCoverVerbosity)"> | ||
<Output TaskParameter="Extended" PropertyName="VSTestSetting" /> | ||
</AltCover.RunSettings> | ||
|
||
<CallTarget Targets="ShowCallOfVSTestTaskWithParameter" /> | ||
|
||
<Microsoft.TestPlatform.Build.Tasks.VSTestTask | ||
TestFileFullPath="$(AltCoverTestTargetPath)" | ||
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)" | ||
Condition="'$(IsTestProject)' == 'true'" /> | ||
|
||
<OnError ExecuteTargets="AltCoverGenerateCoverageResult" Condition="'$(AltCoverFailFast)' != 'true'" /> | ||
<OnError ExecuteTargets="AltCoverTidy" Condition="'$(AltCoverFailFast)' == 'true'" /> | ||
</Target> | ||
|
||
<Target Name="AltCoverDeleteTempRunSettingsFile"> | ||
<Message Text="Deleting $(VSTestSetting)" /> | ||
<Delete Files="$(VSTestSetting)"> | ||
<Output TaskParameter="DeletedFiles" ItemName="AltCoverDeletedList" /> | ||
</Delete> | ||
<Message Text="Deleted files: '@(AltCoverDeletedList)'" /> | ||
</Target> | ||
|
||
<Target Name="AltCoverTidy"> | ||
<ItemGroup> | ||
<AltCoverRecorderGFiles Include="$(TargetDir)/AltCover.Recorder.g.*" /> | ||
<AltCoverSavedFiles Include="$(AltCoverSavedDirectory))_$(ProjectName)/*.*" /> | ||
</ItemGroup> | ||
<CallTarget Targets="AltCoverDeleteTempRunSettingsFile" | ||
Condition="$(VSTestSetting.EndsWith('.altcover.runsettings')) AND Exists($(VSTestSetting))" /> | ||
<Move SourceFiles="@(AltCoverSavedFiles)" DestinationFolder="$(TargetDir)" OverwriteReadOnlyFiles="true" Condition="'$(AltCoverInPlace)' != 'false'" /> | ||
<RemoveDir Directories="$(AltCoverSavedDirectory)_$(ProjectName)" Condition="Exists('$(AltCoverSavedDirectory))_$(ProjectName)') AND '$(AltCoverInPlace)' != 'false'" /> | ||
<AltCover.RetryDelete Files="@(AltCoverRecorderGFiles)" Condition="'$(AltCoverInPlace)' != 'false'" /> | ||
</Target> | ||
|
||
<Target Name="AltCoverGenerateCoverageResult" AfterTargets="VSTest" Condition="'$(AltCover)' == 'true'"> | ||
<PropertyGroup> | ||
<AltCoverColour Condition="'$(AltCoverShowSummary)' != ''">$(AltCoverShowSummary)</AltCoverColour> | ||
<AltCoverColour Condition="'$(AltCoverShowSummary)' == ''">Foreground</AltCoverColour> | ||
<AltCoverRecorderDirectory Condition="'$(AltCover)' != 'true' OR '$(AltCoverInPlace)' != 'false'">$(TargetDir)</AltCoverRecorderDirectory> | ||
<AltCoverRecorderDirectory Condition="'$(AltCover)' == 'true' AND '$(AltCoverInPlace)' == 'false'">$(AltCoverInstrumentedDirectory)_$(ProjectName)</AltCoverRecorderDirectory> | ||
</PropertyGroup> | ||
|
||
<AltCover.Collect | ||
RecorderDirectory="$(AltCoverRecorderDirectory)" | ||
LcovReport="$(AltCoverLcovReport)" | ||
Threshold="$(AltCoverThreshold)" | ||
Cobertura="$(AltCoverCobertura)" | ||
SummaryFormat="$(AltCoverSummaryFormat)" | ||
Verbosity="$(AltCoverVerbosity)"> | ||
<Output TaskParameter="Summary" PropertyName="AltCoverSummary" /> | ||
</AltCover.Collect> | ||
<AltCover.Echo Condition="'$(AltCoverShowSummary)' != '' AND '$(AltCoverSummary)' !=''" | ||
Text="$(AltCoverSummary)" Colour="$(AltCoverColour)" | ||
Verbosity="$(AltCoverVerbosity)" /> | ||
<CallTarget Targets="AltCoverTidy" /> | ||
</Target> | ||
</Project> |
Oops, something went wrong.