File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . IO ;
3
3
using System . Reflection ;
4
+ using System . Threading ;
4
5
using GitVersion . Configuration ;
5
6
using GitVersion . Extensions ;
6
7
using GitVersion . Logging ;
@@ -56,8 +57,16 @@ public int Execute(GitVersionOptions gitVersionOptions)
56
57
57
58
private int RunGitVersionTool ( GitVersionOptions gitVersionOptions )
58
59
{
60
+ var mutexName = gitVersionOptions . WorkingDirectory . Replace ( "\\ " , "" ) ;
61
+ using var mutex = new Mutex ( true , $@ "Global\{ mutexName } ", out var acquired ) ;
62
+
59
63
try
60
64
{
65
+ if ( ! acquired )
66
+ {
67
+ mutex . WaitOne ( ) ;
68
+ }
69
+
61
70
var variables = gitVersionCalculateTool . CalculateVersionVariables ( ) ;
62
71
63
72
var configuration = configProvider . Provide ( overrideConfig : gitVersionOptions . ConfigInfo . OverrideConfig ) ;
@@ -92,6 +101,10 @@ private int RunGitVersionTool(GitVersionOptions gitVersionOptions)
92
101
}
93
102
return 1 ;
94
103
}
104
+ finally
105
+ {
106
+ mutex . ReleaseMutex ( ) ;
107
+ }
95
108
96
109
return 0 ;
97
110
}
You can’t perform that action at this time.
0 commit comments