Skip to content

Commit 5676060

Browse files
committed
Fix GitVersionTask on Linux
The additional import statement introduced in #1163 causes failure on Linux when a project tries to use the GitVersionTask. It seems that Mono can't cope with an empty `Project` attribute in the `Import` element. Additionally there seems to be a bug at least in Mono 3.x in that it requires the argument in `Exists` to be passed in quotes. This change fixes these two problems and allows to use the GitVersionTask again on Linux.
1 parent cc28b2d commit 5676060

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/GitVersionTask/NugetAssets/build/GitVersionTask.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<GitVersionPath Condition="'$(GitVersionPath)' == ''">$(MSBuildProjectDirectory)</GitVersionPath>
1010
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == '' And Exists('$(MSBuildProjectDirectory)\GitVersionTask.targets')">$(SolutionDir)\GitVersionTask.targets</GitVersionCustomizeTargetFile>
1111
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == '' And '$(SolutionDir)' != '' And Exists('$(SolutionDir)\GitVersionTask.targets')">$(SolutionDir)\GitVersionTask.targets</GitVersionCustomizeTargetFile>
12+
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == ''"></GitVersionCustomizeTargetFile>
1213
<IntermediateOutputPath Condition="$(IntermediateOutputPath) == '' Or $(IntermediateOutputPath) == '*Undefined*'">$(MSBuildProjectDirectory)\obj\$(Configuration)\</IntermediateOutputPath>
1314
<GitVersion_NoFetchEnabled Condition="$(GitVersion_NoFetchEnabled) == ''">false</GitVersion_NoFetchEnabled>
1415

@@ -39,7 +40,7 @@
3940
TaskName="GitVersionTask.WriteVersionInfoToBuildLog"
4041
AssemblyFile="$(GitVersionTaskLibrary)GitVersionTask.dll" />
4142

42-
<Import Project="$(GitVersionCustomizeTargetFile)" Condition="'$(GitVersionCustomizeTargetFile)' != '' and Exists($(GitVersionCustomizeTargetFile))" />
43+
<Import Project="$(GitVersionCustomizeTargetFile)" Condition="'$(GitVersionCustomizeTargetFile)' != '' and Exists('$(GitVersionCustomizeTargetFile)')" />
4344

4445
<Target Name="WriteVersionInfoToBuildLog" BeforeTargets="CoreCompile;GetAssemblyVersion;GenerateNuspec" Condition="$(WriteVersionInfoToBuildLog) == 'true'">
4546
<WriteVersionInfoToBuildLog SolutionDirectory="$(GitVersionPath)" NoFetch="$(GitVersion_NoFetchEnabled)"/>
@@ -119,4 +120,4 @@
119120
</None>
120121
</ItemGroup>
121122

122-
</Project>
123+
</Project>

src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<GitVersionPath Condition="'$(GitVersionPath)' == ''">$(MSBuildProjectDirectory)</GitVersionPath>
1010
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == '' And Exists('$(MSBuildProjectDirectory)\GitVersionTask.targets')">$(SolutionDir)\GitVersionTask.targets</GitVersionCustomizeTargetFile>
1111
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == '' And '$(SolutionDir)' != '' And Exists('$(SolutionDir)\GitVersionTask.targets')">$(SolutionDir)\GitVersionTask.targets</GitVersionCustomizeTargetFile>
12+
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == ''"></GitVersionCustomizeTargetFile>
1213
<GitVersion_NoFetchEnabled Condition="$(GitVersion_NoFetchEnabled) == ''">false</GitVersion_NoFetchEnabled>
1314

1415
<!-- Property that enables WriteVersionInfoToBuildLog -->
@@ -37,7 +38,7 @@
3738
TaskName="GitVersionTask.WriteVersionInfoToBuildLog"
3839
AssemblyFile="$(GitVersionTaskLibrary)GitVersionTask.dll" />
3940

40-
<Import Project="$(GitVersionCustomizeTargetFile)" Condition="'$(GitVersionCustomizeTargetFile)' != '' and Exists($(GitVersionCustomizeTargetFile))" />
41+
<Import Project="$(GitVersionCustomizeTargetFile)" Condition="'$(GitVersionCustomizeTargetFile)' != '' and Exists('$(GitVersionCustomizeTargetFile)')" />
4142

4243
<Target Name="WriteVersionInfoToBuildLog" BeforeTargets="DispatchToInnerBuilds;GenerateNuspec" Condition="$(WriteVersionInfoToBuildLog) == 'true'">
4344
<WriteVersionInfoToBuildLog SolutionDirectory="$(GitVersionPath)" NoFetch="$(GitVersion_NoFetchEnabled)"/>
@@ -85,4 +86,4 @@
8586
</PropertyGroup>
8687

8788
</Target>
88-
</Project>
89+
</Project>

0 commit comments

Comments
 (0)