Skip to content

Release 8.5.841

Steve Gilham edited this page Nov 19, 2022 · 10 revisions

This is the dotnet v7.0 release. It provides some more official work-rounds for the issues mentioned at that link.

Release Notes

  • To support Cake 3.0, move the Cake API assembly from AltCover.Api to a new package AltCover.Cake; this contains libraries built against Cake 2.0.0 at netcoreapp3.1 as well as the old ones built against Cake 1.0.0 at netstandard2.0 (present but in practice obsolete).
  • Following Fake.build's policy of deprecating releases older then 6 month, drop support for versions before 5.23.0
  • [BREAKING] Rename AltCover.Cake.DotNet.DotNetCoreTest to AltCover.Cake.DotNet.DotNetTest (even in the obsolete 1.0.0 build) to match the changes in the Cake APIs (and consequent chage to the test setting type in the argument list). Similarly, in the version ≥ 2.0.0 build, the type AltCover.Cake.DotNet is now a [CakeAliasCategory("DotNet")] rather than [CakeAliasCategory("DotNetCore")]
  • [API] New DotNet APIs for Fake support - ToTestPropertiesList method to emit a list of (name,value) pairs to allow customised property passing to dotnet test in the wake of the v7.0.100 regression.
  • [API] Additionally ImportModuleProperties and GetVersionProperties values that are additonal lists of (name,value) pairs to append as needed.

New package - AltCover.Cake

This is to allow support for Cake v3.0 without needlessly bloating the AltCover.Api package. All Cake support now moves here. Otherwise all is as previously documented.

How-to work around the dotnet test 7.0.100 regression

Instead of decorating the DotNetTestSettings so as to add extra /p:... arguments by

      testSettings.ArgumentCustomization = altcoverSettings.Concatenate(testSettings.ArgumentCustomization);

use the new ToTestPropertiesList API to inject the values into the test process environment

    using FSDotNet = AltCover.DotNet;

...
      var args =  FSDotNet.ToTestPropertiesList(
                      altcoverSettings.PreparationPhase,
                      altcoverSettings.CollectionPhase,
                      altcoverSettings.Options).ToArray();

      Array.ForEach(args, 
        s => { testSettings.EnvironmentVariables[s.Item1] = s.Item2;});

Scripting with Fake

How-to work around the limitation of Fake not working except on dotnet 6.0

Workrounds for running Fake at dotnet 7.0 are here.

How-to work around the dotnet test 7.0.100 regression

Add the following preamble to your script

  let dotnetVersion = DotNet.getVersion id

  let withTestEnvironment l (o: DotNet.TestOptions) =
    let before = o.Environment |> Map.toList

    let after =
      [ l; before ] |> List.concat |> Map.ofList

    o.WithEnvironment after

  let withAltCoverOptions
    (prepare: Abstract.IPrepareOptions)
    (collect: Abstract.ICollectOptions)
    (force: DotNet.ICLIOptions)
    (o: DotNet.TestOptions)
    =
    if dotnetVersion <> "7.0.100" then
      o.WithAltCoverOptions prepare collect force
    else
      withTestEnvironment (DotNet.ToTestPropertiesList prepare collect force) o

  let withAltCoverImportModule (o: DotNet.TestOptions) =
    if dotnetVersion <> "7.0.100" then
      o.WithAltCoverImportModule()
    else
      withTestEnvironment DotNet.ImportModuleProperties o

  let withAltCoverGetVersion (o: DotNet.TestOptions) =
    if dotnetVersion <> "7.0.100" then
      o.WithAltCoverGetVersion()
    else
      withTestEnvironment DotNet.GetVersionProperties o

then replace code like

Fake.DotNet.DotNet.test (fun to' -> to'.WithAltCoverOptions prepare collect ForceTrue) "dotnettest.fsproj"

with

Fake.DotNet.DotNet.test (fun to' -> to' |> (withAltCoverOptions prepare collect ForceTrue)) "dotnettest.fsproj"

NuGet Packages