Skip to content

GitVersionTask throws logging exceptions when task is reused, causing builds to fail. #1643

@tpaxatb

Description

@tpaxatb

When GitVersionTask is added to a wixproj (and probably other project types), and the build is hosted within Visual Studio (or executed via devenv), the MSBuild Tasks have the potential to be reused (i.e. the Execute() method can be called multiple times on the same Task object instance). Because the Execute() method Resets the Logger hooks at the end of the function, subsequent calls to the Execute causes the logging to fail with an exception and the build process fails, since the logging is not Setup again (it's only performed during construction). This failure does not occur when running via a plain msbuild, since msbuild is directing the build and constructs the tasks in a different manner. The failure does not occur with C# and VB projects because of the fact that those tasks are delegated by visual studio to external build.

There are a couple of wonky design issues I have with the logging:

  1. Failure to set up a logging callback should not cause failure to build.
  2. Since the logging methods is a callback, any object that uses it needs to be in its own AppDomain, because it is static...the last one to set it wins, which most definitely isn't the intended behavior.
  3. The logging should not be reset in the execute function if it did not set it. There is a HUGE assumption that the task object will not be reused by doing so.

(As an aside, it was darn near impossible to figure out how to build and deploy a debug version of GitVersionTask to test the theory because I didn't realize except by trial and error that the UtilPack.NuGet.MsBuild package was actually loading from the nuget cache directory)

(See also issue #1512, this seems to be the root cause)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions