diff --git a/src/GitVersion.Core/Core/GitPreparer.cs b/src/GitVersion.Core/Core/GitPreparer.cs index d6ee46e276..9e16df1438 100644 --- a/src/GitVersion.Core/Core/GitPreparer.cs +++ b/src/GitVersion.Core/Core/GitPreparer.cs @@ -3,6 +3,7 @@ using System.Linq; using GitVersion.Common; using GitVersion.Extensions; +using GitVersion.Helpers; using GitVersion.Logging; using GitVersion.Model.Configuration; using Microsoft.Extensions.Options; @@ -148,7 +149,10 @@ private void CloneRepository(string repositoryUrl, string gitDirectory, Authenti { using (log.IndentLog($"Cloning repository from url '{repositoryUrl}'")) { - repository.Clone(repositoryUrl, gitDirectory, auth); + new OperationWithExponentialBackoff(new ThreadSleep(), log, () => + { + repository.Clone(repositoryUrl, gitDirectory, auth); + }).ExecuteAsync().Wait(); } } @@ -178,7 +182,9 @@ private void NormalizeGitDirectory(bool noFetch, string currentBranchName, bool { var refSpecs = string.Join(", ", remote.FetchRefSpecs.Select(r => r.Specification)); log.Info($"Fetching from remote '{remote.Name}' using the following refspecs: {refSpecs}."); - repository.Fetch(remote.Name, Enumerable.Empty(), authentication, null); + new OperationWithExponentialBackoff(new ThreadSleep(), log, + () => repository.Fetch(remote.Name, Enumerable.Empty(), authentication, null)) + .ExecuteAsync().Wait(); } EnsureLocalBranchExistsForCurrentBranch(remote, currentBranchName); @@ -220,7 +226,7 @@ private void NormalizeGitDirectory(bool noFetch, string currentBranchName, bool if (matchingCurrentBranch != null) { log.Info($"Checking out local branch '{currentBranchName}'."); - repository.Checkout(matchingCurrentBranch.Name.Canonical); + Checkout(matchingCurrentBranch.Name.Canonical); } else if (localBranchesWhereCommitShaIsHead.Count > 1) { @@ -233,7 +239,7 @@ private void NormalizeGitDirectory(bool noFetch, string currentBranchName, bool if (main != null) { log.Warning("Because one of the branches is 'main', will build main." + moveBranchMsg); - repository.Checkout(Config.MainBranchKey); + Checkout(Config.MainBranchKey); } else { @@ -242,7 +248,7 @@ private void NormalizeGitDirectory(bool noFetch, string currentBranchName, bool { var branchWithoutSeparator = branchesWithoutSeparators[0]; log.Warning($"Choosing {branchWithoutSeparator.Name.Canonical} as it is the only branch without / or - in it. " + moveBranchMsg); - repository.Checkout(branchWithoutSeparator.Name.Canonical); + Checkout(branchWithoutSeparator.Name.Canonical); } else { @@ -253,12 +259,15 @@ private void NormalizeGitDirectory(bool noFetch, string currentBranchName, bool else if (localBranchesWhereCommitShaIsHead.Count == 0) { log.Info($"No local branch pointing at the commit '{headSha}'. Fake branch needs to be created."); - repository.CreateBranchForPullRequestBranch(authentication); + new OperationWithExponentialBackoff(new ThreadSleep(), log, () => + { + repository.CreateBranchForPullRequestBranch(authentication); + }).ExecuteAsync().Wait(); } else { log.Info($"Checking out local branch 'refs/heads/{localBranchesWhereCommitShaIsHead[0]}'."); - repository.Checkout(localBranchesWhereCommitShaIsHead[0].Name.Friendly); + Checkout(localBranchesWhereCommitShaIsHead[0].Name.Friendly); } } finally @@ -329,7 +338,7 @@ private void CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(string remoteName } var remoteRefTipId = remoteTrackingReference.ReferenceTargetId; log.Info($"Updating local ref '{localRef.Name.Canonical}' to point at {remoteRefTipId}."); - repository.Refs.UpdateTarget(localRef, remoteRefTipId); + new OperationWithExponentialBackoff(new ThreadSleep(), log, () => repository.Refs.UpdateTarget(localRef, remoteRefTipId)).ExecuteAsync().Wait(); continue; } @@ -382,10 +391,16 @@ public void EnsureLocalBranchExistsForCurrentBranch(IRemote remote, string curre log.Info(isBranch ? $"Updating local branch {referenceName} to point at {repoTip}" : $"Updating local branch {referenceName} to match ref {currentBranch}"); var localRef = repository.Refs[localCanonicalName]; - repository.Refs.UpdateTarget(localRef, repoTipId); + new OperationWithExponentialBackoff(new ThreadSleep(), log, () => repository.Refs.UpdateTarget(localRef, repoTipId)).ExecuteAsync().Wait(); } - repository.Checkout(localCanonicalName); + Checkout(localCanonicalName); + } + + private void Checkout(string commitOrBranchSpec) + { + new OperationWithExponentialBackoff(new ThreadSleep(), log, () => + repository.Checkout(commitOrBranchSpec)).ExecuteAsync().Wait(); } } } diff --git a/src/GitVersion.Core/Core/ThreadSleep.cs b/src/GitVersion.Core/Core/ThreadSleep.cs index b2f7e68bce..db3c4809e4 100644 --- a/src/GitVersion.Core/Core/ThreadSleep.cs +++ b/src/GitVersion.Core/Core/ThreadSleep.cs @@ -2,7 +2,7 @@ namespace GitVersion { - internal class ThreadSleep : IThreadSleep + public class ThreadSleep : IThreadSleep { public async Task SleepAsync(int milliseconds) { diff --git a/src/GitVersion.Core/Git/IReferenceCollection.cs b/src/GitVersion.Core/Git/IReferenceCollection.cs index 8a60b4e191..0a0a15a306 100644 --- a/src/GitVersion.Core/Git/IReferenceCollection.cs +++ b/src/GitVersion.Core/Git/IReferenceCollection.cs @@ -10,4 +10,5 @@ public interface IReferenceCollection : IEnumerable void UpdateTarget(IReference directRef, IObjectId targetId); IEnumerable FromGlob(string prefix); } + } diff --git a/src/GitVersion.Core/Helpers/OperationWithExponentialBackoff.cs b/src/GitVersion.Core/Helpers/OperationWithExponentialBackoff.cs index 365e9028b0..e8e50e5e11 100644 --- a/src/GitVersion.Core/Helpers/OperationWithExponentialBackoff.cs +++ b/src/GitVersion.Core/Helpers/OperationWithExponentialBackoff.cs @@ -5,25 +5,37 @@ namespace GitVersion.Helpers { - internal class OperationWithExponentialBackoff where T : Exception + public class OperationWithExponentialBackoff : OperationWithExponentialBackoff where T : Exception + { + public OperationWithExponentialBackoff(IThreadSleep threadSleep, ILog log, Action operation, int maxRetries = 5) + : base(threadSleep, log, () => { operation(); return false; }, maxRetries) + { + } + + public new Task ExecuteAsync() + { + return base.ExecuteAsync(); + } + } + public class OperationWithExponentialBackoff where T : Exception { private readonly IThreadSleep threadSleep; private readonly ILog log; - private readonly Action operation; + private readonly Func operation; private readonly int maxRetries; - public OperationWithExponentialBackoff(IThreadSleep threadSleep, ILog log, Action operation, int maxRetries = 5) + public OperationWithExponentialBackoff(IThreadSleep threadSleep, ILog log, Func operation, int maxRetries = 5) { if (maxRetries < 0) throw new ArgumentOutOfRangeException(nameof(maxRetries)); this.threadSleep = threadSleep ?? throw new ArgumentNullException(nameof(threadSleep)); - this.log = log; + this.log = log ?? throw new ArgumentNullException(nameof(log)); this.operation = operation; this.maxRetries = maxRetries; } - public async Task ExecuteAsync() + public async Task ExecuteAsync() { var exceptions = new List(); @@ -36,8 +48,7 @@ public async Task ExecuteAsync() try { - operation(); - break; + return operation(); } catch (T e) { @@ -53,6 +64,7 @@ public async Task ExecuteAsync() sleepMSec *= 2; } + return default; } } } diff --git a/src/GitVersion.Core/Model/Exceptions/LockedFileException.cs b/src/GitVersion.Core/Model/Exceptions/LockedFileException.cs new file mode 100644 index 0000000000..f53226812e --- /dev/null +++ b/src/GitVersion.Core/Model/Exceptions/LockedFileException.cs @@ -0,0 +1,11 @@ +using System; + +namespace GitVersion +{ + public class LockedFileException : Exception + { + public LockedFileException(Exception inner) : base(inner.Message, inner) + { + } + } +} diff --git a/src/GitVersion.Core/Model/VersionVariables.cs b/src/GitVersion.Core/Model/VersionVariables.cs index 29e4fda19d..18b257b38f 100644 --- a/src/GitVersion.Core/Model/VersionVariables.cs +++ b/src/GitVersion.Core/Model/VersionVariables.cs @@ -1,3 +1,5 @@ +using GitVersion.Helpers; +using GitVersion.Logging; using System; using System.Collections; using System.Collections.Generic; @@ -164,7 +166,29 @@ public static VersionVariables FromJson(string json) return FromDictionary(variablePairs); } - public static VersionVariables FromFile(string filePath, IFileSystem fileSystem) + public static VersionVariables FromFile(string filePath, IFileSystem fileSystem, ILog log) + { + try + { + if (log == null) + { + return FromFileInternal(filePath, fileSystem); + } + var retryOperation = new OperationWithExponentialBackoff(new ThreadSleep(), log, () => FromFileInternal(filePath, fileSystem)); + var versionVariables = retryOperation.ExecuteAsync().Result; + return versionVariables; + } + catch (AggregateException ex) + { + var lastException = ex.InnerExceptions?.LastOrDefault() ?? ex.InnerException; + if (lastException != null) + { + throw lastException; + } + throw; + } + } + private static VersionVariables FromFileInternal(string filePath, IFileSystem fileSystem) { using var stream = fileSystem.OpenRead(filePath); using var reader = new StreamReader(stream); diff --git a/src/GitVersion.Core/VersionCalculation/Cache/GitVersionCache.cs b/src/GitVersion.Core/VersionCalculation/Cache/GitVersionCache.cs index 2e53231a21..36cd01b68f 100644 --- a/src/GitVersion.Core/VersionCalculation/Cache/GitVersionCache.cs +++ b/src/GitVersion.Core/VersionCalculation/Cache/GitVersionCache.cs @@ -74,7 +74,7 @@ public VersionVariables LoadVersionVariablesFromDiskCache(GitVersionCacheKey key { try { - var loadedVariables = VersionVariables.FromFile(cacheFileName, fileSystem); + var loadedVariables = VersionVariables.FromFile(cacheFileName, fileSystem, log); return loadedVariables; } catch (Exception ex) diff --git a/src/GitVersion.Core/VersionConverters/OutputGenerator/OutputGenerator.cs b/src/GitVersion.Core/VersionConverters/OutputGenerator/OutputGenerator.cs index 312424f6a7..be9090d676 100644 --- a/src/GitVersion.Core/VersionConverters/OutputGenerator/OutputGenerator.cs +++ b/src/GitVersion.Core/VersionConverters/OutputGenerator/OutputGenerator.cs @@ -1,4 +1,6 @@ using System; +using System.IO; +using GitVersion.Helpers; using GitVersion.Logging; using GitVersion.Model; using GitVersion.OutputVariables; @@ -13,13 +15,15 @@ public interface IOutputGenerator : IVersionConverter public class OutputGenerator : IOutputGenerator { private readonly IConsole console; + private readonly ILog log; private readonly IFileSystem fileSystem; private readonly IOptions options; private readonly ICurrentBuildAgent buildAgent; - public OutputGenerator(ICurrentBuildAgent buildAgent, IConsole console, IFileSystem fileSystem, IOptions options) + public OutputGenerator(ICurrentBuildAgent buildAgent, IConsole console, ILog log, IFileSystem fileSystem, IOptions options) { this.console = console ?? throw new ArgumentNullException(nameof(console)); + this.log = log ?? throw new ArgumentNullException(nameof(log)); this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); this.options = options ?? throw new ArgumentNullException(nameof(options)); this.buildAgent = buildAgent; @@ -34,7 +38,8 @@ public void Execute(VersionVariables variables, OutputContext context) } if (gitVersionOptions.Output.Contains(OutputType.File)) { - fileSystem.WriteAllText(context.OutputFile, variables.ToString()); + var retryOperation = new OperationWithExponentialBackoff(new ThreadSleep(), log, () => fileSystem.WriteAllText(context.OutputFile, variables.ToString())); + retryOperation.ExecuteAsync().Wait(); } if (gitVersionOptions.Output.Contains(OutputType.Json)) { diff --git a/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs b/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs index 56dc68981d..95eb657ee6 100644 --- a/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs +++ b/src/GitVersion.LibGit2Sharp/Git/GitRepository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using GitVersion.Helpers; using GitVersion.Logging; using LibGit2Sharp; using LibGit2Sharp.Handlers; @@ -53,10 +54,20 @@ public void Dispose() public ICommit FindMergeBase(ICommit commit, ICommit otherCommit) { - var mergeBase = repositoryInstance.ObjectDatabase.FindMergeBase((Commit)commit, (Commit)otherCommit); - return new Commit(mergeBase); + return new OperationWithExponentialBackoff(new ThreadSleep(), log, () => + { + var mergeBase = repositoryInstance.ObjectDatabase.FindMergeBase((Commit)commit, (Commit)otherCommit); + return new Commit(mergeBase); + }).ExecuteAsync().Result; } public int GetNumberOfUncommittedChanges() + { + return new OperationWithExponentialBackoff(new ThreadSleep(), log, () => + { + return GetNumberOfUncommittedChangesInternal(); + }).ExecuteAsync().Result; + } + private int GetNumberOfUncommittedChangesInternal() { // check if we have a branch tip at all to behave properly with empty repos // => return that we have actually uncomitted changes because we are apparently @@ -87,60 +98,63 @@ public int GetNumberOfUncommittedChanges() } public void CreateBranchForPullRequestBranch(AuthenticationInfo auth) { - var network = repositoryInstance.Network; - var remote = network.Remotes.Single(); + RepositoryExtensions.RunSafe(() => + { + var network = repositoryInstance.Network; + var remote = network.Remotes.Single(); - log.Info("Fetching remote refs to see if there is a pull request ref"); - var credentialsProvider = GetCredentialsProvider(auth); - var remoteTips = (credentialsProvider != null - ? network.ListReferences(remote, credentialsProvider) - : network.ListReferences(remote)) - .Select(r => r.ResolveToDirectReference()).ToList(); + log.Info("Fetching remote refs to see if there is a pull request ref"); + var credentialsProvider = GetCredentialsProvider(auth); + var remoteTips = (credentialsProvider != null + ? network.ListReferences(remote, credentialsProvider) + : network.ListReferences(remote)) + .Select(r => r.ResolveToDirectReference()).ToList(); - log.Info($"Remote Refs:{System.Environment.NewLine}" + string.Join(System.Environment.NewLine, remoteTips.Select(r => r.CanonicalName))); + log.Info($"Remote Refs:{System.Environment.NewLine}" + string.Join(System.Environment.NewLine, remoteTips.Select(r => r.CanonicalName))); - var headTipSha = Head.Tip?.Sha; + var headTipSha = Head.Tip?.Sha; - var refs = remoteTips.Where(r => r.TargetIdentifier == headTipSha).ToList(); + var refs = remoteTips.Where(r => r.TargetIdentifier == headTipSha).ToList(); - if (refs.Count == 0) - { - var message = $"Couldn't find any remote tips from remote '{remote.Url}' pointing at the commit '{headTipSha}'."; - throw new WarningException(message); - } + if (refs.Count == 0) + { + var message = $"Couldn't find any remote tips from remote '{remote.Url}' pointing at the commit '{headTipSha}'."; + throw new WarningException(message); + } - if (refs.Count > 1) - { - var names = string.Join(", ", refs.Select(r => r.CanonicalName)); - var message = $"Found more than one remote tip from remote '{remote.Url}' pointing at the commit '{headTipSha}'. Unable to determine which one to use ({names})."; - throw new WarningException(message); - } + if (refs.Count > 1) + { + var names = string.Join(", ", refs.Select(r => r.CanonicalName)); + var message = $"Found more than one remote tip from remote '{remote.Url}' pointing at the commit '{headTipSha}'. Unable to determine which one to use ({names})."; + throw new WarningException(message); + } - var reference = refs.First(); - var canonicalName = reference.CanonicalName; - var referenceName = ReferenceName.Parse(reference.CanonicalName); - log.Info($"Found remote tip '{canonicalName}' pointing at the commit '{headTipSha}'."); + var reference = refs.First(); + var canonicalName = reference.CanonicalName; + var referenceName = ReferenceName.Parse(reference.CanonicalName); + log.Info($"Found remote tip '{canonicalName}' pointing at the commit '{headTipSha}'."); - if (referenceName.IsTag) - { - log.Info($"Checking out tag '{canonicalName}'"); - Checkout(reference.Target.Sha); - } - else if (referenceName.IsPullRequest) - { - var fakeBranchName = canonicalName.Replace("refs/pull/", "refs/heads/pull/").Replace("refs/pull-requests/", "refs/heads/pull-requests/"); + if (referenceName.IsTag) + { + log.Info($"Checking out tag '{canonicalName}'"); + Checkout(reference.Target.Sha); + } + else if (referenceName.IsPullRequest) + { + var fakeBranchName = canonicalName.Replace("refs/pull/", "refs/heads/pull/").Replace("refs/pull-requests/", "refs/heads/pull-requests/"); - log.Info($"Creating fake local branch '{fakeBranchName}'."); - Refs.Add(fakeBranchName, headTipSha); + log.Info($"Creating fake local branch '{fakeBranchName}'."); + Refs.Add(fakeBranchName, headTipSha); - log.Info($"Checking local branch '{fakeBranchName}' out."); - Checkout(fakeBranchName); - } - else - { - var message = $"Remote tip '{canonicalName}' from remote '{remote.Url}' doesn't look like a valid pull request."; - throw new WarningException(message); - } + log.Info($"Checking local branch '{fakeBranchName}' out."); + Checkout(fakeBranchName); + } + else + { + var message = $"Remote tip '{canonicalName}' from remote '{remote.Url}' doesn't look like a valid pull request."; + throw new WarningException(message); + } + }); } public void Clone(string sourceUrl, string workdirPath, AuthenticationInfo auth) { @@ -149,6 +163,10 @@ public void Clone(string sourceUrl, string workdirPath, AuthenticationInfo auth) var path = Repository.Clone(sourceUrl, workdirPath, GetCloneOptions(auth)); log.Info($"Returned path after repository clone: {path}"); } + catch (LibGit2Sharp.LockedFileException ex) + { + throw new LockedFileException(ex); + } catch (LibGit2SharpException ex) { var message = ex.Message; @@ -168,9 +186,20 @@ public void Clone(string sourceUrl, string workdirPath, AuthenticationInfo auth) throw new Exception("There was an unknown problem with the Git repository you provided", ex); } } - public void Checkout(string commitOrBranchSpec) => Commands.Checkout(repositoryInstance, commitOrBranchSpec); - public void Fetch(string remote, IEnumerable refSpecs, AuthenticationInfo auth, string logMessage) => - Commands.Fetch((Repository)repositoryInstance, remote, refSpecs, GetFetchOptions(auth), logMessage); + public void Checkout(string commitOrBranchSpec) + { + RepositoryExtensions.RunSafe(() => + { + Commands.Checkout(repositoryInstance, commitOrBranchSpec); + }); + } + public void Fetch(string remote, IEnumerable refSpecs, AuthenticationInfo auth, string logMessage) + { + RepositoryExtensions.RunSafe(() => + { + Commands.Fetch((Repository)repositoryInstance, remote, refSpecs, GetFetchOptions(auth), logMessage); + }); + } internal static string Discover(string path) => Repository.Discover(path); private static FetchOptions GetFetchOptions(AuthenticationInfo auth) diff --git a/src/GitVersion.LibGit2Sharp/Git/ReferenceCollection.cs b/src/GitVersion.LibGit2Sharp/Git/ReferenceCollection.cs index 5fede01e50..ba03760e91 100644 --- a/src/GitVersion.LibGit2Sharp/Git/ReferenceCollection.cs +++ b/src/GitVersion.LibGit2Sharp/Git/ReferenceCollection.cs @@ -21,7 +21,10 @@ public void Add(string name, string canonicalRefNameOrObjectish, bool allowOverw public void UpdateTarget(IReference directRef, IObjectId targetId) { - innerCollection.UpdateTarget((Reference)directRef, (ObjectId)targetId); + RepositoryExtensions.RunSafe(() => + { + innerCollection.UpdateTarget((Reference)directRef, (ObjectId)targetId); + }); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/src/GitVersion.LibGit2Sharp/RepositoryExtensions.cs b/src/GitVersion.LibGit2Sharp/RepositoryExtensions.cs index c4f25e845b..790139a5c6 100644 --- a/src/GitVersion.LibGit2Sharp/RepositoryExtensions.cs +++ b/src/GitVersion.LibGit2Sharp/RepositoryExtensions.cs @@ -1,3 +1,4 @@ +using System; using LibGit2Sharp; using Microsoft.Extensions.Options; @@ -7,5 +8,31 @@ public static class RepositoryExtensions { public static IGitRepository ToGitRepository(this IRepository repository) => new GitRepository(repository); public static IGitRepositoryInfo ToGitRepositoryInfo(IOptions options) => new GitRepositoryInfo(options); + + public static void RunSafe(Action operation) + { + try + { + operation(); + } + catch (LibGit2Sharp.LockedFileException ex) + { + // Wrap this exception so that callers that want to catch it don't need to take a dependency on LibGit2Sharp. + throw new LockedFileException(ex); + } + } + + public static T RunSafe(Func operation) + { + try + { + return operation(); + } + catch (LibGit2Sharp.LockedFileException ex) + { + // Wrap this exception so that callers that want to catch it don't need to take a dependency on LibGit2Sharp. + throw new LockedFileException(ex); + } + } } } diff --git a/src/GitVersion.MsBuild/GitVersionTaskExecutor.cs b/src/GitVersion.MsBuild/GitVersionTaskExecutor.cs index f49b275b58..13472af54c 100644 --- a/src/GitVersion.MsBuild/GitVersionTaskExecutor.cs +++ b/src/GitVersion.MsBuild/GitVersionTaskExecutor.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using GitVersion.Logging; using GitVersion.MsBuild.Tasks; using GitVersion.OutputVariables; using Microsoft.Extensions.Options; @@ -9,20 +10,22 @@ namespace GitVersion.MsBuild public class GitVersionTaskExecutor : IGitVersionTaskExecutor { private readonly IFileSystem fileSystem; + private readonly ILog log; private readonly IGitVersionOutputTool gitVersionOutputTool; private readonly IOptions options; private VersionVariables versionVariables; - public GitVersionTaskExecutor(IFileSystem fileSystem, IGitVersionOutputTool gitVersionOutputTool, IOptions options) + public GitVersionTaskExecutor(IFileSystem fileSystem, IGitVersionOutputTool gitVersionOutputTool, IOptions options, ILog log) { this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); + this.log = log ?? throw new ArgumentNullException(nameof(log)); this.gitVersionOutputTool = gitVersionOutputTool ?? throw new ArgumentNullException(nameof(gitVersionOutputTool)); this.options = options ?? throw new ArgumentNullException(nameof(options)); } public void GetVersion(GetVersion task) { - versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem); + versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem, log); var outputType = typeof(GetVersion); foreach (var variable in versionVariables) { @@ -32,7 +35,7 @@ public void GetVersion(GetVersion task) public void UpdateAssemblyInfo(UpdateAssemblyInfo task) { - versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem); + versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem, log); FileHelper.DeleteTempFiles(); if (task.CompileFiles != null) FileHelper.CheckForInvalidFiles(task.CompileFiles, task.ProjectFile); @@ -50,7 +53,7 @@ public void UpdateAssemblyInfo(UpdateAssemblyInfo task) public void GenerateGitVersionInformation(GenerateGitVersionInformation task) { - versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem); + versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem, log); var fileWriteInfo = task.IntermediateOutputPath.GetFileWriteInfo(task.Language, task.ProjectFile, "GitVersionInformation"); task.GitVersionInformationFilePath = Path.Combine(fileWriteInfo.WorkingDirectory, fileWriteInfo.FileName); @@ -62,7 +65,7 @@ public void GenerateGitVersionInformation(GenerateGitVersionInformation task) public void WriteVersionInfoToBuildLog(WriteVersionInfoToBuildLog task) { - versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem); + versionVariables = VersionVariables.FromFile(task.VersionFile, fileSystem, log); gitVersionOutputTool.OutputVariables(versionVariables, false); } } diff --git a/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets b/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets index fa9b1db2d0..ce188f1c95 100644 --- a/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets +++ b/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets @@ -72,7 +72,7 @@ GitVersion_PreReleaseTag=$(GitVersion_PreReleaseTag);$(DefineConstants) GitVersion_PreReleaseTagWithDash=$(GitVersion_PreReleaseTagWithDash);$(DefineConstants) GitVersion_PreReleaseLabel=$(GitVersion_PreReleaseLabel);$(DefineConstants) - GitVersion_PreReleaseLabelWithDash=$(GitVersion_PreReleaseLabelWithDash);$(DefineConstants) + GitVersion_PreReleaseLabelWithDash=$(GitVersion_PreReleaseLabeWithDashl);$(DefineConstants) GitVersion_PreReleaseNumber=$(GitVersion_PreReleaseNumber);$(DefineConstants) GitVersion_WeightedPreReleaseNumber=$(GitVersion_WeightedPreReleaseNumber);$(DefineConstants) GitVersion_BuildMetaData=$(GitVersion_BuildMetaData);$(DefineConstants)