Skip to content

Commit 43db5c7

Browse files
authored
Merge pull request #1163 from mrswain/issue-1162
GitVersionTask should use .git relative to project directory
2 parents f554e4a + 3355263 commit 43db5c7

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/GitVersionTask/NugetAssets/build/GitVersionTask.targets

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<GitVersion_Task_targets_Imported>True</GitVersion_Task_targets_Imported>
5+
</PropertyGroup>
36
<PropertyGroup>
47
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
8+
<GitVersionPath Condition="'$(GitVersionPath)' == '' And '$(GitVersionUseSolutionDir)' == 'true'">$(SolutionDir)</GitVersionPath>
9+
<GitVersionPath Condition="'$(GitVersionPath)' == ''">$(MSBuildProjectDirectory)</GitVersionPath>
10+
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == '' And Exists('$(MSBuildProjectDirectory)\GitVersionTask.targets')">$(SolutionDir)\GitVersionTask.targets</GitVersionCustomizeTargetFile>
11+
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == '' And '$(SolutionDir)' != '' And Exists('$(SolutionDir)\GitVersionTask.targets')">$(SolutionDir)\GitVersionTask.targets</GitVersionCustomizeTargetFile>
512
<IntermediateOutputPath Condition="$(IntermediateOutputPath) == '' Or $(IntermediateOutputPath) == '*Undefined*'">$(MSBuildProjectDirectory)\obj\$(Configuration)\</IntermediateOutputPath>
613
<GitVersion_NoFetchEnabled Condition="$(GitVersion_NoFetchEnabled) == ''">false</GitVersion_NoFetchEnabled>
714

@@ -32,13 +39,15 @@
3239
TaskName="GitVersionTask.WriteVersionInfoToBuildLog"
3340
AssemblyFile="$(GitVersionTaskLibrary)GitVersionTask.dll" />
3441

42+
<Import Project="$(GitVersionCustomizeTargetFile)" Condition="'$(GitVersionCustomizeTargetFile)' != '' and Exists($(GitVersionCustomizeTargetFile))" />
43+
3544
<Target Name="WriteVersionInfoToBuildLog" BeforeTargets="CoreCompile;GetAssemblyVersion;GenerateNuspec" Condition="$(WriteVersionInfoToBuildLog) == 'true'">
36-
<WriteVersionInfoToBuildLog SolutionDirectory="$(SolutionDir)" NoFetch="$(GitVersion_NoFetchEnabled)"/>
45+
<WriteVersionInfoToBuildLog SolutionDirectory="$(GitVersionPath)" NoFetch="$(GitVersion_NoFetchEnabled)"/>
3746
</Target>
3847

3948
<Target Name="UpdateAssemblyInfo" BeforeTargets="CoreCompile" Condition="$(UpdateAssemblyInfo) == 'true'">
4049
<UpdateAssemblyInfo
41-
SolutionDirectory="$(SolutionDir)"
50+
SolutionDirectory="$(GitVersionPath)"
4251
NoFetch="$(GitVersion_NoFetchEnabled)"
4352
ProjectFile="$(MSBuildProjectFullPath)"
4453
IntermediateOutputPath="$(IntermediateOutputPath)"
@@ -56,7 +65,7 @@
5665

5766
<Target Name="GetVersion" BeforeTargets="CoreCompile;GetAssemblyVersion;GenerateNuspec" Condition="$(GetVersion) == 'true'">
5867

59-
<GetVersion SolutionDirectory="$(SolutionDir)" NoFetch="$(GitVersion_NoFetchEnabled)">
68+
<GetVersion SolutionDirectory="$(GitVersionPath)" NoFetch="$(GitVersion_NoFetchEnabled)">
6069
<Output TaskParameter="Major" PropertyName="GitVersion_Major" />
6170
<Output TaskParameter="Minor" PropertyName="GitVersion_Minor" />
6271
<Output TaskParameter="Patch" PropertyName="GitVersion_Patch" />

src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<GitVersion_Task_targets_Imported>True</GitVersion_Task_targets_Imported>
5+
</PropertyGroup>
36
<PropertyGroup>
47
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
8+
<GitVersionPath Condition="'$(GitVersionPath)' == '' And '$(GitVersionUseSolutionDir)' == 'true'">$(SolutionDir)</GitVersionPath>
9+
<GitVersionPath Condition="'$(GitVersionPath)' == ''">$(MSBuildProjectDirectory)</GitVersionPath>
10+
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == '' And Exists('$(MSBuildProjectDirectory)\GitVersionTask.targets')">$(SolutionDir)\GitVersionTask.targets</GitVersionCustomizeTargetFile>
11+
<GitVersionCustomizeTargetFile Condition="'$(GitVersionCustomizeTargetFile)' == '' And '$(SolutionDir)' != '' And Exists('$(SolutionDir)\GitVersionTask.targets')">$(SolutionDir)\GitVersionTask.targets</GitVersionCustomizeTargetFile>
512
<GitVersion_NoFetchEnabled Condition="$(GitVersion_NoFetchEnabled) == ''">false</GitVersion_NoFetchEnabled>
613

714
<!-- Property that enables WriteVersionInfoToBuildLog -->
@@ -30,13 +37,15 @@
3037
TaskName="GitVersionTask.WriteVersionInfoToBuildLog"
3138
AssemblyFile="$(GitVersionTaskLibrary)GitVersionTask.dll" />
3239

40+
<Import Project="$(GitVersionCustomizeTargetFile)" Condition="'$(GitVersionCustomizeTargetFile)' != '' and Exists($(GitVersionCustomizeTargetFile))" />
41+
3342
<Target Name="WriteVersionInfoToBuildLog" BeforeTargets="DispatchToInnerBuilds;GenerateNuspec" Condition="$(WriteVersionInfoToBuildLog) == 'true'">
34-
<WriteVersionInfoToBuildLog SolutionDirectory="$(SolutionDir)" NoFetch="$(GitVersion_NoFetchEnabled)"/>
43+
<WriteVersionInfoToBuildLog SolutionDirectory="$(GitVersionPath)" NoFetch="$(GitVersion_NoFetchEnabled)"/>
3544
</Target>
3645

3746
<Target Name="GetVersion" BeforeTargets="DispatchToInnerBuilds;GenerateNuspec" Condition="$(GetVersion) == 'true'">
3847

39-
<GetVersion SolutionDirectory="$(SolutionDir)" NoFetch="$(GitVersion_NoFetchEnabled)">
48+
<GetVersion SolutionDirectory="$(GitVersionPath)" NoFetch="$(GitVersion_NoFetchEnabled)">
4049
<Output TaskParameter="Major" PropertyName="GitVersion_Major" />
4150
<Output TaskParameter="Minor" PropertyName="GitVersion_Minor" />
4251
<Output TaskParameter="Patch" PropertyName="GitVersion_Patch" />

0 commit comments

Comments
 (0)