From e58cc3a7dd76a8467f84119e8a0c4e473ebcc709 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Tue, 9 Apr 2024 15:57:08 +0100 Subject: [PATCH] Simplify the use of the AltCover MSBuild tasks via the associated package-level `.targets` file --- AltCover.Api.Tests/AltCover.Api.Tests.fsproj | 2 +- AltCover.Api.Tests/FSApiTests.fs | 2 +- AltCover.Tests/AltCover.Tests.fsproj | 2 +- AltCover.Tests/Runner.Tests.fs | 2 +- AltCover.Tests/Tests3.fs | 2 +- AltCover.sln | 1 + ReleaseNotes.md | 1 + nupkg/build/AltCover.proj | 220 +++++++++++++++++++ nupkg/build/AltCover.targets | 218 +----------------- 9 files changed, 228 insertions(+), 222 deletions(-) create mode 100644 nupkg/build/AltCover.proj diff --git a/AltCover.Api.Tests/AltCover.Api.Tests.fsproj b/AltCover.Api.Tests/AltCover.Api.Tests.fsproj index 26659449..a4ac8592 100644 --- a/AltCover.Api.Tests/AltCover.Api.Tests.fsproj +++ b/AltCover.Api.Tests/AltCover.Api.Tests.fsproj @@ -12,7 +12,7 @@ - + diff --git a/AltCover.Api.Tests/FSApiTests.fs b/AltCover.Api.Tests/FSApiTests.fs index 787ed706..2e6e16fb 100644 --- a/AltCover.Api.Tests/FSApiTests.fs +++ b/AltCover.Api.Tests/FSApiTests.fs @@ -1148,7 +1148,7 @@ module FSApiTests = Assembly .GetExecutingAssembly() .GetManifestResourceNames() - |> Seq.find _.EndsWith("AltCover.targets", StringComparison.Ordinal) + |> Seq.find _.EndsWith("AltCover.proj", StringComparison.Ordinal) use stream = Assembly diff --git a/AltCover.Tests/AltCover.Tests.fsproj b/AltCover.Tests/AltCover.Tests.fsproj index ce7b18b4..890d0c3a 100644 --- a/AltCover.Tests/AltCover.Tests.fsproj +++ b/AltCover.Tests/AltCover.Tests.fsproj @@ -40,7 +40,7 @@ - + diff --git a/AltCover.Tests/Runner.Tests.fs b/AltCover.Tests/Runner.Tests.fs index 91b6491c..7eb938a9 100644 --- a/AltCover.Tests/Runner.Tests.fs +++ b/AltCover.Tests/Runner.Tests.fs @@ -910,7 +910,7 @@ module AltCoverRunnerTests = Assembly .GetExecutingAssembly() .GetManifestResourceNames() - |> Seq.find _.EndsWith("AltCover.targets", StringComparison.Ordinal) + |> Seq.find _.EndsWith("AltCover.proj", StringComparison.Ordinal) use stream = Assembly diff --git a/AltCover.Tests/Tests3.fs b/AltCover.Tests/Tests3.fs index 134e1a24..999a99de 100644 --- a/AltCover.Tests/Tests3.fs +++ b/AltCover.Tests/Tests3.fs @@ -203,7 +203,7 @@ module AltCoverTests3 = Assembly .GetExecutingAssembly() .GetManifestResourceNames() - |> Seq.find _.EndsWith("AltCover.targets", StringComparison.Ordinal) + |> Seq.find _.EndsWith("AltCover.proj", StringComparison.Ordinal) use stream = Assembly diff --git a/AltCover.sln b/AltCover.sln index ee121eb6..222e0b98 100644 --- a/AltCover.sln +++ b/AltCover.sln @@ -38,6 +38,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Items", "Build Items" Build\actions.fs = Build\actions.fs Build\AddStrongName.fsx = Build\AddStrongName.fsx Build\AltCover.nuspec = Build\AltCover.nuspec + nupkg\build\AltCover.proj = nupkg\build\AltCover.proj nupkg\build\AltCover.props = nupkg\build\AltCover.props nupkg\build\AltCover.targets = nupkg\build\AltCover.targets Build\Apply-Xslt.ps1 = Build\Apply-Xslt.ps1 diff --git a/ReleaseNotes.md b/ReleaseNotes.md index a7c6c00f..b36be5c9 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -5,6 +5,7 @@ read the FAQ : https://github.com/SteveGilham/altcover/wiki/FAQ # (Habu series release 28) * [BREAKING; BUGFIX] Issue #206 : Update to net6+ for `dotnet test` integration and respect the `$(IsTestProject)` setting from the `Microsoft.NET.Test.Sdk` package. +* Simplify the use of the AltCover MSBuild tasks via the associated package-level `.targets` file by not even including the `VSTest` integration unless both `'$(AltCover)' == 'true' AND '$(IsTestProject)' == 'true'`. * Mitigate instances of `System.IO.IOException: The process cannot access the file '[coverage report]' because it is being used by another process.` # 8.8.10 (Habu series release 27) diff --git a/nupkg/build/AltCover.proj b/nupkg/build/AltCover.proj new file mode 100644 index 00000000..591fd61b --- /dev/null +++ b/nupkg/build/AltCover.proj @@ -0,0 +1,220 @@ + + + + false + Info + Fail + OK + + + + + + + + + + + + + + + + + + + + + + + $ + $(AltCoverDollarChar)(ProjectName) + $(AltCoverDollarChar)(SolutionDir) + $(AltCoverDollarChar)([System.Guid]::NewGuid()) + %(AltCoverXmlOutput.RootDir)/%(AltCoverXmlOutput.Directory)/%(AltCoverXmlOutput.Filename).$(TargetFramework)%(AltCoverXmlOutput.Extension) + $(ProjectDir)coverage$(AltCoverFileExtension) + $(ProjectDir)coverage.$(TargetFramework)$(AltCoverFileExtension) + - + OpenCover + + + + $(AltCoverReport.Replace($(AltCoverProjectName),$(ProjectName)).Replace($(AltCoverNewGuid),$([System.Guid]::NewGuid().ToString()))) + $(AltCoverReport1.Replace($(AltCoverSolutionDir),'') + $(AltCoverReport1.Replace($(AltCoverSolutionDir),$(SolutionDir))) + + + + + + + + + + + + + + + + + + + + + + + + + $(TargetPath) + $([System.IO.Path]::Combine($(AltCoverInstrumentedDirectory)_$(ProjectName), $(TargetFileName))) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(AltCoverShowSummary) + Foreground + $(TargetDir) + $(AltCoverInstrumentedDirectory)_$(ProjectName) + + + + + + + + + \ No newline at end of file diff --git a/nupkg/build/AltCover.targets b/nupkg/build/AltCover.targets index 6d86fd9c..3ad15aa5 100644 --- a/nupkg/build/AltCover.targets +++ b/nupkg/build/AltCover.targets @@ -29,221 +29,5 @@ - - false - Info - Fail - OK - - - - - - - - - - - - - - - - - - - - - - - $ - $(AltCoverDollarChar)(ProjectName) - $(AltCoverDollarChar)(SolutionDir) - $(AltCoverDollarChar)([System.Guid]::NewGuid()) - %(AltCoverXmlOutput.RootDir)/%(AltCoverXmlOutput.Directory)/%(AltCoverXmlOutput.Filename).$(TargetFramework)%(AltCoverXmlOutput.Extension) - $(ProjectDir)coverage$(AltCoverFileExtension) - $(ProjectDir)coverage.$(TargetFramework)$(AltCoverFileExtension) - - - OpenCover - - - - $(AltCoverReport.Replace($(AltCoverProjectName),$(ProjectName)).Replace($(AltCoverNewGuid),$([System.Guid]::NewGuid().ToString()))) - $(AltCoverReport1.Replace($(AltCoverSolutionDir),'') - $(AltCoverReport1.Replace($(AltCoverSolutionDir),$(SolutionDir))) - - - - - - - - - - - - - - - - - - - - - - - - - $(TargetPath) - $([System.IO.Path]::Combine($(AltCoverInstrumentedDirectory)_$(ProjectName), $(TargetFileName))) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(AltCoverShowSummary) - Foreground - $(TargetDir) - $(AltCoverInstrumentedDirectory)_$(ProjectName) - - - - - - - - + \ No newline at end of file