Skip to content

Commit c96f0ed

Browse files
dazinatorarturcic
authored andcommitted
GitVersionTask - Removed additional MsBuild dependency.
- No longer dependent on Microsoft.Build.Tasks.Core. - Slight refactor of static type initialisers to catch exception for inspection with debugger attach during task execution.
1 parent 1134310 commit c96f0ed

10 files changed

+420
-18
lines changed

src/GitVersionTask.MsBuild/GitVersionTask.MsBuild.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<LangVersion>8.0</LangVersion>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
</PropertyGroup>
8-
8+
99
<ItemGroup>
10-
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
10+
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="System.Runtime.Loader" Version="4.3.0" PrivateAssets="All" />
1111
<PackageReference Include="Microsoft.Build" Version="16.4.0" NoWarn="NU1701" />
12-
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="16.4.0" />
12+
<PackageReference Include="Microsoft.Build.Framework" Version="16.4.0" />
1313
</ItemGroup>
1414

1515
<ItemGroup>
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
using GitVersionTask.MsBuild;
12
using Microsoft.Build.Framework;
23
using Microsoft.Build.Utilities;
34

45
namespace GitVersion.MSBuildTask
56
{
6-
public abstract class GitVersionTaskBase : Task
7+
public abstract class GitVersionTaskBase : ITask
78
{
9+
protected GitVersionTaskBase()
10+
{
11+
this.Log = new TaskLoggingHelper(this);
12+
}
13+
814
[Required]
915
public string SolutionDirectory { get; set; }
1016

@@ -13,5 +19,22 @@ public abstract class GitVersionTaskBase : Task
1319
public bool NoFetch { get; set; }
1420

1521
public bool NoNormalize { get; set; }
22+
public IBuildEngine BuildEngine { get; set; }
23+
public ITaskHost HostObject { get; set; }
24+
25+
public TaskLoggingHelper Log { get; }
26+
27+
public bool Execute()
28+
{
29+
if (TaskProxy.InitialiseException != null)
30+
{
31+
throw TaskProxy.InitialiseException;
32+
}
33+
34+
return OnExecute();
35+
}
36+
37+
protected abstract bool OnExecute();
38+
1639
}
1740
}

0 commit comments

Comments
 (0)