From 120d8b6537fda97d3e3ba57b9a12d38e2c76213c Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 29 Jul 2017 21:31:15 +0100 Subject: [PATCH 01/79] #1175 - First pass at GitVersionCore on netstadard - wip. Haven't been able to resolve some compilation errors yet due to lack of replacemnt API's on netstandard. --- src/GitVersion.sln | 5 +- src/GitVersionCore/BuildServers/AppVeyor.cs | 111 +++++++- .../BuildServers/BuildServerList.cs | 2 + src/GitVersionCore/BuildServers/ContinuaCi.cs | 4 + src/GitVersionCore/BuildServers/MyGet.cs | 4 +- src/GitVersionCore/Configuration/Config.cs | 1 + .../Configuration/ConfigurationProvider.cs | 2 +- .../Configuration/LegacyConfig.cs | 5 +- .../OldConfigurationException.cs | 2 + .../Configuration/TypeHelper.cs | 30 +++ src/GitVersionCore/ExecuteCore.cs | 1 + .../ReadEmbeddedResourceExtensions.cs | 5 + src/GitVersionCore/GitVersionCore.csproj | 255 ++++++------------ src/GitVersionCore/GitVersionFinder.cs | 6 +- src/GitVersionCore/Helpers/EncodingHelper.cs | 1 + src/GitVersionCore/Helpers/FileSystem.cs | 4 +- src/GitVersionCore/Helpers/ThreadSleep.cs | 1 + .../OutputVariables/VariableProvider.cs | 2 +- .../OutputVariables/VersionVariables.cs | 26 +- src/GitVersionCore/SearchPath.cs | 12 +- src/GitVersionCore/SemanticVersion.cs | 1 + .../SemanticVersionPreReleaseTag.cs | 16 +- src/GitVersionCore/StringComparerUtils.cs | 19 ++ src/GitVersionCore/StringFormatWith.cs | 14 +- .../AssemblyVersionInfoTemplates.cs | 10 +- .../VersionAssemblyInfo.cs | 6 +- src/NuGet.config | 7 + 27 files changed, 341 insertions(+), 211 deletions(-) create mode 100644 src/GitVersionCore/Configuration/TypeHelper.cs create mode 100644 src/GitVersionCore/StringComparerUtils.cs create mode 100644 src/NuGet.config diff --git a/src/GitVersion.sln b/src/GitVersion.sln index 6af6252047..2b9eb623dc 100644 --- a/src/GitVersion.sln +++ b/src/GitVersion.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionExe", "GitVersionExe\GitVersionExe.csproj", "{C3578A7B-09A6-4444-9383-0DEAFA4958BD}" EndProject @@ -26,6 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\GitVersion.yml = ..\GitVersion.yml ..\LICENSE = ..\LICENSE ..\mkdocs.yml = ..\mkdocs.yml + NuGet.config = NuGet.config ..\README.md = ..\README.md EndProjectSection EndProject diff --git a/src/GitVersionCore/BuildServers/AppVeyor.cs b/src/GitVersionCore/BuildServers/AppVeyor.cs index 619f6d81e2..2363e4fb63 100644 --- a/src/GitVersionCore/BuildServers/AppVeyor.cs +++ b/src/GitVersionCore/BuildServers/AppVeyor.cs @@ -3,6 +3,13 @@ using System; using System.Net; using System.Text; +#if !NETDESKTOP + using System.Net.Http; + using System.Threading.Tasks; + using System.Net.Http.Headers; + using Newtonsoft.Json; + using System.IO; +#endif public class AppVeyor : BuildServerBase { @@ -13,6 +20,97 @@ public override bool CanApplyToCurrentContext() return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(EnvironmentVariableName)); } +#if !NETDESKTOP + + + public override string GenerateSetVersionMessage(VersionVariables variables) + { + + var buildNumber = Environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER"); + var restBase = Environment.GetEnvironmentVariable("APPVEYOR_API_URL"); + + var request = (HttpWebRequest)WebRequest.Create(restBase + "api/build"); + request.Method = "PUT"; + + + var data = string.Format("{{ \"version\": \"{0}.build.{1}\" }}", variables.FullSemVer, buildNumber); + var bytes = Encoding.UTF8.GetBytes(data); + if (request.Headers == null) + { + request.Headers = new WebHeaderCollection(); + } + var bytesLength = bytes.Length; + request.Headers["Content-Length"] = bytesLength.ToString(); + + // request.ContentLength = bytes.Length; + request.ContentType = "application/json"; + + using (var writeStream = request.GetRequestStreamAsync().Result) + { + writeStream.Write(bytes, 0, bytes.Length); + } + + //var result = request.BeginGetRequestStream((asyncResult) => + // { + // using (var writeStream = request.EndGetRequestStream(asyncResult)) + // { + // writeStream.Write(bytes, 0, bytes.Length); + // } + + // }, null); + + // result.AsyncWaitHandle.WaitOne(new TimeSpan(0, 3, 0)); + + using (var response = (HttpWebResponse)request.GetResponseAsync().Result) + { + if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.NoContent) + { + var message = string.Format("Request failed. Received HTTP {0}", response.StatusCode); + return message; + } + } + + return string.Format("Set AppVeyor build number to '{0}'.", variables.FullSemVer); + + } + + + public override string[] GenerateSetParameterMessage(string name, string value) + { + + // var buildNumber = Environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER"); + var restBase = Environment.GetEnvironmentVariable("APPVEYOR_API_URL"); + + var request = (HttpWebRequest)WebRequest.Create(restBase + "api/build/variables"); + request.Method = "POST"; + request.ContentType = "application/json"; + request.Accept = "application/json"; + + var data = string.Format("{{ \"name\": \"GitVersion_{0}\", \"value\": \"{1}\" }}", name, value); + var bytes = Encoding.UTF8.GetBytes(data); + if (request.Headers == null) + { + request.Headers = new WebHeaderCollection(); + } + var bytesLength = bytes.Length; + // No property for content-length - and no Add() method on header collection? WHAAAAT + // request.ContentLength = bytes.Length; + request.Headers["Content-Length"] = bytesLength.ToString(); + + using (var writeStream = request.GetRequestStreamAsync().Result) + { + writeStream.Write(bytes, 0, bytes.Length); + } + + return new[] + { + string.Format("Adding Environment Variable. name='GitVersion_{0}' value='{1}']", name, value) + }; + } + + +#else + public override string GenerateSetVersionMessage(VersionVariables variables) { var buildNumber = Environment.GetEnvironmentVariable("APPVEYOR_BUILD_NUMBER"); @@ -23,7 +121,14 @@ public override string GenerateSetVersionMessage(VersionVariables variables) var data = string.Format("{{ \"version\": \"{0}.build.{1}\" }}", variables.FullSemVer, buildNumber); var bytes = Encoding.UTF8.GetBytes(data); - request.ContentLength = bytes.Length; + if (request.Headers == null) + { + request.Headers = new WebHeaderCollection(); + } + var bytesLength = bytes.Length; + request.Headers["Content-Length"] = bytesLength.ToString(); + + // request.ContentLength = bytes.Length; request.ContentType = "application/json"; using (var writeStream = request.GetRequestStream()) @@ -60,5 +165,9 @@ public override string[] GenerateSetParameterMessage(string name, string value) string.Format("Adding Environment Variable. name='GitVersion_{0}' value='{1}']", name, value) }; } + + +#endif + } } \ No newline at end of file diff --git a/src/GitVersionCore/BuildServers/BuildServerList.cs b/src/GitVersionCore/BuildServers/BuildServerList.cs index dcd4f6f5a8..87751cbbf4 100644 --- a/src/GitVersionCore/BuildServers/BuildServerList.cs +++ b/src/GitVersionCore/BuildServers/BuildServerList.cs @@ -7,7 +7,9 @@ public static class BuildServerList { static List BuildServers = new List { +#if NETDESKTOP new ContinuaCi(), +#endif new TeamCity(), new AppVeyor(), new MyGet(), diff --git a/src/GitVersionCore/BuildServers/ContinuaCi.cs b/src/GitVersionCore/BuildServers/ContinuaCi.cs index c202b56271..557648acc8 100644 --- a/src/GitVersionCore/BuildServers/ContinuaCi.cs +++ b/src/GitVersionCore/BuildServers/ContinuaCi.cs @@ -1,5 +1,6 @@ namespace GitVersion { +#if NETDESKTOP using Microsoft.Win32; public class ContinuaCi : BuildServerBase @@ -42,4 +43,7 @@ static bool RegistryKeyExists(string keyName, RegistryView registryView) return localKey != null; } } + +#endif + } diff --git a/src/GitVersionCore/BuildServers/MyGet.cs b/src/GitVersionCore/BuildServers/MyGet.cs index 7f652ebc9e..fe7a6b9453 100644 --- a/src/GitVersionCore/BuildServers/MyGet.cs +++ b/src/GitVersionCore/BuildServers/MyGet.cs @@ -10,7 +10,7 @@ public override bool CanApplyToCurrentContext() var buildRunner = Environment.GetEnvironmentVariable("BuildRunner"); return !string.IsNullOrEmpty(buildRunner) - && buildRunner.Equals("MyGet", StringComparison.InvariantCultureIgnoreCase); + && buildRunner.Equals("MyGet", StringComparerUtils.IngoreCaseComparison); } public override string[] GenerateSetParameterMessage(string name, string value) @@ -20,7 +20,7 @@ public override string[] GenerateSetParameterMessage(string name, string value) string.Format("##myget[setParameter name='GitVersion.{0}' value='{1}']", name, ServiceMessageEscapeHelper.EscapeValue(value)) }; - if (string.Equals(name, "LegacySemVerPadded", StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(name, "LegacySemVerPadded", StringComparerUtils.IngoreCaseComparison)) { messages.Add(string.Format("##myget[buildNumber '{0}']", ServiceMessageEscapeHelper.EscapeValue(value))); } diff --git a/src/GitVersionCore/Configuration/Config.cs b/src/GitVersionCore/Configuration/Config.cs index a5d6dcecf8..47dc83fd89 100644 --- a/src/GitVersionCore/Configuration/Config.cs +++ b/src/GitVersionCore/Configuration/Config.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; + using System.Reflection; using System.Text.RegularExpressions; using YamlDotNet.Serialization; diff --git a/src/GitVersionCore/Configuration/ConfigurationProvider.cs b/src/GitVersionCore/Configuration/ConfigurationProvider.cs index 89eaa9474e..23bf52e182 100644 --- a/src/GitVersionCore/Configuration/ConfigurationProvider.cs +++ b/src/GitVersionCore/Configuration/ConfigurationProvider.cs @@ -6,7 +6,7 @@ namespace GitVersion using System.IO; using System.Linq; using System.Text; - using WarningException = System.ComponentModel.WarningException; + using WarningException = GitTools.WarningException; public class ConfigurationProvider { diff --git a/src/GitVersionCore/Configuration/LegacyConfig.cs b/src/GitVersionCore/Configuration/LegacyConfig.cs index 69d83a7a8f..abc46debd3 100644 --- a/src/GitVersionCore/Configuration/LegacyConfig.cs +++ b/src/GitVersionCore/Configuration/LegacyConfig.cs @@ -3,6 +3,7 @@ namespace GitVersion using System.Collections.Generic; using System.Linq; using YamlDotNet.Serialization; + using System.Reflection; /// /// Obsolete properties are added to this, so we can check to see if they are used and provide good error messages for migration @@ -42,7 +43,9 @@ public Dictionary Branches private T MergeObjects(T target, T source) { - typeof(T).GetProperties() + + var typeInfo = typeof(T); + typeInfo.GetProperties() .Where(prop => prop.CanRead && prop.CanWrite) .Select(_ => new { diff --git a/src/GitVersionCore/Configuration/OldConfigurationException.cs b/src/GitVersionCore/Configuration/OldConfigurationException.cs index 08603b4daf..fd230d679e 100644 --- a/src/GitVersionCore/Configuration/OldConfigurationException.cs +++ b/src/GitVersionCore/Configuration/OldConfigurationException.cs @@ -10,10 +10,12 @@ public OldConfigurationException(string message) : base(message) { } +#if NETDESKTOP protected OldConfigurationException( SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } } \ No newline at end of file diff --git a/src/GitVersionCore/Configuration/TypeHelper.cs b/src/GitVersionCore/Configuration/TypeHelper.cs new file mode 100644 index 0000000000..b94e68f8b0 --- /dev/null +++ b/src/GitVersionCore/Configuration/TypeHelper.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +//public static class TypeHelper +//{ +//#if NETDESKTOP +// public static Type GetType() +// { +// return GetType(); +// } +//#else +// public static TypeInfo GetType() +// { +// return GetType(); +// } +//#endif + +//#if NETDESKTOP +// public static IEnumerable GetConstructorsForType() +// { +// return GetType().GetConstructors(); +// } +//#else +// public static IEnumerable GetConstructorsForType() +// { +// return GetType().DeclaredConstructors; +// } +//#endif +//} diff --git a/src/GitVersionCore/ExecuteCore.cs b/src/GitVersionCore/ExecuteCore.cs index ddab02ea5a..225d21e260 100644 --- a/src/GitVersionCore/ExecuteCore.cs +++ b/src/GitVersionCore/ExecuteCore.cs @@ -1,5 +1,6 @@ namespace GitVersion { + using GitTools; using GitVersion.Helpers; using LibGit2Sharp; using System; diff --git a/src/GitVersionCore/Extensions/ReadEmbeddedResourceExtensions.cs b/src/GitVersionCore/Extensions/ReadEmbeddedResourceExtensions.cs index a57e7ef720..4f5ff14587 100644 --- a/src/GitVersionCore/Extensions/ReadEmbeddedResourceExtensions.cs +++ b/src/GitVersionCore/Extensions/ReadEmbeddedResourceExtensions.cs @@ -1,6 +1,7 @@ namespace GitVersionCore.Extensions { using System.IO; + using System.Reflection; public static class ReadEmbeddedResourceExtensions { @@ -23,7 +24,11 @@ public static string ReadAsStringFromEmbeddedResource(this string resourceNam public static Stream ReadFromEmbeddedResource(this string resourceName) { +#if NETDESKTOP var assembly = typeof(T).Assembly; +#else + var assembly = typeof(T).GetTypeInfo().Assembly; +#endif return assembly.GetManifestResourceStream(resourceName); } } diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index fea4f65af9..69ff279af9 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -1,181 +1,107 @@ - - - - + + - Debug - AnyCPU - {F9741A0D-B9D7-4557-9A1C-A7252C1071F5} + netstandard1.3;net40 Library - Properties GitVersion GitVersionCore - v4.0 - 6 - 512 $(SolutionDir)..\build\ - - + + GitVersion + GitVersion + GitTools and Contributors + https://github.com/GitTools/GitVersion + false + Git;Versioning;GitVersion;GitFlowVersion;GitFlow;GitHubFlow;SemVer + Derives SemVer information from a repository following GitFlow or GitHubFlow. + Copyright GitTools 2015. + http://www.opensource.org/licenses/mit-license.php + https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png + https://github.com/GitTools/GitVersion/releases + + $(Authors) + $(AssemblyName) + + + false + false + false + false + false + true - - true + + + + TRACE;NET40;NETDESKTOP + + + + TRACE;NETSTANDARD1_3; + + + full false bin\Debug\ DEBUG;TRACE - prompt - 4 bin\Debug\GitVersionCore.xml - 1591 - + + pdbonly true bin\Release\ TRACE - prompt - 4 bin\Release\GitVersionCore.xml - 1591 + - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net4\GitTools.Core.dll - True - - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True - + + + + + All + + + + + - - - ..\packages\YamlDotNet.3.8.0\lib\net35\YamlDotNet.dll - True - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Designer @@ -183,6 +109,7 @@ + @@ -190,35 +117,5 @@ - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/GitVersionCore/GitVersionFinder.cs b/src/GitVersionCore/GitVersionFinder.cs index 77addc07c1..4cf9d37170 100644 --- a/src/GitVersionCore/GitVersionFinder.cs +++ b/src/GitVersionCore/GitVersionFinder.cs @@ -1,8 +1,8 @@ namespace GitVersion { - using System.ComponentModel; using System.IO; using GitVersion.VersionCalculation; + using GitTools; public class GitVersionFinder { @@ -21,8 +21,8 @@ public SemanticVersion FindVersion(GitVersionContext context) var filePath = Path.Combine(context.Repository.GetRepositoryDirectory(), "NextVersion.txt"); if (File.Exists(filePath)) - { - throw new WarningException("NextVersion.txt has been deprecated. See http://gitversion.readthedocs.org/en/latest/configuration/ for replacement"); + { + throw new GitTools.WarningException("NextVersion.txt has been deprecated. See http://gitversion.readthedocs.org/en/latest/configuration/ for replacement"); } return new NextVersionCalculator().FindVersion(context); diff --git a/src/GitVersionCore/Helpers/EncodingHelper.cs b/src/GitVersionCore/Helpers/EncodingHelper.cs index 392f86e2ac..f16f0bec14 100644 --- a/src/GitVersionCore/Helpers/EncodingHelper.cs +++ b/src/GitVersionCore/Helpers/EncodingHelper.cs @@ -73,6 +73,7 @@ public static Encoding DetectEncoding(IList bytes) /// An ordered list of encodings and corresponding preambles. private static void ScanEncodings() { + // Might be out of luck finding a replacement for GetEncodings for netcore 1: https://stackoverflow.com/questions/44351507/what-is-net-core-equivalent-of-encoding-getencodings EncodingsWithPreambles = (from info in Encoding.GetEncodings() let encoding = info.GetEncoding() let preamble = encoding.GetPreamble() diff --git a/src/GitVersionCore/Helpers/FileSystem.cs b/src/GitVersionCore/Helpers/FileSystem.cs index f3022e816c..551ba0c0f8 100644 --- a/src/GitVersionCore/Helpers/FileSystem.cs +++ b/src/GitVersionCore/Helpers/FileSystem.cs @@ -86,8 +86,8 @@ public long GetLastDirectoryWrite(string path) public bool PathsEqual(string path, string otherPath) { var comparison = runningOnMono - ? StringComparison.InvariantCulture - : StringComparison.InvariantCultureIgnoreCase; + ? StringComparerUtils.CaseSensitiveComparison + : StringComparerUtils.IngoreCaseComparison; return string.Equals( Path.GetFullPath(path).TrimEnd('\\').TrimEnd('/'), diff --git a/src/GitVersionCore/Helpers/ThreadSleep.cs b/src/GitVersionCore/Helpers/ThreadSleep.cs index b20989814e..12cb1966d5 100644 --- a/src/GitVersionCore/Helpers/ThreadSleep.cs +++ b/src/GitVersionCore/Helpers/ThreadSleep.cs @@ -6,6 +6,7 @@ internal class ThreadSleep : IThreadSleep { public void Sleep(int milliseconds) { + Thread.Sleep(milliseconds); } } diff --git a/src/GitVersionCore/OutputVariables/VariableProvider.cs b/src/GitVersionCore/OutputVariables/VariableProvider.cs index ec71af58ed..b4f361e053 100644 --- a/src/GitVersionCore/OutputVariables/VariableProvider.cs +++ b/src/GitVersionCore/OutputVariables/VariableProvider.cs @@ -1,9 +1,9 @@ namespace GitVersion { using System; - using System.ComponentModel; using System.Text.RegularExpressions; using GitVersion.VersionCalculation; + using WarningException = GitTools.WarningException; public static class VariableProvider { diff --git a/src/GitVersionCore/OutputVariables/VersionVariables.cs b/src/GitVersionCore/OutputVariables/VersionVariables.cs index 430736187a..d5c4ec0d2e 100644 --- a/src/GitVersionCore/OutputVariables/VersionVariables.cs +++ b/src/GitVersionCore/OutputVariables/VersionVariables.cs @@ -6,6 +6,8 @@ using System.IO; using System.Linq; using GitVersion.Helpers; + using System.Reflection; + using YamlDotNet.Serialization; @@ -116,7 +118,20 @@ public static IEnumerable AvailableVariables [ReflectionIgnore] public string this[string variable] { - get { return (string)typeof(VersionVariables).GetProperty(variable).GetValue(this, null); } + + + get + { +#if NETDESKTOP + return typeof(VersionVariables).GetProperty(variable).GetValue(this, null) as string; +#else + throw new NotImplementedException(); + // return typeof(VersionVariables).GetTypeInfo().GetProperty(variable).GetValue(this, null) as string; +#endif + + + + } } public IEnumerator> GetEnumerator() @@ -137,7 +152,9 @@ IEnumerator IEnumerable.GetEnumerator() public static VersionVariables FromDictionary(IEnumerable> properties) { var type = typeof(VersionVariables); - var ctor = type.GetConstructors().Single(); + var constructors = type.GetConstructors(); + + var ctor = constructors.Single(); var ctorArgs = ctor.GetParameters() .Select(p => properties.Single(v => string.Equals(v.Key, p.Name, StringComparison.CurrentCultureIgnoreCase)).Value) .Cast() @@ -173,7 +190,12 @@ public bool TryGetValue(string variable, out string variableValue) public bool ContainsKey(string variable) { +#if NETDESKTOP return typeof(VersionVariables).GetProperty(variable) != null; +#else + throw new NotImplementedException(); + // return typeof(VersionVariables).GetTypeInfo().GetProperty(variable) != null; +#endif } sealed class ReflectionIgnoreAttribute : Attribute diff --git a/src/GitVersionCore/SearchPath.cs b/src/GitVersionCore/SearchPath.cs index b8f7cbb1d4..1fd9535324 100644 --- a/src/GitVersionCore/SearchPath.cs +++ b/src/GitVersionCore/SearchPath.cs @@ -22,7 +22,17 @@ public static void SetSearchPath(string addinDirectoryPath) static string GetProcessorArchitecture() { - if (Environment.Is64BitProcess) +#if NETDESKTOP + var is64 = Environment.Is64BitProcess; +#else + var arch = System.Runtime.InteropServices.RuntimeInformation.OSArchitecture; + bool is64 = (arch == System.Runtime.InteropServices.Architecture.X64 || arch == System.Runtime.InteropServices.Architecture.Arm64); + if (arch == System.Runtime.InteropServices.Architecture.X64) + { + return "X64"; + } +#endif + if (is64) { return "amd64"; } diff --git a/src/GitVersionCore/SemanticVersion.cs b/src/GitVersionCore/SemanticVersion.cs index e98056d7bd..0c8a9bedf0 100644 --- a/src/GitVersionCore/SemanticVersion.cs +++ b/src/GitVersionCore/SemanticVersion.cs @@ -1,5 +1,6 @@ namespace GitVersion { + using GitTools; using System; using System.ComponentModel; using System.Text.RegularExpressions; diff --git a/src/GitVersionCore/SemanticVersionPreReleaseTag.cs b/src/GitVersionCore/SemanticVersionPreReleaseTag.cs index 4a9e57e01d..92e3982633 100644 --- a/src/GitVersionCore/SemanticVersionPreReleaseTag.cs +++ b/src/GitVersionCore/SemanticVersionPreReleaseTag.cs @@ -1,10 +1,11 @@ +using System; +using System.Linq; +using System.Text.RegularExpressions; + namespace GitVersion { - using System; - using System.Linq; - using System.Text.RegularExpressions; - public class SemanticVersionPreReleaseTag : + public class SemanticVersionPreReleaseTag : IFormattable, IComparable, IEquatable { static LambdaEqualityHelper equalityHelper = @@ -71,7 +72,7 @@ public override int GetHashCode() public static bool operator <=(SemanticVersionPreReleaseTag left, SemanticVersionPreReleaseTag right) { - return StringComparer.InvariantCultureIgnoreCase.Compare(left.Name, right.Name) != 1; + return StringComparerUtils.IngoreCaseComparer.Compare(left.Name, right.Name) != 1; } public static implicit operator string(SemanticVersionPreReleaseTag preReleaseTag) @@ -99,7 +100,7 @@ public static SemanticVersionPreReleaseTag Parse(string preReleaseTag) } var value = match.Groups["name"].Value; - var number = match.Groups["number"].Success ? int.Parse(match.Groups["number"].Value) : (int?) null; + var number = match.Groups["number"].Success ? int.Parse(match.Groups["number"].Value) : (int?)null; if (value.EndsWith("-")) return new SemanticVersionPreReleaseTag(preReleaseTag, null); @@ -117,7 +118,8 @@ public int CompareTo(SemanticVersionPreReleaseTag other) return -1; } - var nameComparison = StringComparer.InvariantCultureIgnoreCase.Compare(Name, other.Name); + + var nameComparison = StringComparerUtils.IngoreCaseComparer.Compare(Name, other.Name); if (nameComparison != 0) return nameComparison; diff --git a/src/GitVersionCore/StringComparerUtils.cs b/src/GitVersionCore/StringComparerUtils.cs new file mode 100644 index 0000000000..d61d0ab2fe --- /dev/null +++ b/src/GitVersionCore/StringComparerUtils.cs @@ -0,0 +1,19 @@ +using System; + +namespace GitVersion +{ + public static class StringComparerUtils + { +#if NETDESKTOP + public static readonly System.StringComparer IngoreCaseComparer = StringComparer.InvariantCultureIgnoreCase; + public static readonly StringComparison IngoreCaseComparison = StringComparison.InvariantCultureIgnoreCase; + public static readonly StringComparison CaseSensitiveComparison = StringComparison.InvariantCulture; +#else + public static readonly System.StringComparer IngoreCaseComparer = StringComparer.OrdinalIgnoreCase; + public static readonly StringComparison IngoreCaseComparison = StringComparison.OrdinalIgnoreCase; + public static readonly StringComparison CaseSensitiveComparison = StringComparison.Ordinal; +#endif + } + + +} diff --git a/src/GitVersionCore/StringFormatWith.cs b/src/GitVersionCore/StringFormatWith.cs index 54eb2d5884..da1cd0c45e 100644 --- a/src/GitVersionCore/StringFormatWith.cs +++ b/src/GitVersionCore/StringFormatWith.cs @@ -17,6 +17,8 @@ All rights reserved. #endregion +#if NETDESKTOP + // Originally appeared in http://haacked.com/archive/2009/01/14/named-formats-redux.aspx // Authored by Henri Wiechers // Ported to NETFx by Daniel Cazzulino @@ -50,7 +52,7 @@ public static string FormatWith(this string format, object source) throw new ArgumentNullException("format"); } - var result = new StringBuilder(format.Length*2); + var result = new StringBuilder(format.Length * 2); using (var reader = new StringReader(format)) { @@ -76,7 +78,7 @@ public static string FormatWith(this string format, object source) state = State.OnCloseBracket; break; default: - result.Append((char) @char); + result.Append((char)@char); break; } break; @@ -91,7 +93,7 @@ public static string FormatWith(this string format, object source) state = State.OutsideExpression; break; default: - expression.Append((char) @char); + expression.Append((char)@char); state = State.InsideExpression; break; } @@ -108,7 +110,7 @@ public static string FormatWith(this string format, object source) state = State.OutsideExpression; break; default: - expression.Append((char) @char); + expression.Append((char)@char); break; } break; @@ -167,4 +169,6 @@ enum State End } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/GitVersionCore/VersionAssemblyInfoResources/AssemblyVersionInfoTemplates.cs b/src/GitVersionCore/VersionAssemblyInfoResources/AssemblyVersionInfoTemplates.cs index 36c8242b63..909811a454 100644 --- a/src/GitVersionCore/VersionAssemblyInfoResources/AssemblyVersionInfoTemplates.cs +++ b/src/GitVersionCore/VersionAssemblyInfoResources/AssemblyVersionInfoTemplates.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using GitVersionCore.Extensions; + using System.Reflection; public class AssemblyVersionInfoTemplates { @@ -64,7 +65,14 @@ private static IEnumerable GetEmbeddedVersionAssemblyFiles() if (enclosingNamespace == null) throw new InvalidOperationException("The AssemblyVersionInfoTemplates class is missing its namespace."); - foreach (var name in typeof(AssemblyVersionInfoTemplates).Assembly.GetManifestResourceNames()) + Assembly assy = null; +#if NETDESKTOP + assy = typeof(AssemblyVersionInfoTemplates).Assembly; +#else + assy = typeof(AssemblyVersionInfoTemplates).GetTypeInfo().Assembly; +#endif + + foreach (var name in assy.GetManifestResourceNames()) { if (name.StartsWith(enclosingNamespace)) yield return new FileInfo(name); diff --git a/src/GitVersionCore/VersionAssemblyInfoResources/VersionAssemblyInfo.cs b/src/GitVersionCore/VersionAssemblyInfoResources/VersionAssemblyInfo.cs index c46e49bf37..400214bf31 100644 --- a/src/GitVersionCore/VersionAssemblyInfoResources/VersionAssemblyInfo.cs +++ b/src/GitVersionCore/VersionAssemblyInfoResources/VersionAssemblyInfo.cs @@ -8,6 +8,6 @@ using System.Reflection; -[assembly: AssemblyFileVersion("0.0.0.0")] -[assembly: AssemblyVersion("0.0.0.0")] -[assembly: AssemblyInformationalVersion("0.0.0.0")] \ No newline at end of file +//[assembly: AssemblyFileVersion("0.0.0.0")] +//[assembly: AssemblyVersion("0.0.0.0")] +//[assembly: AssemblyInformationalVersion("0.0.0.0")] \ No newline at end of file diff --git a/src/NuGet.config b/src/NuGet.config new file mode 100644 index 0000000000..20d8e217a4 --- /dev/null +++ b/src/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file From 75b4e2bee66c35336c37ce58ee06539309e49350 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 16 Aug 2017 11:09:26 +0100 Subject: [PATCH 02/79] Fixes #1278 - ContinuaCI use environment variable not registry. --- src/GitVersionCore/BuildServers/ContinuaCi.cs | 32 ++++--------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/GitVersionCore/BuildServers/ContinuaCi.cs b/src/GitVersionCore/BuildServers/ContinuaCi.cs index 557648acc8..1cfff16e44 100644 --- a/src/GitVersionCore/BuildServers/ContinuaCi.cs +++ b/src/GitVersionCore/BuildServers/ContinuaCi.cs @@ -1,25 +1,16 @@ namespace GitVersion { -#if NETDESKTOP - using Microsoft.Win32; + using System; public class ContinuaCi : BuildServerBase { - public override bool CanApplyToCurrentContext() - { - const string KeyName = @"Software\VSoft Technologies\Continua CI Agent"; - if (RegistryKeyExists(KeyName, RegistryView.Registry32)) - { - return true; - } + public const string EnvironmentVariableName = "ContinuaCI.Version"; - if (RegistryKeyExists(KeyName, RegistryView.Registry64)) - { - return true; - } + public override bool CanApplyToCurrentContext() + { + return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable(EnvironmentVariableName)); - return false; } public override string[] GenerateSetParameterMessage(string name, string value) @@ -33,17 +24,6 @@ public override string[] GenerateSetParameterMessage(string name, string value) public override string GenerateSetVersionMessage(VersionVariables variables) { return string.Format("@@continua[setBuildVersion value='{0}']", variables.FullSemVer); - } - - static bool RegistryKeyExists(string keyName, RegistryView registryView) - { - var localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView); - localKey = localKey.OpenSubKey(keyName); - - return localKey != null; - } + } } - -#endif - } From 87ecbb7bae885ed040a2e992d1a5dad6e3a1124b Mon Sep 17 00:00:00 2001 From: Timothy Barnett TIBA Date: Mon, 31 Jul 2017 14:06:30 +0200 Subject: [PATCH 03/79] #1271 Allow branch names starting with master _masterfix_ and _fixmaster_ now behave the same way (i.e. in a different way to _master_, but in the same way as other branches) --- ....CanWriteOutEffectiveConfiguration.approved.txt | 2 +- .../IntegrationTests/OtherScenarios.cs | 14 ++++++++++++++ .../Configuration/ConfigurationProvider.cs | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt b/src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt index 3ad3bf8f76..1a0c0ba54b 100644 --- a/src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt +++ b/src/GitVersionCore.Tests/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt @@ -29,7 +29,7 @@ branches: increment: Patch prevent-increment-of-merged-branch-version: true track-merge-target: false - regex: master + regex: master$ source-branches: - develop - release diff --git a/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs index 4ebda3317b..5fef1447c6 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs @@ -46,6 +46,20 @@ public void AllowNotHavingMaster() } } + [Test] + public void AllowHavingVariantsStartingWithMaster() + { + using (var fixture = new EmptyRepositoryFixture()) + { + fixture.Repository.MakeACommit(); + fixture.Repository.MakeATaggedCommit("1.0.0"); + fixture.Repository.MakeACommit(); + Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("masterfix")); + + fixture.AssertFullSemver("1.0.1-masterfix.1+1"); + } + } + [Test] public void AllowHavingMainInsteadOfMaster() { diff --git a/src/GitVersionCore/Configuration/ConfigurationProvider.cs b/src/GitVersionCore/Configuration/ConfigurationProvider.cs index 23bf52e182..088791aa00 100644 --- a/src/GitVersionCore/Configuration/ConfigurationProvider.cs +++ b/src/GitVersionCore/Configuration/ConfigurationProvider.cs @@ -21,7 +21,7 @@ public class ConfigurationProvider public const string HotfixBranchRegex = "hotfix(es)?[/-]"; public const string SupportBranchRegex = "support[/-]"; public const string DevelopBranchRegex = "dev(elop)?(ment)?$"; - public const string MasterBranchRegex = "master"; + public const string MasterBranchRegex = "master$"; public const string MasterBranchKey = "master"; public const string ReleaseBranchKey = "release"; public const string FeatureBranchKey = "feature"; From 63f10286730b559d9bd2d75f02116a8c43023f4e Mon Sep 17 00:00:00 2001 From: Peter Neave Date: Thu, 10 Aug 2017 14:44:18 +1000 Subject: [PATCH 04/79] Added Octopus Deploy to list Octopus Deploy states that they use GitVersion here https://octopus.com/docs/packaging-applications/versioning-in-octopus-deploy#VersioninginOctopusDeploy-HowweversionOctopusDeploy --- docs/who.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/who.md b/docs/who.md index e5026b8ce8..0fdc28d52d 100644 --- a/docs/who.md +++ b/docs/who.md @@ -4,6 +4,7 @@ Various people are actively using GitVersion, and taking advantage of the automa * [Catel](https://github.com/catel/catel) * [ChocolateyGUI](https://github.com/chocolatey/ChocolateyGUI) * [GitLink](https://github.com/GitTools/GitLink) + * [OctopusDeploy](https://github.com/OctopusDeploy) * [Orc.* packages](https://github.com/wildgums?query=orc) * [Orchestra](https://github.com/wildgums/orchestra) * [Pomona](http://pomona.io/) From 67ed186573aaf7c39de05cb9968d9858421bac6f Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 16 Aug 2017 22:36:55 +0100 Subject: [PATCH 05/79] Worked around absent GetEncodings APi for NetStandard. Tried to switch to `Task.Delay` instead of Thread.Sleep but task's won't compile for net40 for some reason, even with the bcl.async nuget package. --- .../Mocks/MockThreadSleep.cs | 11 +++---- .../OperationWithExponentialBackoffTests.cs | 10 +++---- src/GitVersionCore/ExecuteCore.cs | 6 ++-- src/GitVersionCore/Extensions/TaskHelper.cs | 29 ++++++++++++++++++ src/GitVersionCore/GitVersionCache.cs | 5 ++-- src/GitVersionCore/GitVersionCore.csproj | 21 +++++++------ src/GitVersionCore/Helpers/EncodingHelper.cs | 30 ++++++++++++++----- src/GitVersionCore/Helpers/IThreadSleep.cs | 6 ++-- .../OperationWithExponentialBackoff.cs | 6 ++-- src/GitVersionCore/Helpers/ThreadSleep.cs | 7 ++--- .../OutputVariables/VariableProvider.cs | 3 ++ src/GitVersionCore/SemanticVersion.cs | 2 +- 12 files changed, 96 insertions(+), 40 deletions(-) create mode 100644 src/GitVersionCore/Extensions/TaskHelper.cs diff --git a/src/GitVersionCore.Tests/Mocks/MockThreadSleep.cs b/src/GitVersionCore.Tests/Mocks/MockThreadSleep.cs index e32b4f5e04..fa04ecf06e 100644 --- a/src/GitVersionCore.Tests/Mocks/MockThreadSleep.cs +++ b/src/GitVersionCore.Tests/Mocks/MockThreadSleep.cs @@ -1,20 +1,21 @@ using System; using GitVersion.Helpers; +using System.Threading.Tasks; public class MockThreadSleep : IThreadSleep { - private Action Validator; - - public MockThreadSleep(Action validator = null) + private Func Validator; + + public MockThreadSleep(Func validator = null) { this.Validator = validator; } - public void Sleep(int milliseconds) + public async Task SleepAsync(int milliseconds) { if (Validator != null) { - Validator(milliseconds); + await Validator(milliseconds); } } } diff --git a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs index 0e8ad200fd..af536f6d0c 100644 --- a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs +++ b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs @@ -30,7 +30,7 @@ public void OperationIsNotRetriedOnInvalidException() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation); - Action action = () => retryOperation.Execute(); + Action action = () => retryOperation.ExecuteAsync(); action.ShouldThrow(); } @@ -49,7 +49,7 @@ public void OperationIsRetriedOnIOException() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation); - retryOperation.Execute(); + retryOperation.ExecuteAsync(); operationCount.ShouldBe(2); } @@ -67,7 +67,7 @@ public void OperationIsRetriedAMaximumNumberOfTimes() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation, numberOfRetries); - Action action = () => retryOperation.Execute(); + Action action = () => retryOperation.ExecuteAsync(); action.ShouldThrow(); operationCount.ShouldBe(numberOfRetries + 1); @@ -93,7 +93,7 @@ public void OperationDelayDoublesBetweenRetries() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(validator), operation, numberOfRetries); - Action action = () => retryOperation.Execute(); + Action action = () => retryOperation.ExecuteAsync(); action.ShouldThrow(); sleepCount.ShouldBe(numberOfRetries); @@ -116,7 +116,7 @@ public void TotalSleepTimeForSixRetriesIsAboutThirtySeconds() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(validator), operation, numberOfRetries); - Action action = () => retryOperation.Execute(); + Action action = () => retryOperation.ExecuteAsync(); action.ShouldThrow(); // Exact number is 31,5 seconds diff --git a/src/GitVersionCore/ExecuteCore.cs b/src/GitVersionCore/ExecuteCore.cs index 225d21e260..433dcce46a 100644 --- a/src/GitVersionCore/ExecuteCore.cs +++ b/src/GitVersionCore/ExecuteCore.cs @@ -62,7 +62,7 @@ public VersionVariables ExecuteGitVersion(string targetUrl, string dynamicReposi { try { - gitVersionCache.WriteVariablesToDiskCache(gitPreparer, cacheKey, versionVariables); + gitVersionCache.WriteVariablesToDiskCacheAsync(gitPreparer, cacheKey, versionVariables); } catch (AggregateException e) { @@ -125,7 +125,7 @@ IRepository GetRepository(string gitDirectory) var branch = repository.Head; if (branch.Tip == null) { - throw new WarningException("No Tip found. Has repo been initialized?"); + throw new GitTools.WarningException("No Tip found. Has repo been initialized?"); } return repository; } @@ -133,7 +133,7 @@ IRepository GetRepository(string gitDirectory) { if (exception.Message.Contains("LibGit2Sharp.Core.NativeMethods") || exception.Message.Contains("FilePathMarshaler")) { - throw new WarningException("Restart of the process may be required to load an updated version of LibGit2Sharp."); + throw new GitTools.WarningException("Restart of the process may be required to load an updated version of LibGit2Sharp."); } throw; } diff --git a/src/GitVersionCore/Extensions/TaskHelper.cs b/src/GitVersionCore/Extensions/TaskHelper.cs new file mode 100644 index 0000000000..92cffec0b7 --- /dev/null +++ b/src/GitVersionCore/Extensions/TaskHelper.cs @@ -0,0 +1,29 @@ +namespace System.Threading.Tasks +{ + public static class TaskHelper + { + +#if NETDESKTOP + public static Task Delay(int milliseconds) + { + var tcs = new TaskCompletionSource(); + System.Timers.Timer timer = new System.Timers.Timer(); + timer.Elapsed += (obj, args) => + { + tcs.TrySetResult(true); + }; + timer.Interval = (double)milliseconds; + timer.AutoReset = false; + timer.Start(); + return tcs.Task; + } +#else + public static Task Delay(int milliseconds) + { + return Task.Delay(milliseconds); + } +#endif + } + + +} diff --git a/src/GitVersionCore/GitVersionCache.cs b/src/GitVersionCore/GitVersionCache.cs index 99307c2ab6..c148cf75f8 100644 --- a/src/GitVersionCore/GitVersionCache.cs +++ b/src/GitVersionCore/GitVersionCache.cs @@ -5,6 +5,7 @@ namespace GitVersion using System.Collections.Generic; using System.IO; using System.Linq; + using System.Threading.Tasks; using YamlDotNet.Serialization; public class GitVersionCache @@ -16,7 +17,7 @@ public GitVersionCache(IFileSystem fileSystem) this.fileSystem = fileSystem; } - public void WriteVariablesToDiskCache(GitPreparer gitPreparer, GitVersionCacheKey cacheKey, VersionVariables variablesFromCache) + public async Task WriteVariablesToDiskCacheAsync(GitPreparer gitPreparer, GitVersionCacheKey cacheKey, VersionVariables variablesFromCache) { var cacheDir = PrepareCacheDirectory(gitPreparer); var cacheFileName = GetCacheFileName(cacheKey, cacheDir); @@ -45,7 +46,7 @@ public void WriteVariablesToDiskCache(GitPreparer gitPreparer, GitVersionCacheKe }; var retryOperation = new OperationWithExponentialBackoff(new ThreadSleep(), writeCacheOperation, maxRetries: 6); - retryOperation.Execute(); + await retryOperation.ExecuteAsync(); } public static string GetCacheDirectory(GitPreparer gitPreparer) diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 69ff279af9..2f91caffce 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -66,7 +66,7 @@ See --> - + All @@ -83,18 +83,21 @@ + + + - - - - - - - - + + + + + + + + diff --git a/src/GitVersionCore/Helpers/EncodingHelper.cs b/src/GitVersionCore/Helpers/EncodingHelper.cs index f16f0bec14..8337246f67 100644 --- a/src/GitVersionCore/Helpers/EncodingHelper.cs +++ b/src/GitVersionCore/Helpers/EncodingHelper.cs @@ -74,13 +74,29 @@ public static Encoding DetectEncoding(IList bytes) private static void ScanEncodings() { // Might be out of luck finding a replacement for GetEncodings for netcore 1: https://stackoverflow.com/questions/44351507/what-is-net-core-equivalent-of-encoding-getencodings - EncodingsWithPreambles = (from info in Encoding.GetEncodings() - let encoding = info.GetEncoding() - let preamble = encoding.GetPreamble() - where preamble.Length > 0 - orderby preamble.Length descending - select encoding).ToList(); - +#if NETDESKTOP + var encodings = (Encoding.GetEncodings()); + EncodingsWithPreambles = (from info in encodings + let encoding = info.GetEncoding() + let preamble = encoding.GetPreamble() + where preamble.Length > 0 + orderby preamble.Length descending + select encoding).ToList(); + +#else + // GetEncodings not available on netstandard, so just manually adding some common ones. + var encodings = new List() { Encoding.ASCII, Encoding.Unicode, Encoding.UTF32, Encoding.UTF7, Encoding.UTF8 }; + EncodingsWithPreambles = (from info in encodings + let preamble = info.GetPreamble() + where preamble.Length > 0 + orderby preamble.Length descending + select info).ToList(); +#endif + + + + + var encodingWithLongestPreamble = EncodingsWithPreambles.FirstOrDefault(); MaxPreambleLength = encodingWithLongestPreamble == null ? 0 : encodingWithLongestPreamble.GetPreamble().Length; } diff --git a/src/GitVersionCore/Helpers/IThreadSleep.cs b/src/GitVersionCore/Helpers/IThreadSleep.cs index 86484d3580..ca6f90f302 100644 --- a/src/GitVersionCore/Helpers/IThreadSleep.cs +++ b/src/GitVersionCore/Helpers/IThreadSleep.cs @@ -1,7 +1,9 @@ -namespace GitVersion.Helpers +using System.Threading.Tasks; + +namespace GitVersion.Helpers { public interface IThreadSleep { - void Sleep(int milliseconds); + Task SleepAsync(int milliseconds); } } diff --git a/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs b/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs index 61e6e6fd73..c6b6b5395f 100644 --- a/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs +++ b/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace GitVersion.Helpers { @@ -21,7 +22,7 @@ public OperationWithExponentialBackoff(IThreadSleep threadSleep, Action operatio this.MaxRetries = maxRetries; } - public void Execute() + public async Task ExecuteAsync() { var exceptions = new List(); @@ -47,7 +48,8 @@ public void Execute() } Logger.WriteInfo(string.Format("Operation failed, retrying in {0} milliseconds.", sleepMSec)); - ThreadSleep.Sleep(sleepMSec); + await TaskHelper.Delay(sleepMSec); + sleepMSec *= 2; } } diff --git a/src/GitVersionCore/Helpers/ThreadSleep.cs b/src/GitVersionCore/Helpers/ThreadSleep.cs index 12cb1966d5..f293358199 100644 --- a/src/GitVersionCore/Helpers/ThreadSleep.cs +++ b/src/GitVersionCore/Helpers/ThreadSleep.cs @@ -1,13 +1,12 @@ namespace GitVersion.Helpers { - using System.Threading; + using System.Threading.Tasks; internal class ThreadSleep : IThreadSleep { - public void Sleep(int milliseconds) + public async Task SleepAsync(int milliseconds) { - - Thread.Sleep(milliseconds); + await TaskHelper.Delay(milliseconds); } } } diff --git a/src/GitVersionCore/OutputVariables/VariableProvider.cs b/src/GitVersionCore/OutputVariables/VariableProvider.cs index b4f361e053..277a6053c0 100644 --- a/src/GitVersionCore/OutputVariables/VariableProvider.cs +++ b/src/GitVersionCore/OutputVariables/VariableProvider.cs @@ -53,7 +53,10 @@ public static VersionVariables GetVariablesFor(SemanticVersion semanticVersion, { try { +#if NETDESKTOP informationalVersion = config.AssemblyInformationalFormat.FormatWith(semverFormatValues); +#endif + throw new NotImplementedException(); } catch (FormatException formex) { diff --git a/src/GitVersionCore/SemanticVersion.cs b/src/GitVersionCore/SemanticVersion.cs index 0c8a9bedf0..51927ee959 100644 --- a/src/GitVersionCore/SemanticVersion.cs +++ b/src/GitVersionCore/SemanticVersion.cs @@ -142,7 +142,7 @@ public static SemanticVersion Parse(string version, string tagPrefixRegex) { SemanticVersion semanticVersion; if (!TryParse(version, tagPrefixRegex, out semanticVersion)) - throw new WarningException(string.Format("Failed to parse {0} into a Semantic Version", version)); + throw new GitTools.WarningException(string.Format("Failed to parse {0} into a Semantic Version", version)); return semanticVersion; } From 309a30c7ed8e22ab7b3991f0c29d796d449d04d4 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 16 Aug 2017 23:03:32 +0100 Subject: [PATCH 06/79] Down to one build error. --- .../GitVersionCore.Tests.csproj | 23 ++++++----- .../OperationWithExponentialBackoffTests.cs | 38 +++++++++++++------ src/GitVersionCore.Tests/app.config | 2 +- src/GitVersionCore.Tests/packages.config | 10 +++-- src/GitVersionCore/GitVersionCore.csproj | 15 +++++--- .../GitVersionExe.Tests.csproj | 18 +++++---- src/GitVersionExe.Tests/app.config | 2 +- src/GitVersionExe.Tests/packages.config | 10 +++-- src/GitVersionExe/GitVersionExe.csproj | 17 +++++---- src/GitVersionExe/packages.config | 7 ++-- .../GitVersionTask.Tests.csproj | 18 +++++---- src/GitVersionTask.Tests/app.config | 2 +- src/GitVersionTask.Tests/packages.config | 10 +++-- src/GitVersionTask/GitVersionTask.csproj | 17 +++++---- src/GitVersionTask/packages.config | 7 ++-- 15 files changed, 119 insertions(+), 77 deletions(-) diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 370f750929..168225713d 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -1,6 +1,6 @@  - + Debug @@ -42,18 +42,20 @@ ..\packages\FluentDateTime.1.13.0\lib\NET35\FluentDateTime.dll True - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net45\GitTools.Core.dll - True + + ..\packages\GitTools.Core.1.3.0\lib\net45\GitTools.Core.dll ..\packages\GitTools.Testing.1.1.1-beta0001\lib\net4\GitTools.Testing.dll True - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True + + ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll + + + ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll + ..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll True @@ -68,6 +70,7 @@ + @@ -158,7 +161,9 @@ - + + Designer + @@ -189,8 +194,8 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs index af536f6d0c..4bb1975f1e 100644 --- a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs +++ b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs @@ -3,6 +3,7 @@ using GitVersion.Helpers; using NUnit.Framework; using Shouldly; +using System.Threading.Tasks; [TestFixture] public class OperationWithExponentialBackoffTests @@ -74,7 +75,7 @@ public void OperationIsRetriedAMaximumNumberOfTimes() } [Test] - public void OperationDelayDoublesBetweenRetries() + public async Task OperationDelayDoublesBetweenRetries() { const int numberOfRetries = 3; var expectedSleepMSec = 500; @@ -85,22 +86,28 @@ public void OperationDelayDoublesBetweenRetries() throw new IOException(); }; - Action validator = u => + Func validator = (u) => { - sleepCount++; - u.ShouldBe(expectedSleepMSec); - expectedSleepMSec *= 2; + return Task.Run(() => + { + sleepCount++; + u.ShouldBe(expectedSleepMSec); + expectedSleepMSec *= 2; + }); + }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(validator), operation, numberOfRetries); - Action action = () => retryOperation.ExecuteAsync(); - action.ShouldThrow(); + Task action = retryOperation.ExecuteAsync(); + await action.ShouldThrowAsync(); + + // action.ShouldThrow(); sleepCount.ShouldBe(numberOfRetries); } [Test] - public void TotalSleepTimeForSixRetriesIsAboutThirtySeconds() + public async Task TotalSleepTimeForSixRetriesIsAboutThirtySecondsAsync() { const int numberOfRetries = 6; int totalSleep = 0; @@ -110,14 +117,21 @@ public void TotalSleepTimeForSixRetriesIsAboutThirtySeconds() throw new IOException(); }; - Action validator = u => + Func validator = (u) => { - totalSleep += u; + return Task.Run(() => + { + totalSleep += u; + }); + }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(validator), operation, numberOfRetries); - Action action = () => retryOperation.ExecuteAsync(); - action.ShouldThrow(); + + Task action = retryOperation.ExecuteAsync(); + await action.ShouldThrowAsync(); + // Action action = () => retryOperation.ExecuteAsync(); + // action.ShouldThrow(); // Exact number is 31,5 seconds totalSleep.ShouldBe(31500); diff --git a/src/GitVersionCore.Tests/app.config b/src/GitVersionCore.Tests/app.config index c24557fb8a..c7a9384535 100644 --- a/src/GitVersionCore.Tests/app.config +++ b/src/GitVersionCore.Tests/app.config @@ -8,7 +8,7 @@ - + diff --git a/src/GitVersionCore.Tests/packages.config b/src/GitVersionCore.Tests/packages.config index 0797568c38..e93f302b24 100644 --- a/src/GitVersionCore.Tests/packages.config +++ b/src/GitVersionCore.Tests/packages.config @@ -2,15 +2,19 @@ - + - - + + + + + + \ No newline at end of file diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 2f91caffce..bdac39c913 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -2,6 +2,7 @@ netstandard1.3;net40 + net40 Library GitVersion GitVersionCore @@ -34,9 +35,9 @@ true - + TRACE;NET40;NETDESKTOP @@ -65,6 +66,7 @@ + @@ -72,8 +74,7 @@ - - + @@ -85,9 +86,11 @@ - - + + + + diff --git a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj index 0de79326e5..c97ddcbf0b 100644 --- a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj +++ b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj @@ -1,6 +1,6 @@  - + Debug @@ -35,17 +35,18 @@ true - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net45\GitTools.Core.dll - True + + ..\packages\GitTools.Core.1.3.0\lib\net45\GitTools.Core.dll ..\packages\GitTools.Testing.1.1.1-beta0001\lib\net4\GitTools.Testing.dll True - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True + + ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll + + + ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll @@ -77,6 +78,7 @@ + @@ -146,6 +148,6 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/GitVersionExe.Tests/app.config b/src/GitVersionExe.Tests/app.config index c24557fb8a..c7a9384535 100644 --- a/src/GitVersionExe.Tests/app.config +++ b/src/GitVersionExe.Tests/app.config @@ -8,7 +8,7 @@ - + diff --git a/src/GitVersionExe.Tests/packages.config b/src/GitVersionExe.Tests/packages.config index 30641d4d15..e832e5bd94 100644 --- a/src/GitVersionExe.Tests/packages.config +++ b/src/GitVersionExe.Tests/packages.config @@ -1,12 +1,16 @@  - + - - + + + + + + \ No newline at end of file diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index e862fb08f5..8374af9782 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -1,6 +1,6 @@  - + Debug AnyCPU @@ -41,13 +41,14 @@ 1591 - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net4\GitTools.Core.dll - True + + ..\packages\GitTools.Core.1.3.0\lib\net40\GitTools.Core.dll - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True + + ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll + + + ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll @@ -212,8 +213,8 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/GitVersionExe/packages.config b/src/GitVersionExe/packages.config index 62114fb516..7341ae9b26 100644 --- a/src/GitVersionExe/packages.config +++ b/src/GitVersionExe/packages.config @@ -2,9 +2,10 @@ - + - - + + + \ No newline at end of file diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index 8fcf5aa054..a78d3f4f5d 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -1,6 +1,6 @@  - + Debug AnyCPU @@ -56,13 +56,14 @@ ..\packages\FluentDateTime.1.13.0\lib\NET35\FluentDateTime.dll True - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net45\GitTools.Core.dll - True + + ..\packages\GitTools.Core.1.3.0\lib\net45\GitTools.Core.dll - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True + + ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll + + + ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll @@ -110,6 +111,7 @@ ..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll True + @@ -189,8 +191,8 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/GitVersionTask.Tests/app.config b/src/GitVersionTask.Tests/app.config index 3d12e16fad..c39d7cb3ce 100644 --- a/src/GitVersionTask.Tests/app.config +++ b/src/GitVersionTask.Tests/app.config @@ -16,7 +16,7 @@ - + diff --git a/src/GitVersionTask.Tests/packages.config b/src/GitVersionTask.Tests/packages.config index 856ed3b632..2598a9979f 100644 --- a/src/GitVersionTask.Tests/packages.config +++ b/src/GitVersionTask.Tests/packages.config @@ -4,13 +4,15 @@ - - - + + + + + @@ -21,11 +23,13 @@ + + \ No newline at end of file diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 5ab4fdd607..fb156332e3 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -1,6 +1,6 @@  - + Debug @@ -39,13 +39,14 @@ 1591 - - ..\packages\GitTools.Core.1.2.1-beta0001\lib\net4\GitTools.Core.dll - True + + ..\packages\GitTools.Core.1.3.0\lib\net40\GitTools.Core.dll - - ..\packages\LibGit2Sharp.0.23.0-pre20160922233542\lib\net40\LibGit2Sharp.dll - True + + ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll + + + ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll @@ -139,8 +140,8 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/src/GitVersionTask/packages.config b/src/GitVersionTask/packages.config index d94e9e5e27..bd05c73992 100644 --- a/src/GitVersionTask/packages.config +++ b/src/GitVersionTask/packages.config @@ -2,10 +2,11 @@ - + - - + + + \ No newline at end of file From 8d56e2339f57963eb8ce279ba32319d00a6f1191 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 16 Aug 2017 23:11:21 +0100 Subject: [PATCH 07/79] Fixed up some tests. Haven't been able to run them yet! --- .../OperationWithExponentialBackoffTests.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs index 4bb1975f1e..699faad16c 100644 --- a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs +++ b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs @@ -23,7 +23,7 @@ public void RetryOperationThrowsWhenThreadSleepIsNull() } [Test] - public void OperationIsNotRetriedOnInvalidException() + public async Task OperationIsNotRetriedOnInvalidException() { Action operation = () => { @@ -31,12 +31,12 @@ public void OperationIsNotRetriedOnInvalidException() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation); - Action action = () => retryOperation.ExecuteAsync(); - action.ShouldThrow(); + Task action = retryOperation.ExecuteAsync(); + await action.ShouldThrowAsync(); } [Test] - public void OperationIsRetriedOnIOException() + public async Task OperationIsRetriedOnIOException() { var operationCount = 0; @@ -50,13 +50,13 @@ public void OperationIsRetriedOnIOException() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation); - retryOperation.ExecuteAsync(); + await retryOperation.ExecuteAsync(); operationCount.ShouldBe(2); } [Test] - public void OperationIsRetriedAMaximumNumberOfTimes() + public async Task OperationIsRetriedAMaximumNumberOfTimesAsync() { const int numberOfRetries = 3; var operationCount = 0; @@ -68,8 +68,8 @@ public void OperationIsRetriedAMaximumNumberOfTimes() }; var retryOperation = new OperationWithExponentialBackoff(new MockThreadSleep(), operation, numberOfRetries); - Action action = () => retryOperation.ExecuteAsync(); - action.ShouldThrow(); + Task action = retryOperation.ExecuteAsync(); + await action.ShouldThrowAsync(); operationCount.ShouldBe(numberOfRetries + 1); } From b41fc585a865efd42df91825ee407476c93333c0 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 17 Aug 2017 02:25:49 +0100 Subject: [PATCH 08/79] gitversiontask building again for net40. --- src/GitVersion.sln | 14 +- src/GitVersionCore/GitVersionCore.csproj | 1 - .../GitVersionTask.Tests.csproj | 4 - src/GitVersionTask/AssemblyInfo.cs | 7 - src/GitVersionTask/FodyWeavers.xml | 3 +- src/GitVersionTask/GitVersionTask.csproj | 157 +++++++----------- .../NugetAssets/GitVersionTask.nuspec | 7 + src/GitVersionTask/key.snk | Bin 0 -> 596 bytes 8 files changed, 78 insertions(+), 115 deletions(-) delete mode 100644 src/GitVersionTask/AssemblyInfo.cs create mode 100644 src/GitVersionTask/key.snk diff --git a/src/GitVersion.sln b/src/GitVersion.sln index 2b9eb623dc..211d857af2 100644 --- a/src/GitVersion.sln +++ b/src/GitVersion.sln @@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionExe", "GitVersion EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionTask.Tests", "GitVersionTask.Tests\GitVersionTask.Tests.csproj", "{5A86453B-96FB-4B6E-A283-225BB9F753D3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionTask", "GitVersionTask\GitVersionTask.csproj", "{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionCore.Tests", "GitVersionCore.Tests\GitVersionCore.Tests.csproj", "{BF905F84-382C-440D-92F5-C61108626D8D}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3EFFC5D6-88D0-49D9-BB53-E1B7EB49DD45}" @@ -30,7 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\README.md = ..\README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionCore", "GitVersionCore\GitVersionCore.csproj", "{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionCore", "GitVersionCore\GitVersionCore.csproj", "{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionExe.Tests", "GitVersionExe.Tests\GitVersionExe.Tests.csproj", "{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}" EndProject @@ -46,6 +44,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TfsTask", "TfsTask", "{A0ED GitVersionTfsTask\Update-GitVersionTfsTaskVersion.ps1 = GitVersionTfsTask\Update-GitVersionTfsTaskVersion.ps1 EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionTask", "GitVersionTask\GitVersionTask.csproj", "{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -60,10 +60,6 @@ Global {5A86453B-96FB-4B6E-A283-225BB9F753D3}.Debug|Any CPU.Build.0 = Debug|Any CPU {5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|Any CPU.ActiveCfg = Release|Any CPU {5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|Any CPU.Build.0 = Release|Any CPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.Build.0 = Release|Any CPU {BF905F84-382C-440D-92F5-C61108626D8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BF905F84-382C-440D-92F5-C61108626D8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF905F84-382C-440D-92F5-C61108626D8D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -76,6 +72,10 @@ Global {75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Release|Any CPU.ActiveCfg = Release|Any CPU {75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Release|Any CPU.Build.0 = Release|Any CPU + {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index bdac39c913..11a8a1a82a 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -84,7 +84,6 @@ - diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index a78d3f4f5d..53b3256f3a 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -170,10 +170,6 @@ {F9741A0D-B9D7-4557-9A1C-A7252C1071F5} GitVersionCore - - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1} - GitVersionTask - diff --git a/src/GitVersionTask/AssemblyInfo.cs b/src/GitVersionTask/AssemblyInfo.cs deleted file mode 100644 index d4fbe64c8f..0000000000 --- a/src/GitVersionTask/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyTitle("GitVersionTask")] -[assembly: AssemblyProduct("GitVersionTask")] -[assembly: AssemblyVersion("4.0.0.0")] -[assembly: AssemblyFileVersion("4.0.0.0")] -[assembly: AssemblyInformationalVersion("4.0.0-beta.12+1291.Branch.master.Sha.bc74ac2247d8a58053a33316334ada6b771a8455")] diff --git a/src/GitVersionTask/FodyWeavers.xml b/src/GitVersionTask/FodyWeavers.xml index 6c4dacc2ba..5adf0a8f9f 100644 --- a/src/GitVersionTask/FodyWeavers.xml +++ b/src/GitVersionTask/FodyWeavers.xml @@ -1,4 +1,5 @@ - + + \ No newline at end of file diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index fb156332e3..1e4631f233 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -1,19 +1,21 @@  - - - + Debug AnyCPU - {F7AC0E71-3E9A-4F6D-B986-E004825A48E1} Library - Properties GitVersionTask GitVersionTask - v4.0 - 6 - 512 - $(SolutionDir)..\build\ + net40 + 0.0.1 + + NugetAssets\GitVersionTask.nuspec + version=$(PackageVersion);configuration=$(Configuration) + GitTools and Contributors + + $(Authors) + $(AssemblyName) + @@ -21,33 +23,41 @@ true full false - bin\Debug\ DEBUG;TRACE - prompt - 4 - false 1591 pdbonly true - bin\Release\ TRACE prompt 4 - false 1591 - - ..\packages\GitTools.Core.1.3.0\lib\net40\GitTools.Core.dll - - - ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll - - - ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll - + + + all + + + all + + + all + + + all + + + all + + + All + + + @@ -59,30 +69,27 @@ - - ..\packages\YamlDotNet.3.8.0\lib\net35\YamlDotNet.dll - True - - - - - - - - - - - - - - - - + + true + build\lib\ + + + true + build\ + - - + + + true + buildMultiTargeting\GitVersionTask.targets + + + true + build\GitVersionTask.targets + + Designer @@ -90,65 +97,25 @@ Designer + Designer - - {f9741a0d-b9d7-4557-9a1c-a7252c1071f5} - GitVersionCore - + - - - - - - - - - - - mono - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + + f7ac0e71-3e9a-4f6d-b986-e004825a48e1 + + + + - - - - \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index 2e053e86cc..51d52a5448 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -15,5 +15,12 @@ Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer true https://github.com/GitTools/GitVersion/releases + + + + + + + diff --git a/src/GitVersionTask/key.snk b/src/GitVersionTask/key.snk new file mode 100644 index 0000000000000000000000000000000000000000..17a1bfef7139447f43b42db920ce12b72542d855 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa500980B+&fDRCUgiCp10$nRIiT<|+1?r=Ds% zBgxFU&lQ>Rz6!O`X!|I5l~kA+wB`oY%|9=6#pz7)p~T~D}B>-rpQNH4cJgy){6>lS_$fM9)nQt%=KN+&Q-StH2@vmx1! zgg``_c9VUUju6(RfvV=#8IE zZD1k)Z7li5``YwMWJjO0is?l{ea7)!K->l~6i_lWw0&ZW&qgvEGC)>Ct8&25*9x1A zpeIixp4MlXZW;83dE*gHdZxYoVpE{<)N@Ew@n zDb&uMN~;fXl_CmU3P~91;Pq|%EGpJP3yM$4NH+PyGv`W&6m%nv@c{Vo(J>QwIJ7EX zdOOaIrR(HtQ*#gYU)JI*FyOL2lGZ2nLz2-@LT-JV9s=HKDRbNivnGybpjcm*zB}dT zk4Y34SP@6f=IO1^gAiBlxK1ZPGvs@moLoPGH}dhZ4(~rYfcLx!f5Z*3odB_c|Lh#T z?PKL03Yv}>rP&*KTTo1%N!dq}m4t|SsNPOH>oD;QBib(=(TJTTUo~z#^n+|l7 Date: Thu, 17 Aug 2017 23:45:47 +0100 Subject: [PATCH 09/79] Upgraded yamldotnet, removed remaining system.web references, and switched to gittools warning exceptions. --- src/GitVersionCore.Tests/ConfigProviderTests.cs | 2 +- src/GitVersionCore.Tests/GitVersionCore.Tests.csproj | 9 +++++---- .../IntegrationTests/RemoteRepositoryScenarios.cs | 2 +- src/GitVersionCore.Tests/packages.config | 2 +- src/GitVersionCore/GitVersionCore.csproj | 4 +--- .../Helpers/OperationWithExponentialBackoff.cs | 2 +- src/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs | 2 +- src/GitVersionTask.Tests/GitVersionTask.Tests.csproj | 4 ++++ src/GitVersionTask/GitVersionTask.csproj | 10 +++++----- 9 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/GitVersionCore.Tests/ConfigProviderTests.cs b/src/GitVersionCore.Tests/ConfigProviderTests.cs index cf3c527325..e288777fbc 100644 --- a/src/GitVersionCore.Tests/ConfigProviderTests.cs +++ b/src/GitVersionCore.Tests/ConfigProviderTests.cs @@ -1,9 +1,9 @@ +using GitTools; using GitVersion; using GitVersion.Helpers; using NUnit.Framework; using Shouldly; using System; -using System.ComponentModel; using System.IO; using System.Linq; using System.Reflection; diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 168225713d..966a41d576 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -80,9 +80,8 @@ ..\packages\TestStack.ConventionTests.3.0.0\lib\net40\TestStack.ConventionTests.dll True - - ..\packages\YamlDotNet.3.8.0\lib\net35\YamlDotNet.dll - True + + ..\packages\YamlDotNet.4.2.1\lib\net35\YamlDotNet.dll @@ -164,7 +163,9 @@ Designer - + + Designer + diff --git a/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs index d6debdcc42..2dedb40287 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs @@ -1,11 +1,11 @@ using System; -using System.ComponentModel; using GitTools.Git; using GitTools.Testing; using GitVersionCore.Tests; using LibGit2Sharp; using NUnit.Framework; using Shouldly; +using GitTools; [TestFixture] public class RemoteRepositoryScenarios diff --git a/src/GitVersionCore.Tests/packages.config b/src/GitVersionCore.Tests/packages.config index e93f302b24..b176980283 100644 --- a/src/GitVersionCore.Tests/packages.config +++ b/src/GitVersionCore.Tests/packages.config @@ -16,5 +16,5 @@ - + \ No newline at end of file diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 11a8a1a82a..9e93056757 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -81,9 +81,7 @@ - - - + diff --git a/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs b/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs index c6b6b5395f..56e48cc5a3 100644 --- a/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs +++ b/src/GitVersionCore/Helpers/OperationWithExponentialBackoff.cs @@ -48,7 +48,7 @@ public async Task ExecuteAsync() } Logger.WriteInfo(string.Format("Operation failed, retrying in {0} milliseconds.", sleepMSec)); - await TaskHelper.Delay(sleepMSec); + await ThreadSleep.SleepAsync(sleepMSec); sleepMSec *= 2; } diff --git a/src/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs b/src/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs index 2a183ca1be..ef58630bea 100644 --- a/src/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs +++ b/src/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Linq; using System.Reflection; @@ -14,6 +13,7 @@ using NSubstitute; using NUnit.Framework; using Shouldly; +using GitTools; [TestFixture] public class AssemblyInfoBuilderTests diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index 53b3256f3a..754fe29a80 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -170,6 +170,10 @@ {F9741A0D-B9D7-4557-9A1C-A7252C1071F5} GitVersionCore + + {f7ac0e71-3e9a-4f6d-b986-e004825a48e1} + GitVersionTask + diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 1e4631f233..7caab99524 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -39,19 +39,19 @@ See --> - all + All - all + All - all + All - all + All - all + All All From 123d73bc1b5215528b4053855780371e5f9ffda4 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 18 Aug 2017 00:10:29 +0100 Subject: [PATCH 10/79] Upgraded GitVersionTask csproj to new vs2017 format. --- .../GitVersionTask.Tests.csproj | 172 ++++-------------- 1 file changed, 38 insertions(+), 134 deletions(-) diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index 754fe29a80..f1249abb88 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -1,20 +1,21 @@ - - - + Debug AnyCPU - 8.0.30703 - 2.0 - {5A86453B-96FB-4B6E-A283-225BB9F753D3} + Library - Properties + GitVersionTask.Tests GitVersionTask.Tests - v4.5 - 6 - 512 - + net45 + + false + false + false + false + false + true + @@ -40,159 +41,62 @@ true - - ..\packages\ApprovalTests.3.0.11\lib\net40\ApprovalTests.dll - True - - - ..\packages\ApprovalUtilities.3.0.11\lib\net45\ApprovalUtilities.dll - True - - - ..\packages\ApprovalUtilities.3.0.11\lib\net45\ApprovalUtilities.Net45.dll - True - - - ..\packages\FluentDateTime.1.13.0\lib\NET35\FluentDateTime.dll - True - - - ..\packages\GitTools.Core.1.3.0\lib\net45\GitTools.Core.dll - - - ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll - - - ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll - + + + + + + + + + + + + + + + + + + + - - ..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll - True - - - ..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll - True - - - ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.dll - True - - - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - True - - - ..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll - True - - - ..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll - True - - - ..\packages\ObjectApproval.1.3.0\lib\NET40\ObjectApproval.dll - True - - - ..\packages\Shouldly.2.7.0\lib\net40\Shouldly.dll - True - - - ..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll - True - - - ..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll - True - - - - - - - - - - - - - - + - - Designer - - - - - - - - - - - - - - - - - - - - - - - + + - {BF905F84-382C-440D-92F5-C61108626D8D} - GitVersionCore.Tests - {F9741A0D-B9D7-4557-9A1C-A7252C1071F5} - GitVersionCore - {f7ac0e71-3e9a-4f6d-b986-e004825a48e1} - GitVersionTask - - - - - + - + + - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + \ No newline at end of file From 0547a2f2618ee7b9b0cea4c60568fb225b7f61ca Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 18 Aug 2017 00:27:00 +0100 Subject: [PATCH 11/79] Fixed remaining tests. --- src/GitVersionCore/GitVersionCore.csproj | 4 ++++ .../VersionAssemblyInfoResources/VersionAssemblyInfo.cs | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 9e93056757..870af60c3d 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -62,6 +62,10 @@ bin\Release\GitVersionCore.xml + + + + Library - Properties GitVersionCore.Tests GitVersionCore.Tests - v4.5 - 6 - 512 - - - + + false + false + false + false + false + true + true full false - bin\Debug\ DEBUG;TRACE - prompt - 4 - false full false bin\Release\ TRACE - prompt - 4 - false - true - - ..\packages\FluentDateTime.1.13.0\lib\NET35\FluentDateTime.dll - True - - - ..\packages\GitTools.Core.1.3.0\lib\net45\GitTools.Core.dll - - - ..\packages\GitTools.Testing.1.1.1-beta0001\lib\net4\GitTools.Testing.dll - True - - - ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll - - - ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll - - - - ..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll - True - - - ..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll - True - - - ..\packages\Shouldly.2.7.0\lib\net40\Shouldly.dll - True - + + + + + + + + + + + + + + + - - - ..\packages\TestStack.ConventionTests.3.0.0\lib\net40\TestStack.ConventionTests.dll - True - - - ..\packages\YamlDotNet.4.2.1\lib\net35\YamlDotNet.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + Designer - - Designer - - - {f9741a0d-b9d7-4557-9a1c-a7252c1071f5} - GitVersionCore - + - - - - - - - + - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + \ No newline at end of file diff --git a/src/GitVersionCore.Tests/Mocks/MockQueryableCommitLog.cs b/src/GitVersionCore.Tests/Mocks/MockQueryableCommitLog.cs index d9241619b7..b8a57127ba 100644 --- a/src/GitVersionCore.Tests/Mocks/MockQueryableCommitLog.cs +++ b/src/GitVersionCore.Tests/Mocks/MockQueryableCommitLog.cs @@ -36,14 +36,7 @@ public IEnumerable QueryBy(string path) { throw new NotImplementedException(); } - -#pragma warning disable CS0618 // Type or member is obsolete - public IEnumerable QueryBy(string path, FollowFilter filter) -#pragma warning restore CS0618 // Type or member is obsolete - { - throw new NotImplementedException(); - } - + public Commit FindMergeBase(Commit first, Commit second) { return null; diff --git a/src/GitVersionCore.Tests/app.config b/src/GitVersionCore.Tests/app.config index c7a9384535..2f21c15a6d 100644 --- a/src/GitVersionCore.Tests/app.config +++ b/src/GitVersionCore.Tests/app.config @@ -1,15 +1,15 @@ - + - - + + - - + + - \ No newline at end of file + diff --git a/src/GitVersionCore.Tests/packages.config b/src/GitVersionCore.Tests/packages.config deleted file mode 100644 index b176980283..0000000000 --- a/src/GitVersionCore.Tests/packages.config +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 870af60c3d..51dd440a0e 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -2,13 +2,13 @@ netstandard1.3;net40 - net40 + Library GitVersion GitVersionCore $(SolutionDir)..\build\ - GitVersion + GitVersionCore GitVersion GitTools and Contributors https://github.com/GitTools/GitVersion @@ -71,7 +71,7 @@ See --> - + All @@ -85,14 +85,14 @@ - - - - - + - + + + All + + diff --git a/src/GitVersionCore/StringFormatWith.cs b/src/GitVersionCore/StringFormatWith.cs index a33c1ded82..844e05aaf4 100644 --- a/src/GitVersionCore/StringFormatWith.cs +++ b/src/GitVersionCore/StringFormatWith.cs @@ -58,12 +58,12 @@ static Func CompileDataBinder(Type type, string expr) { body = Expression.PropertyOrField(body, members[i]); } - var method = typeof(Convert).GetMethod("ToString", BindingFlags.Static | BindingFlags.Public, - null, new Type[] { body.Type }, null); + + var staticOrPublic = BindingFlags.Static | BindingFlags.Public; + var method = GetMethodInfo("ToString", staticOrPublic, new Type[] { body.Type }); if (method == null) { - method = typeof(Convert).GetMethod("ToString", BindingFlags.Static | BindingFlags.Public, - null, new Type[] { typeof(object) }, null); + method = GetMethodInfo("ToString", staticOrPublic, new Type[] { typeof(object) }); body = Expression.Call(method, Expression.Convert(body, typeof(object))); } else @@ -74,5 +74,17 @@ static Func CompileDataBinder(Type type, string expr) return Expression.Lambda>(body, param).Compile(); } + private static MethodInfo GetMethodInfo(string name, BindingFlags bindingFlags, Type[] types) + { +#if NETDESKTOP + var methodInfo = typeof(Convert).GetMethod(name, bindingFlags, null, types, null); + return methodInfo; +#else + var type = typeof(Convert); + var methodInfo = typeof(Convert).GetMethod(name, types); + return methodInfo; +#endif + //throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/src/GitVersionExe.Tests/AssemblyInfoFileUpdateTests.cs b/src/GitVersionExe.Tests/AssemblyInfoFileUpdateTests.cs index 9b7e035dca..fd7bfb371a 100644 --- a/src/GitVersionExe.Tests/AssemblyInfoFileUpdateTests.cs +++ b/src/GitVersionExe.Tests/AssemblyInfoFileUpdateTests.cs @@ -4,588 +4,591 @@ using System.Linq; using GitVersion; using GitVersion.Helpers; -using GitVersionCore.Tests; using NSubstitute; using NUnit.Framework; using Shouldly; -[TestFixture] -public class AssemblyInfoFileUpdateTests +namespace GitVersionExe.Tests { - [SetUp] - public void SetLoggers() + [TestFixture] + public class AssemblyInfoFileUpdateTests { - ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute(); - } + [SetUp] + public void SetLoggers() + { + ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute(); + } - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) - { - var fileSystem = new TestFileSystem(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = new HashSet + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) { - "VersionAssemblyInfo." + fileExtension - }; - var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - var arguments = new Arguments + var fileSystem = new TestFileSystem(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = new HashSet { - EnsureAssemblyInfo = true, - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = assemblyInfoFile + "VersionAssemblyInfo." + fileExtension }; + var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var arguments = new Arguments + { + EnsureAssemblyInfo = true, + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = assemblyInfoFile + }; - using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) - { - fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) + { + fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + } } - } - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) - { - var fileSystem = new TestFileSystem(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = new HashSet + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) { - Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension) - }; - var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - var arguments = new Arguments + var fileSystem = new TestFileSystem(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = new HashSet { - EnsureAssemblyInfo = true, - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = assemblyInfoFile + Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension) }; + var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var arguments = new Arguments + { + EnsureAssemblyInfo = true, + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = assemblyInfoFile + }; - using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) - { - fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) + { + fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + } } - } - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) - { - var fileSystem = new TestFileSystem(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = new HashSet + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) + { + var fileSystem = new TestFileSystem(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = new HashSet { "AssemblyInfo." + fileExtension, Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension) }; - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - var arguments = new Arguments - { - EnsureAssemblyInfo = true, - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = assemblyInfoFile - }; + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var arguments = new Arguments + { + EnsureAssemblyInfo = true, + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = assemblyInfoFile + }; - using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) - { - foreach (var item in assemblyInfoFile) + using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) { - var fullPath = Path.Combine(workingDir, item); - fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + foreach (var item in assemblyInfoFile) + { + var fullPath = Path.Combine(workingDir, item); + fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + } } } - } - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - public void ShouldNotCreateAssemblyInfoFileWhenNotExistsAndNotEnsureAssemblyInfo(string fileExtension) - { - var fileSystem = new TestFileSystem(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = new HashSet + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + public void ShouldNotCreateAssemblyInfoFileWhenNotExistsAndNotEnsureAssemblyInfo(string fileExtension) { - "VersionAssemblyInfo." + fileExtension - }; - var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - var arguments = new Arguments + var fileSystem = new TestFileSystem(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = new HashSet { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = assemblyInfoFile + "VersionAssemblyInfo." + fileExtension }; + var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var arguments = new Arguments + { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = assemblyInfoFile + }; - using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) - { - fileSystem.Exists(fullPath).ShouldBeFalse(); + using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) + { + fileSystem.Exists(fullPath).ShouldBeFalse(); + } } - } - [Test] - public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssemblyInfo() - { - var fileSystem = Substitute.For(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = new HashSet + [Test] + public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssemblyInfo() { - "VersionAssemblyInfo.js" - }; - var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - var arguments = new Arguments + var fileSystem = Substitute.For(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = new HashSet { - EnsureAssemblyInfo = true, - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = assemblyInfoFile + "VersionAssemblyInfo.js" }; + var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var arguments = new Arguments + { + EnsureAssemblyInfo = true, + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = assemblyInfoFile + }; - using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) - { - fileSystem.Received(0).WriteAllText(fullPath, Arg.Any()); + using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) + { + fileSystem.Received(0).WriteAllText(fullPath, Arg.Any()); + } } - } - [Test] - public void ShouldStartSearchFromWorkingDirectory() - { - var fileSystem = Substitute.For(); - var workingDir = Path.GetTempPath(); - - var config = new TestEffectiveConfiguration(); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), config, false); - var arguments = new Arguments - { - UpdateAssemblyInfo = true - }; - using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) + [Test] + public void ShouldStartSearchFromWorkingDirectory() { - fileSystem.Received().DirectoryGetFiles(Arg.Is(workingDir), Arg.Any(), Arg.Any()); - } - } - - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersion(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + var fileSystem = Substitute.For(); + var workingDir = Path.GetTempPath(); - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => - { - var args = new Arguments + var config = new TestEffectiveConfiguration(); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), config, false); + var arguments = new Arguments { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet - { - "AssemblyInfo." + fileExtension - } + UpdateAssemblyInfo = true }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); + fileSystem.Received().DirectoryGetFiles(Arg.Is(workingDir), Arg.Any(), Arg.Any()); } - }); - } - - - [TestCase("cs", "[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]")] - [TestCase("vb", "")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.None, verify: (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersion(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { "AssemblyInfo." + fileExtension + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; + }); + } + + + [TestCase("cs", "[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]")] + [TestCase("vb", "")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.None, verify: (fileSystem, variables) => { - assemblyFileContent = fileSystem.ReadAllText(fileName); - assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); - } - }); - } + var args = new Arguments + { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { + "AssemblyInfo." + fileExtension + } + }; - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersionInRelativePath(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo." + fileExtension); + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + assemblyFileContent = fileSystem.ReadAllText(fileName); + assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + } + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersionInRelativePath(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension) + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - - [TestCase("cs", "[assembly: AssemblyVersion ( \"1.0.0.0\") ]\r\n[assembly: AssemblyInformationalVersion\t(\t\"1.0.0.0\"\t)]\r\n[assembly: AssemblyFileVersion\r\n(\r\n\"1.0.0.0\"\r\n)]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - public void ShouldReplaceAssemblyVersionInRelativePathWithWhiteSpace(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo." + fileExtension); + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion ( \"1.0.0.0\") ]\r\n[assembly: AssemblyInformationalVersion\t(\t\"1.0.0.0\"\t)]\r\n[assembly: AssemblyFileVersion\r\n(\r\n\"1.0.0.0\"\r\n)]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + public void ShouldReplaceAssemblyVersionInRelativePathWithWhiteSpace(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension) + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.*\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersionWithStar(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.*\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersionWithStar(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { "AssemblyInfo." + fileExtension + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - - [TestCase("cs", "[assembly: AssemblyVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersionAttribute(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersionWithAtttributeSuffix(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersionAttribute(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersionWithAtttributeSuffix(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { "AssemblyInfo." + fileExtension + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + !s.Contains(@"AssemblyVersionAttribute(""1.0.0.0"")") && + !s.Contains(@"AssemblyInformationalVersionAttribute(""1.0.0.0"")") && + !s.Contains(@"AssemblyFileVersionAttribute(""1.0.0.0"")") && + s.Contains(@"AssemblyVersion(""2.3.1.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - !s.Contains(@"AssemblyVersionAttribute(""1.0.0.0"")") && - !s.Contains(@"AssemblyInformationalVersionAttribute(""1.0.0.0"")") && - !s.Contains(@"AssemblyFileVersionAttribute(""1.0.0.0"")") && - s.Contains(@"AssemblyVersion(""2.3.1.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - public void ShouldAddAssemblyVersionIfMissingFromInfoFile(string fileExtension) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + }); + } - VerifyAssemblyInfoFile("", fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + public void ShouldAddAssemblyVersionIfMissingFromInfoFile(string fileExtension) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile("", fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { "AssemblyInfo." + fileExtension + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - - [TestCase("cs", "[assembly: AssemblyVersion(\"2.2.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"2.2.0+5.Branch.foo.Sha.hash\")]\r\n[assembly: AssemblyFileVersion(\"2.2.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAlreadySubstitutedValues(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion(\"2.2.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"2.2.0+5.Branch.foo.Sha.hash\")]\r\n[assembly: AssemblyFileVersion(\"2.2.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAlreadySubstitutedValues(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { "AssemblyInfo." + fileExtension + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - + }); + } - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersionWhenCreatingAssemblyVersionFileAndEnsureAssemblyInfo(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); - VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersionWhenCreatingAssemblyVersionFileAndEnsureAssemblyInfo(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => { - EnsureAssemblyInfo = true, - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + EnsureAssemblyInfo = true, + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { "AssemblyInfo." + fileExtension + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.1.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.1.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - - [TestCase("cs", "[assembly: AssemblyVersion (AssemblyInfo.Version) ]\r\n[assembly: AssemblyInformationalVersion(AssemblyInfo.InformationalVersion)]\r\n[assembly: AssemblyFileVersion(AssemblyInfo.FileVersion)]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - public void ShouldReplaceAssemblyVersionInRelativePathWithVariables(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo." + fileExtension); + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion (AssemblyInfo.Version) ]\r\n[assembly: AssemblyInformationalVersion(AssemblyInfo.InformationalVersion)]\r\n[assembly: AssemblyFileVersion(AssemblyInfo.FileVersion)]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + public void ShouldReplaceAssemblyVersionInRelativePathWithVariables(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension) + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - - [TestCase("cs", "[assembly: AssemblyVersion ( AssemblyInfo.VersionInfo ) ]\r\n[assembly: AssemblyInformationalVersion\t(\tAssemblyInfo.InformationalVersion\t)]\r\n[assembly: AssemblyFileVersion\r\n(\r\nAssemblyInfo.FileVersion\r\n)]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - public void ShouldReplaceAssemblyVersionInRelativePathWithVariablesAndWhiteSpace(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo." + fileExtension); + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion ( AssemblyInfo.VersionInfo ) ]\r\n[assembly: AssemblyInformationalVersion\t(\tAssemblyInfo.InformationalVersion\t)]\r\n[assembly: AssemblyFileVersion\r\n(\r\nAssemblyInfo.FileVersion\r\n)]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + public void ShouldReplaceAssemblyVersionInRelativePathWithVariablesAndWhiteSpace(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "Project", "src", "Properties", "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension) + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } - - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]")] - [TestCase("vb", "\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]")] + [TestCase("vb", "\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { "AssemblyInfo." + fileExtension - } - }; - - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - assemblyFileContent = fileSystem.ReadAllText(fileName); - assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); - } - }); - } + } + }; + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + assemblyFileContent = fileSystem.ReadAllText(fileName); + assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + } + }); + } - [TestCase("cs", "[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]")] - [TestCase("vb", "")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.None, verify: (fileSystem, variables) => + [TestCase("cs", "[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]")] + [TestCase("vb", "")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone(string fileExtension, string assemblyFileContent) { - var args = new Arguments + var workingDir = Path.GetTempPath(); + var fileName = Path.Combine(workingDir, "AssemblyInfo." + fileExtension); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.None, verify: (fileSystem, variables) => { - UpdateAssemblyInfo = true, - UpdateAssemblyInfoFileName = new HashSet + var args = new Arguments { + UpdateAssemblyInfo = true, + UpdateAssemblyInfoFileName = new HashSet + { "AssemblyInfo." + fileExtension - } - }; + } + }; - using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) - { - assemblyFileContent = fileSystem.ReadAllText(fileName); - assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); - } - }); - } + using (new AssemblyInfoFileUpdate(args, workingDir, variables, fileSystem)) + { + assemblyFileContent = fileSystem.ReadAllText(fileName); + assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + } + }); + } - private static void VerifyAssemblyInfoFile( - string assemblyFileContent, - string fileName, - AssemblyVersioningScheme versioningScheme = AssemblyVersioningScheme.MajorMinorPatch, - Action verify = null) - { - var fileSystem = Substitute.For(); - var version = new SemanticVersion + private static void VerifyAssemblyInfoFile( + string assemblyFileContent, + string fileName, + AssemblyVersioningScheme versioningScheme = AssemblyVersioningScheme.MajorMinorPatch, + Action verify = null) { - BuildMetaData = new SemanticVersionBuildMetaData(3, "foo", "hash", DateTimeOffset.Now), - Major = 2, - Minor = 3, - Patch = 1 - }; + var fileSystem = Substitute.For(); + var version = new SemanticVersion + { + BuildMetaData = new SemanticVersionBuildMetaData(3, "foo", "hash", DateTimeOffset.Now), + Major = 2, + Minor = 3, + Patch = 1 + }; - fileSystem.Exists(fileName).Returns(true); - fileSystem.ReadAllText(fileName).Returns(assemblyFileContent); - fileSystem.When(f => f.WriteAllText(fileName, Arg.Any())).Do(c => - { - assemblyFileContent = c.ArgAt(1); + fileSystem.Exists(fileName).Returns(true); fileSystem.ReadAllText(fileName).Returns(assemblyFileContent); - }); + fileSystem.When(f => f.WriteAllText(fileName, Arg.Any())).Do(c => + { + assemblyFileContent = c.ArgAt(1); + fileSystem.ReadAllText(fileName).Returns(assemblyFileContent); + }); - var config = new TestEffectiveConfiguration(assemblyVersioningScheme: versioningScheme); - var variables = VariableProvider.GetVariablesFor(version, config, false); + var config = new TestEffectiveConfiguration(assemblyVersioningScheme: versioningScheme); + var variables = VariableProvider.GetVariablesFor(version, config, false); - verify(fileSystem, variables); + verify(fileSystem, variables); + } } + } \ No newline at end of file diff --git a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj index c97ddcbf0b..a3cf45cb21 100644 --- a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj +++ b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj @@ -1,21 +1,23 @@ - - - - + Debug AnyCPU - {75C2BE85-1DAF-4E34-8305-B17AFAA982A6} + Library - Properties + GitVersionExe.Tests GitVersionExe.Tests - v4.5 - 512 - 6 - - + net452 + + false + false + false + false + false + true + + true full @@ -35,47 +37,17 @@ true - - ..\packages\GitTools.Core.1.3.0\lib\net45\GitTools.Core.dll - - - ..\packages\GitTools.Testing.1.1.1-beta0001\lib\net4\GitTools.Testing.dll - True - - - ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll - - - ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll - - - ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll - True - - - ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Mdb.dll - True - - - ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Pdb.dll - True - - - ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Rocks.dll - True - - - ..\packages\NSubstitute.1.10.0.0\lib\net45\NSubstitute.dll - True - - - ..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll - True - - - ..\packages\Shouldly.2.7.0\lib\net40\Shouldly.dll - True - + + + + + + + + + + + @@ -86,68 +58,19 @@ - - - {BF905F84-382C-440D-92F5-C61108626D8D} - GitVersionCore.Tests - - - {F9741A0D-B9D7-4557-9A1C-A7252C1071F5} - GitVersionCore - - - {c3578a7b-09a6-4444-9383-0deafa4958bd} - GitVersionExe - + + + - - Designer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + \ No newline at end of file diff --git a/src/GitVersionExe.Tests/Helpers/DirectoryHelper.cs b/src/GitVersionExe.Tests/Helpers/DirectoryHelper.cs new file mode 100644 index 0000000000..0b34a20605 --- /dev/null +++ b/src/GitVersionExe.Tests/Helpers/DirectoryHelper.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +public static class DirectoryHelper +{ + static Dictionary toRename = new Dictionary + { + {"gitted", ".git"}, + {"gitmodules", ".gitmodules"}, + }; + + public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target) + { + // From http://stackoverflow.com/questions/58744/best-way-to-copy-the-entire-contents-of-a-directory-in-c/58779#58779 + + foreach (var dir in source.GetDirectories()) + { + CopyFilesRecursively(dir, target.CreateSubdirectory(Rename(dir.Name))); + } + foreach (var file in source.GetFiles()) + { + file.CopyTo(Path.Combine(target.FullName, Rename(file.Name))); + } + } + + static string Rename(string name) + { + return toRename.ContainsKey(name) ? toRename[name] : name; + } + + public static void DeleteSubDirectories(string parentPath) + { + var dirs = Directory.GetDirectories(parentPath); + foreach (var dir in dirs) + { + DeleteDirectory(dir); + } + } + + public static void DeleteDirectory(string directoryPath) + { + // From http://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true/329502#329502 + + if (!Directory.Exists(directoryPath)) + { + Trace.WriteLine( + string.Format("Directory '{0}' is missing and can't be removed.", + directoryPath)); + + return; + } + + var files = Directory.GetFiles(directoryPath); + var dirs = Directory.GetDirectories(directoryPath); + + foreach (var file in files) + { + File.SetAttributes(file, FileAttributes.Normal); + File.Delete(file); + } + + foreach (var dir in dirs) + { + DeleteDirectory(dir); + } + + File.SetAttributes(directoryPath, FileAttributes.Normal); + try + { + Directory.Delete(directoryPath, false); + } + catch (IOException) + { + Trace.WriteLine(string.Format("{0}The directory '{1}' could not be deleted!" + + "{0}Most of the time, this is due to an external process accessing the files in the temporary repositories created during the test runs, and keeping a handle on the directory, thus preventing the deletion of those files." + + "{0}Known and common causes include:" + + "{0}- Windows Search Indexer (go to the Indexing Options, in the Windows Control Panel, and exclude the bin folder of LibGit2Sharp.Tests)" + + "{0}- Antivirus (exclude the bin folder of LibGit2Sharp.Tests from the paths scanned by your real-time antivirus){0}", + Environment.NewLine, Path.GetFullPath(directoryPath))); + } + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/Helpers/PathHelper.cs b/src/GitVersionExe.Tests/Helpers/PathHelper.cs new file mode 100644 index 0000000000..b73edfeda1 --- /dev/null +++ b/src/GitVersionExe.Tests/Helpers/PathHelper.cs @@ -0,0 +1,16 @@ +using System; +using System.IO; +using System.Reflection; + +public static class PathHelper +{ + public static string GetCurrentDirectory() + { + return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + + public static string GetTempPath() + { + return Path.Combine(GetCurrentDirectory(), "TestRepositories", Guid.NewGuid().ToString()); + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/Helpers/TestFileSystem.cs b/src/GitVersionExe.Tests/Helpers/TestFileSystem.cs new file mode 100644 index 0000000000..217957b015 --- /dev/null +++ b/src/GitVersionExe.Tests/Helpers/TestFileSystem.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using GitVersion.Helpers; + +public class TestFileSystem : IFileSystem +{ + Dictionary fileSystem = new Dictionary(); + + public void Copy(string @from, string to, bool overwrite) + { + if (fileSystem.ContainsKey(to)) + { + if (overwrite) + fileSystem.Remove(to); + else + throw new IOException("File already exists"); + } + + byte[] source; + if (!fileSystem.TryGetValue(from, out source)) + throw new FileNotFoundException(string.Format("The source file '{0}' was not found", from), from); + + fileSystem.Add(to, source); + } + + public void Move(string @from, string to) + { + Copy(from, to, false); + fileSystem.Remove(from); + } + + public bool Exists(string file) + { + return fileSystem.ContainsKey(file); + } + + public void Delete(string path) + { + fileSystem.Remove(path); + } + + public string ReadAllText(string path) + { + byte[] content; + if (!fileSystem.TryGetValue(path, out content)) + throw new FileNotFoundException(string.Format("The file '{0}' was not found", path), path); + + var encoding = EncodingHelper.DetectEncoding(content) ?? Encoding.UTF8; + return encoding.GetString(content); + } + + public void WriteAllText(string file, string fileContents) + { + var encoding = fileSystem.ContainsKey(file) + ? EncodingHelper.DetectEncoding(fileSystem[file]) ?? Encoding.UTF8 + : Encoding.UTF8; + WriteAllText(file, fileContents, encoding); + } + + public void WriteAllText(string file, string fileContents, Encoding encoding) + { + fileSystem[file] = encoding.GetBytes(fileContents); + } + + public IEnumerable DirectoryGetFiles(string directory, string searchPattern, SearchOption searchOption) + { + throw new NotImplementedException(); + } + + public Stream OpenWrite(string path) + { + return new TestStream(path, this); + } + + public Stream OpenRead(string path) + { + if (fileSystem.ContainsKey(path)) + { + var content = fileSystem[path]; + return new MemoryStream(content); + } + + throw new FileNotFoundException("File not found.", path); + } + + public void CreateDirectory(string path) + { + if (fileSystem.ContainsKey(path)) + { + fileSystem[path] = new byte[0]; + } + else + { + fileSystem.Add(path, new byte[0]); + } + } + + public bool DirectoryExists(string path) + { + return fileSystem.ContainsKey(path); + } + + public long GetLastDirectoryWrite(string path) + { + return 1; + } + + public bool PathsEqual(string path, string otherPath) + { + return path == otherPath; + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/Helpers/TestStream.cs b/src/GitVersionExe.Tests/Helpers/TestStream.cs new file mode 100644 index 0000000000..ce23cfa7ec --- /dev/null +++ b/src/GitVersionExe.Tests/Helpers/TestStream.cs @@ -0,0 +1,76 @@ +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +public class TestStream : Stream +{ + readonly string path; + readonly TestFileSystem testFileSystem; + MemoryStream underlying = new MemoryStream(); + + public TestStream(string path, TestFileSystem testFileSystem) + { + this.path = path; + this.testFileSystem = testFileSystem; + } + + protected override void Dispose(bool disposing) + { + Flush(); + base.Dispose(disposing); + } + + public override void Flush() + { + underlying.Position = 0; + var readToEnd = new StreamReader(underlying).ReadToEnd(); + testFileSystem.WriteAllText(path, readToEnd); + } + + public override long Seek(long offset, SeekOrigin origin) + { + return underlying.Seek(offset, origin); + } + + public override void SetLength(long value) + { + underlying.SetLength(value); + } + + public override int Read(byte[] buffer, int offset, int count) + { + return underlying.Read(buffer, offset, count); + } + + public override void Write(byte[] buffer, int offset, int count) + { + underlying.Write(buffer, offset, count); + } + + public override void WriteByte(byte value) + { + base.WriteByte(value); + } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return base.BeginWrite(buffer, offset, count, callback, state); + } + + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return base.WriteAsync(buffer, offset, count, cancellationToken); + } + + public override bool CanRead { get { return underlying.CanRead; } } + public override bool CanSeek { get { return underlying.CanSeek; } } + public override bool CanWrite { get { return underlying.CanWrite; } } + public override long Length { get { return underlying.Length; } } + + public override long Position + { + get { return underlying.Position; } + set { underlying.Position = value; } + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/TestEffectiveConfiguration.cs b/src/GitVersionExe.Tests/TestEffectiveConfiguration.cs new file mode 100644 index 0000000000..3201f26e0c --- /dev/null +++ b/src/GitVersionExe.Tests/TestEffectiveConfiguration.cs @@ -0,0 +1,44 @@ +namespace GitVersionExe.Tests +{ + using GitVersion; + using GitVersion.VersionFilters; + using System.Collections.Generic; + using System.Linq; + + public class TestEffectiveConfiguration : EffectiveConfiguration + { + public TestEffectiveConfiguration( + AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch, + AssemblyFileVersioningScheme assemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch, + string assemblyInformationalFormat = null, + VersioningMode versioningMode = VersioningMode.ContinuousDelivery, + string gitTagPrefix = "v", + string tag = "", + string nextVersion = null, + string branchPrefixToTrim = "", + bool preventIncrementForMergedBranchVersion = false, + string tagNumberPattern = null, + string continuousDeploymentFallbackTag = "ci", + bool trackMergeTarget = false, + string majorMessage = null, + string minorMessage = null, + string patchMessage = null, + string noBumpMessage = null, + CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled, + int legacySemVerPadding = 4, + int buildMetaDataPadding = 4, + int commitsSinceVersionSourcePadding = 4, + IEnumerable versionFilters = null, + bool tracksReleaseBranches = false, + bool isRelease = false) : + base(assemblyVersioningScheme, assemblyFileVersioningScheme, assemblyInformationalFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch, + branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag, + trackMergeTarget, + majorMessage, minorMessage, patchMessage, noBumpMessage, + commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding, + versionFilters ?? Enumerable.Empty(), + tracksReleaseBranches, isRelease) + { + } + } +} \ No newline at end of file diff --git a/src/GitVersionExe.Tests/app.config b/src/GitVersionExe.Tests/app.config index c7a9384535..2f21c15a6d 100644 --- a/src/GitVersionExe.Tests/app.config +++ b/src/GitVersionExe.Tests/app.config @@ -1,15 +1,15 @@ - + - - + + - - + + - \ No newline at end of file + diff --git a/src/GitVersionExe.Tests/packages.config b/src/GitVersionExe.Tests/packages.config deleted file mode 100644 index e832e5bd94..0000000000 --- a/src/GitVersionExe.Tests/packages.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index 8374af9782..7d21b4c679 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -1,31 +1,29 @@ - - - + Debug AnyCPU - 8.0.30703 - 2.0 - {C3578A7B-09A6-4444-9383-0DEAFA4958BD} + Exe GitVersion GitVersion - v4.0 - 6 - 512 + net40 $(SolutionDir)..\build\ - - + + false + false + false + false + false + true + true full false bin\Debug\ DEBUG;TRACE - prompt - 4 - false + bin\Debug\GitVersion.xml 1591 @@ -34,39 +32,27 @@ true bin\Release\ TRACE - prompt - 4 - false + bin\Release\GitVersion.xml 1591 - - - ..\packages\GitTools.Core.1.3.0\lib\net40\GitTools.Core.dll - - - ..\packages\JetBrains.Annotations.10.4.0\lib\net\JetBrains.Annotations.dll - - - ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll - + + + + + + + + + + - - - - - - - - - - - + @@ -87,9 +73,6 @@ - - Designer - @@ -98,12 +81,9 @@ - - {f9741a0d-b9d7-4557-9a1c-a7252c1071f5} - GitVersionCore - + - + @@ -208,14 +188,5 @@ - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - + \ No newline at end of file diff --git a/src/GitVersionExe/app.config b/src/GitVersionExe/app.config index b57ccf84c3..87ccfc557c 100644 --- a/src/GitVersionExe/app.config +++ b/src/GitVersionExe/app.config @@ -4,7 +4,7 @@ - + diff --git a/src/GitVersionExe/packages.config b/src/GitVersionExe/packages.config deleted file mode 100644 index 7341ae9b26..0000000000 --- a/src/GitVersionExe/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index f1249abb88..e811943eed 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -7,7 +7,7 @@ GitVersionTask.Tests GitVersionTask.Tests - net45 + net452 false false @@ -41,19 +41,20 @@ true + - + - + - + @@ -81,9 +82,7 @@ - - - + diff --git a/src/GitVersionTask.Tests/Helpers/DirectoryHelper.cs b/src/GitVersionTask.Tests/Helpers/DirectoryHelper.cs new file mode 100644 index 0000000000..0b34a20605 --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/DirectoryHelper.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +public static class DirectoryHelper +{ + static Dictionary toRename = new Dictionary + { + {"gitted", ".git"}, + {"gitmodules", ".gitmodules"}, + }; + + public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target) + { + // From http://stackoverflow.com/questions/58744/best-way-to-copy-the-entire-contents-of-a-directory-in-c/58779#58779 + + foreach (var dir in source.GetDirectories()) + { + CopyFilesRecursively(dir, target.CreateSubdirectory(Rename(dir.Name))); + } + foreach (var file in source.GetFiles()) + { + file.CopyTo(Path.Combine(target.FullName, Rename(file.Name))); + } + } + + static string Rename(string name) + { + return toRename.ContainsKey(name) ? toRename[name] : name; + } + + public static void DeleteSubDirectories(string parentPath) + { + var dirs = Directory.GetDirectories(parentPath); + foreach (var dir in dirs) + { + DeleteDirectory(dir); + } + } + + public static void DeleteDirectory(string directoryPath) + { + // From http://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true/329502#329502 + + if (!Directory.Exists(directoryPath)) + { + Trace.WriteLine( + string.Format("Directory '{0}' is missing and can't be removed.", + directoryPath)); + + return; + } + + var files = Directory.GetFiles(directoryPath); + var dirs = Directory.GetDirectories(directoryPath); + + foreach (var file in files) + { + File.SetAttributes(file, FileAttributes.Normal); + File.Delete(file); + } + + foreach (var dir in dirs) + { + DeleteDirectory(dir); + } + + File.SetAttributes(directoryPath, FileAttributes.Normal); + try + { + Directory.Delete(directoryPath, false); + } + catch (IOException) + { + Trace.WriteLine(string.Format("{0}The directory '{1}' could not be deleted!" + + "{0}Most of the time, this is due to an external process accessing the files in the temporary repositories created during the test runs, and keeping a handle on the directory, thus preventing the deletion of those files." + + "{0}Known and common causes include:" + + "{0}- Windows Search Indexer (go to the Indexing Options, in the Windows Control Panel, and exclude the bin folder of LibGit2Sharp.Tests)" + + "{0}- Antivirus (exclude the bin folder of LibGit2Sharp.Tests from the paths scanned by your real-time antivirus){0}", + Environment.NewLine, Path.GetFullPath(directoryPath))); + } + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/Helpers/PathHelper.cs b/src/GitVersionTask.Tests/Helpers/PathHelper.cs new file mode 100644 index 0000000000..b73edfeda1 --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/PathHelper.cs @@ -0,0 +1,16 @@ +using System; +using System.IO; +using System.Reflection; + +public static class PathHelper +{ + public static string GetCurrentDirectory() + { + return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + + public static string GetTempPath() + { + return Path.Combine(GetCurrentDirectory(), "TestRepositories", Guid.NewGuid().ToString()); + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/Helpers/TestEffectiveConfiguration.cs b/src/GitVersionTask.Tests/Helpers/TestEffectiveConfiguration.cs new file mode 100644 index 0000000000..3256c2d90e --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/TestEffectiveConfiguration.cs @@ -0,0 +1,44 @@ +namespace GitVersionCore.Tests +{ + using GitVersion; + using GitVersion.VersionFilters; + using System.Collections.Generic; + using System.Linq; + + public class TestEffectiveConfiguration : EffectiveConfiguration + { + public TestEffectiveConfiguration( + AssemblyVersioningScheme assemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch, + AssemblyFileVersioningScheme assemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch, + string assemblyInformationalFormat = null, + VersioningMode versioningMode = VersioningMode.ContinuousDelivery, + string gitTagPrefix = "v", + string tag = "", + string nextVersion = null, + string branchPrefixToTrim = "", + bool preventIncrementForMergedBranchVersion = false, + string tagNumberPattern = null, + string continuousDeploymentFallbackTag = "ci", + bool trackMergeTarget = false, + string majorMessage = null, + string minorMessage = null, + string patchMessage = null, + string noBumpMessage = null, + CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled, + int legacySemVerPadding = 4, + int buildMetaDataPadding = 4, + int commitsSinceVersionSourcePadding = 4, + IEnumerable versionFilters = null, + bool tracksReleaseBranches = false, + bool isRelease = false) : + base(assemblyVersioningScheme, assemblyFileVersioningScheme, assemblyInformationalFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch, + branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag, + trackMergeTarget, + majorMessage, minorMessage, patchMessage, noBumpMessage, + commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding, + versionFilters ?? Enumerable.Empty(), + tracksReleaseBranches, isRelease) + { + } + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/Helpers/TestFileSystem.cs b/src/GitVersionTask.Tests/Helpers/TestFileSystem.cs new file mode 100644 index 0000000000..217957b015 --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/TestFileSystem.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using GitVersion.Helpers; + +public class TestFileSystem : IFileSystem +{ + Dictionary fileSystem = new Dictionary(); + + public void Copy(string @from, string to, bool overwrite) + { + if (fileSystem.ContainsKey(to)) + { + if (overwrite) + fileSystem.Remove(to); + else + throw new IOException("File already exists"); + } + + byte[] source; + if (!fileSystem.TryGetValue(from, out source)) + throw new FileNotFoundException(string.Format("The source file '{0}' was not found", from), from); + + fileSystem.Add(to, source); + } + + public void Move(string @from, string to) + { + Copy(from, to, false); + fileSystem.Remove(from); + } + + public bool Exists(string file) + { + return fileSystem.ContainsKey(file); + } + + public void Delete(string path) + { + fileSystem.Remove(path); + } + + public string ReadAllText(string path) + { + byte[] content; + if (!fileSystem.TryGetValue(path, out content)) + throw new FileNotFoundException(string.Format("The file '{0}' was not found", path), path); + + var encoding = EncodingHelper.DetectEncoding(content) ?? Encoding.UTF8; + return encoding.GetString(content); + } + + public void WriteAllText(string file, string fileContents) + { + var encoding = fileSystem.ContainsKey(file) + ? EncodingHelper.DetectEncoding(fileSystem[file]) ?? Encoding.UTF8 + : Encoding.UTF8; + WriteAllText(file, fileContents, encoding); + } + + public void WriteAllText(string file, string fileContents, Encoding encoding) + { + fileSystem[file] = encoding.GetBytes(fileContents); + } + + public IEnumerable DirectoryGetFiles(string directory, string searchPattern, SearchOption searchOption) + { + throw new NotImplementedException(); + } + + public Stream OpenWrite(string path) + { + return new TestStream(path, this); + } + + public Stream OpenRead(string path) + { + if (fileSystem.ContainsKey(path)) + { + var content = fileSystem[path]; + return new MemoryStream(content); + } + + throw new FileNotFoundException("File not found.", path); + } + + public void CreateDirectory(string path) + { + if (fileSystem.ContainsKey(path)) + { + fileSystem[path] = new byte[0]; + } + else + { + fileSystem.Add(path, new byte[0]); + } + } + + public bool DirectoryExists(string path) + { + return fileSystem.ContainsKey(path); + } + + public long GetLastDirectoryWrite(string path) + { + return 1; + } + + public bool PathsEqual(string path, string otherPath) + { + return path == otherPath; + } +} \ No newline at end of file diff --git a/src/GitVersionTask.Tests/Helpers/TestStream.cs b/src/GitVersionTask.Tests/Helpers/TestStream.cs new file mode 100644 index 0000000000..ce23cfa7ec --- /dev/null +++ b/src/GitVersionTask.Tests/Helpers/TestStream.cs @@ -0,0 +1,76 @@ +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +public class TestStream : Stream +{ + readonly string path; + readonly TestFileSystem testFileSystem; + MemoryStream underlying = new MemoryStream(); + + public TestStream(string path, TestFileSystem testFileSystem) + { + this.path = path; + this.testFileSystem = testFileSystem; + } + + protected override void Dispose(bool disposing) + { + Flush(); + base.Dispose(disposing); + } + + public override void Flush() + { + underlying.Position = 0; + var readToEnd = new StreamReader(underlying).ReadToEnd(); + testFileSystem.WriteAllText(path, readToEnd); + } + + public override long Seek(long offset, SeekOrigin origin) + { + return underlying.Seek(offset, origin); + } + + public override void SetLength(long value) + { + underlying.SetLength(value); + } + + public override int Read(byte[] buffer, int offset, int count) + { + return underlying.Read(buffer, offset, count); + } + + public override void Write(byte[] buffer, int offset, int count) + { + underlying.Write(buffer, offset, count); + } + + public override void WriteByte(byte value) + { + base.WriteByte(value); + } + + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return base.BeginWrite(buffer, offset, count, callback, state); + } + + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return base.WriteAsync(buffer, offset, count, cancellationToken); + } + + public override bool CanRead { get { return underlying.CanRead; } } + public override bool CanSeek { get { return underlying.CanSeek; } } + public override bool CanWrite { get { return underlying.CanWrite; } } + public override long Length { get { return underlying.Length; } } + + public override long Position + { + get { return underlying.Position; } + set { underlying.Position = value; } + } +} \ No newline at end of file diff --git a/src/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/src/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index 26ec592ffb..390b28b5d3 100644 --- a/src/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/src/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -1,14 +1,12 @@ namespace GitVersionTask { using System; - using System.ComponentModel; using System.IO; using System.Text; - using GitVersion; using GitVersion.Helpers; - using Microsoft.Build.Framework; + using GitTools; // TODO: Consolidate this with GitVersion.AssemblyInfoFileUpdate in GitVersionExe. @asbjornu public class UpdateAssemblyInfo : GitVersionTaskBase diff --git a/src/GitVersionTask/GetVersion.cs b/src/GitVersionTask/GetVersion.cs index c699dd2e0d..cb66e84294 100644 --- a/src/GitVersionTask/GetVersion.cs +++ b/src/GitVersionTask/GetVersion.cs @@ -1,10 +1,11 @@ namespace GitVersionTask { using System; - using System.ComponentModel; using GitVersion; using Microsoft.Build.Framework; + using GitTools; + using System.Reflection; public class GetVersion : GitVersionTaskBase { diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 7caab99524..6780b218af 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -6,8 +6,11 @@ Library GitVersionTask GitVersionTask - net40 + net40;netcoreapp1.0 0.0.1 + + true + NugetAssets\GitVersionTask.nuspec version=$(PackageVersion);configuration=$(Configuration) @@ -38,26 +41,33 @@ - - All - - - All - - + + All - - - All - + All - - All - + + + + + + + + + + + All + + + + 1.6.2 + + @@ -73,11 +83,11 @@ true - build\lib\ + build\net40\lib\ true - build\ + build\net40 @@ -93,12 +103,9 @@ Designer - - Designer - - + Designer diff --git a/src/GitVersionTask/InvalidFileChecker.cs b/src/GitVersionTask/InvalidFileChecker.cs index 8717977ece..4f522c9df8 100644 --- a/src/GitVersionTask/InvalidFileChecker.cs +++ b/src/GitVersionTask/InvalidFileChecker.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Linq; using System.Text.RegularExpressions; using Microsoft.Build.Framework; +using GitTools; public static class InvalidFileChecker { diff --git a/src/GitVersionTask/WriteVersionInfoToBuildLog.cs b/src/GitVersionTask/WriteVersionInfoToBuildLog.cs index 32715053a5..aa4b4c6e1e 100644 --- a/src/GitVersionTask/WriteVersionInfoToBuildLog.cs +++ b/src/GitVersionTask/WriteVersionInfoToBuildLog.cs @@ -2,11 +2,9 @@ { using System; using System.Collections.Generic; - using System.ComponentModel; - using GitVersion; - using Microsoft.Build.Framework; + using GitTools; public class WriteVersionInfoToBuildLog : GitVersionTaskBase { diff --git a/src/GitVersionTask/packages.config b/src/GitVersionTask/packages.config deleted file mode 100644 index bd05c73992..0000000000 --- a/src/GitVersionTask/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file From 589786a17f4c2889d29ff275cfbff9fcf5c21780 Mon Sep 17 00:00:00 2001 From: dazinator Date: Tue, 24 Oct 2017 19:15:48 +0100 Subject: [PATCH 13/79] First attempt at getting GitVersion task to run via UtilPack. --- src/GitVersionTask/GitVersionTask.csproj | 127 ++++++-------- .../NugetAssets/GitVersionTask.nuspec | 36 ---- .../NugetAssets/build/GitVersionTask.targets | 163 ++---------------- .../GitVersionTask.targets | 102 ----------- src/GitVersionTask/app.config | 7 +- 5 files changed, 69 insertions(+), 366 deletions(-) delete mode 100644 src/GitVersionTask/NugetAssets/GitVersionTask.nuspec delete mode 100644 src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 576a90fd8c..dc78b37e93 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -7,18 +7,33 @@ GitVersionTask GitVersionTask net461;netstandard1.5 - 0.0.1 - - - + - - version=$(PackageVersion);configuration=$(Configuration) - GitTools and Contributors + GitVersionTask + GitVersionTask + GitTools and Contributors + https://github.com/GitTools/GitVersion + false + Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer + Stamps an assembly with git information based on SemVer. + Copyright GitTools 2015. + http://www.opensource.org/licenses/mit-license.php + https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png + https://github.com/GitTools/GitVersion/releases + true + build + GitTools and Contributors + $(Authors) - $(AssemblyName) - + $(AssemblyName) + false + false + false + false + false + true + true @@ -36,45 +51,26 @@ 1591 - - - - All - - - All - + + + - - + + + - - - - + + - - - - - - - - + + + All - - 1.6.2 - - - + + All + @@ -83,36 +79,31 @@ - - - true - build\net40\lib\ - - - true - build\net40 - - - - - true - buildMultiTargeting\GitVersionTask.targets - - - true - build\GitVersionTask.targets - - + + Designer + + + + + - - - Designer + + + true + build\%(RecursiveDir)%(FileName)%(Extension) + + + true + buildMultiTargeting\GitVersionTask.targets + + + @@ -121,11 +112,7 @@ - - - + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec deleted file mode 100644 index d94f56d31d..0000000000 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ /dev/null @@ -1,36 +0,0 @@ - - - - GitVersionTask - $version$ - GitVersionTask - GitTools and Contributors - GitTools and Contributors - http://www.opensource.org/licenses/mit-license.php - https://github.com/GitTools/GitVersion - https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png - false - Stamps an assembly with git information based on SemVer. - en-AU - Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer - true - https://github.com/GitTools/GitVersion/releases - - - - - - - - - - - - - - - - - - - diff --git a/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets b/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets index 0f0d549fd9..a097b516f2 100644 --- a/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets +++ b/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets @@ -1,154 +1,13 @@ - - - - True - - - $(MSBuildProjectDirectory)\..\ - $(SolutionDir) - $(MSBuildProjectDirectory) - $(SolutionDir)\GitVersionTask.targets - $(SolutionDir)\GitVersionTask.targets - - $(MSBuildProjectDirectory)\obj\$(Configuration)\ - false - - - false - true - - - false - false - true - - - false - true + - - true - false - - - false - true - - $(MSBuildThisFileDirectory) + + false + true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(GitVersion_FullSemVer) - $(GitVersion_MajorMinorPatch) - $(GitVersion_NuGetPreReleaseTag) - $(GitVersion_PreReleaseTag) - $(GitVersion_NuGetVersion) - $(GitVersion_FullSemVer) - $(GitVersion_InformationalVersion) - $(GitVersion_AssemblySemVer) - $(GitVersion_AssemblySemFileVer) - - - - - - - - False - - - False - - - False - - - - + + + + + + + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets b/src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets deleted file mode 100644 index 1277615b57..0000000000 --- a/src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets +++ /dev/null @@ -1,102 +0,0 @@ - - - - True - - - $(MSBuildProjectDirectory)\..\ - $(SolutionDir) - $(MSBuildProjectDirectory) - $(SolutionDir)\GitVersionTask.targets - $(SolutionDir)\GitVersionTask.targets - - false - - - false - true - - - false - false - true - - - false - true - - false - true - - - true - false - - $(MSBuildThisFileDirectory)..\build\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(GitVersion_FullSemVer) - $(GitVersion_MajorMinorPatch) - $(GitVersion_NuGetPreReleaseTag) - $(GitVersion_PreReleaseTag) - $(GitVersion_NuGetVersion) - $(GitVersion_FullSemVer) - $(GitVersion_InformationalVersion) - $(GitVersion_AssemblySemVer) - $(GitVersion_AssemblySemFileVer) - - - - diff --git a/src/GitVersionTask/app.config b/src/GitVersionTask/app.config index b57ccf84c3..a01b86a142 100644 --- a/src/GitVersionTask/app.config +++ b/src/GitVersionTask/app.config @@ -1,11 +1,6 @@  - - - - - - + \ No newline at end of file From 011441ba134076f1f81a1555a10b4da8c2da125f Mon Sep 17 00:00:00 2001 From: dazinator Date: Tue, 24 Oct 2017 21:01:21 +0100 Subject: [PATCH 14/79] Including all dependencies in task nuget package. --- .../GenerateGitVersionInformation.cs | 2 + src/GitVersionTask/GitVersionTask.csproj | 30 ++++++-------- .../NugetAssets/GitVersionTask.nuspec | 40 +++++++++++++++++++ 3 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 src/GitVersionTask/NugetAssets/GitVersionTask.nuspec diff --git a/src/GitVersionTask/GenerateGitVersionInformation.cs b/src/GitVersionTask/GenerateGitVersionInformation.cs index dc7de6939e..8abaa5a97d 100644 --- a/src/GitVersionTask/GenerateGitVersionInformation.cs +++ b/src/GitVersionTask/GenerateGitVersionInformation.cs @@ -8,6 +8,8 @@ using Microsoft.Build.Framework; using GitTools; + + public class GenerateGitVersionInformation : GitVersionTaskBase { TaskLogger logger; diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index dc78b37e93..57f81fee2e 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -22,7 +22,12 @@ https://github.com/GitTools/GitVersion/releases true build - GitTools and Contributors + GitTools and Contributors + true + NugetAssets\GitVersionTask.nuspec + 0.0.1-alpha-0001 + version=$(PackageVersion);configuration=$(Configuration) + $(Authors) @@ -56,8 +61,12 @@ - - + + All + + + All + @@ -90,20 +99,7 @@ - - - - true - build\%(RecursiveDir)%(FileName)%(Extension) - - - - true - buildMultiTargeting\GitVersionTask.targets - - - - + diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec new file mode 100644 index 0000000000..cbbe0bb76e --- /dev/null +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -0,0 +1,40 @@ + + + + GitVersionTask + 1.0.0 + GitVersionTask + GitTools and Contributors + GitTools and Contributors + false + true + http://www.opensource.org/licenses/mit-license.php + https://github.com/GitTools/GitVersion + https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png + Stamps an assembly with git information based on SemVer. + https://github.com/GitTools/GitVersion/releases + Copyright GitTools 2015. + Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer + + + + + + + + + + + + + + + + \ No newline at end of file From 8ebbc796c253cb16377187081f8d9eec2b303cdc Mon Sep 17 00:00:00 2001 From: dazinator Date: Tue, 31 Oct 2017 23:04:46 +0000 Subject: [PATCH 15/79] Updated util pack to version that handles native assembly resolution on netcore. --- src/GitVersionTask/GitVersionTask.csproj | 4 ++-- src/GitVersionTask/NugetAssets/GitVersionTask.nuspec | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 57f81fee2e..2df11d4a40 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -23,7 +23,7 @@ true build GitTools and Contributors - true + NugetAssets\GitVersionTask.nuspec 0.0.1-alpha-0001 version=$(PackageVersion);configuration=$(Configuration) @@ -69,7 +69,7 @@ - + diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index cbbe0bb76e..b06de95efb 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -17,13 +17,11 @@ Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer - + + + + + $(MSBuildThisFileDirectory)functionality/ + $(GitVersionTaskBuildTools_FunctionalityDir)GitVersionBuild.targets + $(GitVersionTaskBuildTools_FunctionalityDir)GitVersionMultiTargetBuild.targets + $(GitVersionTaskBuildTools_FunctionalityDir)obj/ + + + + $(MSBuildThisFileDirectory)../../../utilpack.nuget.msbuild/2.2.0/build/UtilPack.NuGet.MSBuild.props + $([System.IO.Path]::GetFullPath('$(UtilPackNuGetMSBuildPropsPath)')) + + + + + + true + + + + + .NETFramework + 4.6.1 + + + $(UtilPackTaskFactoryParametersXML) + true + GitVersionTask.dll + + + + + + + + + + \ No newline at end of file From 7118c19f7930d55fda8753629cd1e1f6cd7a65c3 Mon Sep 17 00:00:00 2001 From: dazinator Date: Tue, 31 Oct 2017 23:32:02 +0000 Subject: [PATCH 18/79] Added missing targets and props files. --- .../functionality/GitVersionBuild.targets | 104 ++++++++++++++++++ .../functionality/GitVersionCommon.props | 74 +++++++++++++ .../GitVersionMultiTargetBuild.targets | 53 +++++++++ 3 files changed, 231 insertions(+) create mode 100644 src/GitVersionTask/NugetAssets/build/functionality/GitVersionBuild.targets create mode 100644 src/GitVersionTask/NugetAssets/build/functionality/GitVersionCommon.props create mode 100644 src/GitVersionTask/NugetAssets/build/functionality/GitVersionMultiTargetBuild.targets diff --git a/src/GitVersionTask/NugetAssets/build/functionality/GitVersionBuild.targets b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionBuild.targets new file mode 100644 index 0000000000..95d8e40022 --- /dev/null +++ b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionBuild.targets @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(GitVersion_FullSemVer) + $(GitVersion_MajorMinorPatch) + $(GitVersion_NuGetPreReleaseTag) + $(GitVersion_PreReleaseTag) + $(GitVersion_NuGetVersion) + $(GitVersion_FullSemVer) + $(GitVersion_InformationalVersion) + $(GitVersion_AssemblySemVer) + $(GitVersion_AssemblySemFileVer) + + + + + + + + False + + + False + + + False + + + + diff --git a/src/GitVersionTask/NugetAssets/build/functionality/GitVersionCommon.props b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionCommon.props new file mode 100644 index 0000000000..1cdf0b2053 --- /dev/null +++ b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionCommon.props @@ -0,0 +1,74 @@ + + + + $(MSBuildProjectDirectory)\..\ + $(SolutionDir) + $(MSBuildProjectDirectory) + $(SolutionDir)\GitVersionTask.targets + $(SolutionDir)\GitVersionTask.targets + + false + $(MSBuildProjectDirectory)\obj\$(Configuration)\ + + + false + true + + + false + false + true + + + false + true + + false + true + + + true + false + + + + + $(UtilPackTaskFactoryParametersXML) + + + + + $(UtilPackTaskFactoryParametersXML) + + + + + $(UtilPackTaskFactoryParametersXML) + + + + + $(UtilPackTaskFactoryParametersXML) + + + + True + + + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/build/functionality/GitVersionMultiTargetBuild.targets b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionMultiTargetBuild.targets new file mode 100644 index 0000000000..379ff192cb --- /dev/null +++ b/src/GitVersionTask/NugetAssets/build/functionality/GitVersionMultiTargetBuild.targets @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(GitVersion_FullSemVer) + $(GitVersion_MajorMinorPatch) + $(GitVersion_NuGetPreReleaseTag) + $(GitVersion_PreReleaseTag) + $(GitVersion_NuGetVersion) + $(GitVersion_FullSemVer) + $(GitVersion_InformationalVersion) + $(GitVersion_AssemblySemVer) + $(GitVersion_AssemblySemFileVer) + + + + From ebcc1ab1d32e6a886b5b2fa4e083eac1688845bd Mon Sep 17 00:00:00 2001 From: dazinator Date: Tue, 31 Oct 2017 23:34:28 +0000 Subject: [PATCH 19/79] Update appveyor build image. --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index d25bd9bb1f..6df9d5c357 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,4 @@ +image: Visual Studio 2017 install: npm i -g tfx-cli From 32d556b5e86a07aea911bd96f5ca4aedd2c89499 Mon Sep 17 00:00:00 2001 From: dazinator Date: Tue, 31 Oct 2017 23:37:10 +0000 Subject: [PATCH 20/79] cake script to use vs2017 tools version. --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 5a96078c06..3a91e390b5 100644 --- a/build.cake +++ b/build.cake @@ -31,7 +31,7 @@ void Build(string configuration, string nugetVersion, string semVersion, string .SetConfiguration(configuration) .SetPlatformTarget(PlatformTarget.MSIL) .WithProperty("Windows", "True") - .UseToolVersion(MSBuildToolVersion.VS2015) + .UseToolVersion(MSBuildToolVersion.VS2017) .SetVerbosity(Verbosity.Minimal) .SetNodeReuse(false); From b74a79e24586641ade6b4c548c508c5c4ee6711a Mon Sep 17 00:00:00 2001 From: dazinator Date: Tue, 31 Oct 2017 23:40:00 +0000 Subject: [PATCH 21/79] Updated gitignore to include cake package config. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3b869cb610..9dd5228df2 100644 --- a/.gitignore +++ b/.gitignore @@ -110,7 +110,8 @@ src/GitVersionTfsTask/*.js #################### # Cake #################### -/tools +tools/* +!tools/packages.config /*.zip GitVersion.CommandLine/*/ From e53776b0ff299cd7b89a73d4a89f9b1dfcb61a6d Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 3 Nov 2017 19:04:30 +0000 Subject: [PATCH 22/79] added cake.config --- tools/packages.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/packages.config b/tools/packages.config index 4bc41f6930..758efc6735 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,5 +1,5 @@ - - + + From b819f48fb20e89d851aa33ecb9ec3dbd9b03543f Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 3 Nov 2017 19:11:48 +0000 Subject: [PATCH 23/79] Fixed up some paths in cake script. --- build.cake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cake b/build.cake index 3a91e390b5..c11f999ce8 100644 --- a/build.cake +++ b/build.cake @@ -63,12 +63,12 @@ Task("Version") UpdateAssemblyInfo = true, LogFilePath = "console", OutputType = GitVersionOutput.BuildServer, - ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe" + ToolPath = @"src\GitVersionExe\bin\Release\net40\GitVersion.exe" }); GitVersion assertedVersions = GitVersion(new GitVersionSettings { OutputType = GitVersionOutput.Json, - ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe" + ToolPath = @"src\GitVersionExe\bin\Release\net40\GitVersion.exe" }); version = assertedVersions.MajorMinorPatch; @@ -101,9 +101,9 @@ Task("Run-NUnit-Tests") settings.Where = "cat != NoMono"; } NUnit3(new [] { - "src/GitVersionCore.Tests/bin/" + configuration + "/GitVersionCore.Tests.dll", - "src/GitVersionExe.Tests/bin/" + configuration + "/GitVersionExe.Tests.dll", - "src/GitVersionTask.Tests/bin/" + configuration + "/GitVersionTask.Tests.dll" }, + "src/GitVersionCore.Tests/bin/" + configuration + "/net461/GitVersionCore.Tests.dll", + "src/GitVersionExe.Tests/bin/" + configuration + "/net452/GitVersionExe.Tests.dll", + "src/GitVersionTask.Tests/bin/" + configuration + "/net461/GitVersionTask.Tests.dll" }, settings); if (AppVeyor.IsRunningOnAppVeyor) { From 4fc440e47ec30ccf1a3d3d3b0bf3a680c57417fa Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Tue, 7 Nov 2017 13:58:09 +0000 Subject: [PATCH 24/79] reset AssemblyInfoFileUpdaterTests. --- .../AssemblyInfoFileUpdaterTests.cs | 784 +++++++++--------- 1 file changed, 390 insertions(+), 394 deletions(-) diff --git a/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs b/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs index dccd4ac095..dadc0c4bad 100644 --- a/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs +++ b/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs @@ -4,486 +4,482 @@ using System.Linq; using GitVersion; using GitVersion.Helpers; +using GitVersionCore.Tests; using NSubstitute; using NUnit.Framework; using Shouldly; -using GitVersionCore.Tests; -namespace GitVersionExe.Tests +[TestFixture] +public class AssemblyInfoFileUpdaterTests { - [TestFixture] - public class AssemblyInfoFileUpdaterTests + [SetUp] + public void Setup() + { + ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute(); + } + + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) { - [SetUp] - public void SetLoggers() + var fileSystem = new TestFileSystem(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension; + var fullPath = Path.Combine(workingDir, assemblyInfoFile); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true)) { - ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute(); + assemblyInfoFileUpdater.Update(); + + fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } + } - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) - { - var fileSystem = new TestFileSystem(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension; - var fullPath = Path.Combine(workingDir, assemblyInfoFile); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) + { + var fileSystem = new TestFileSystem(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension); + var fullPath = Path.Combine(workingDir, assemblyInfoFile); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true)) - { - assemblyInfoFileUpdater.Update(); + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true)) + { + assemblyInfoFileUpdater.Update(); - fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); - } + fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } + } - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) + { + var fileSystem = new TestFileSystem(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFiles = new HashSet { - var fileSystem = new TestFileSystem(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension); - var fullPath = Path.Combine(workingDir, assemblyInfoFile); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + "AssemblyInfo." + fileExtension, + Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension) + }; + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true)) - { - assemblyInfoFileUpdater.Update(); + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFiles, workingDir, variables, fileSystem, true)) + { + assemblyInfoFileUpdater.Update(); + foreach (var item in assemblyInfoFiles) + { + var fullPath = Path.Combine(workingDir, item); fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } } + } + + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + public void ShouldNotCreateAssemblyInfoFileWhenNotExistsAndNotEnsureAssemblyInfo(string fileExtension) + { + var fileSystem = new TestFileSystem(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension; + var fullPath = Path.Combine(workingDir, assemblyInfoFile); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - var fileSystem = new TestFileSystem(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFiles = new HashSet + assemblyInfoFileUpdater.Update(); + + fileSystem.Exists(fullPath).ShouldBeFalse(); + } + } + + [Test] + public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssemblyInfo() + { + var fileSystem = Substitute.For(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "VersionAssemblyInfo.js"; + var fullPath = Path.Combine(workingDir, assemblyInfoFile); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true)) { - "AssemblyInfo." + fileExtension, - Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension) - }; - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + assemblyInfoFileUpdater.Update(); + + fileSystem.Received(0).WriteAllText(fullPath, Arg.Any()); + } + } + + [Test] + public void ShouldStartSearchFromWorkingDirectory() + { + var fileSystem = Substitute.For(); + var workingDir = Path.GetTempPath(); + var assemblyInfoFiles = new HashSet(); + var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFiles, workingDir, variables, fileSystem, true)) + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFiles, workingDir, variables, fileSystem, false)) + { + assemblyInfoFileUpdater.Update(); + + fileSystem.Received().DirectoryGetFiles(Arg.Is(workingDir), Arg.Any(), Arg.Any()); + } + } + + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersion(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + { + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { assemblyInfoFileUpdater.Update(); - foreach (var item in assemblyInfoFiles) - { - var fullPath = Path.Combine(workingDir, item); - fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); - } + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - } + }); + } - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - public void ShouldNotCreateAssemblyInfoFileWhenNotExistsAndNotEnsureAssemblyInfo(string fileExtension) - { - var fileSystem = new TestFileSystem(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension; - var fullPath = Path.Combine(workingDir, assemblyInfoFile); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + [TestCase("cs", "[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]")] + [TestCase("vb", "")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.None, verify: (fileSystem, variables) => + { using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { assemblyInfoFileUpdater.Update(); - fileSystem.Exists(fullPath).ShouldBeFalse(); + assemblyFileContent = fileSystem.ReadAllText(fileName); + assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } - } + }); + } - [Test] - public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssemblyInfo() - { - var fileSystem = Substitute.For(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "VersionAssemblyInfo.js"; - var fullPath = Path.Combine(workingDir, assemblyInfoFile); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersionInRelativePath(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension); + var fileName = Path.Combine(workingDir, assemblyInfoFile); - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true)) + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + { + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { assemblyInfoFileUpdater.Update(); - fileSystem.Received(0).WriteAllText(fullPath, Arg.Any()); + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - } + }); + } - [Test] - public void ShouldStartSearchFromWorkingDirectory() - { - var fileSystem = Substitute.For(); - var workingDir = Path.GetTempPath(); - var assemblyInfoFiles = new HashSet(); - var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + [TestCase("cs", "[assembly: AssemblyVersion ( \"1.0.0.0\") ]\r\n[assembly: AssemblyInformationalVersion\t(\t\"1.0.0.0\"\t)]\r\n[assembly: AssemblyFileVersion\r\n(\r\n\"1.0.0.0\"\r\n)]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + public void ShouldReplaceAssemblyVersionInRelativePathWithWhiteSpace(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension); + var fileName = Path.Combine(workingDir, assemblyInfoFile); - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFiles, workingDir, variables, fileSystem, false)) + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + { + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { assemblyInfoFileUpdater.Update(); - fileSystem.Received().DirectoryGetFiles(Arg.Is(workingDir), Arg.Any(), Arg.Any()); + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); } - } + }); + } - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersion(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.*\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersionWithStar(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + { + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + assemblyInfoFileUpdater.Update(); - [TestCase("cs", "[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]")] - [TestCase("vb", "")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); + } + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.None, verify: (fileSystem, variables) => - { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - assemblyFileContent = fileSystem.ReadAllText(fileName); - assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); - } - }); - } + [TestCase("cs", "[assembly: AssemblyVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersionAttribute(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersionWithAtttributeSuffix(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersionInRelativePath(string fileExtension, string assemblyFileContent) + VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension); - var fileName = Path.Combine(workingDir, assemblyInfoFile); - - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + assemblyInfoFileUpdater.Update(); - [TestCase("cs", "[assembly: AssemblyVersion ( \"1.0.0.0\") ]\r\n[assembly: AssemblyInformationalVersion\t(\t\"1.0.0.0\"\t)]\r\n[assembly: AssemblyFileVersion\r\n(\r\n\"1.0.0.0\"\r\n)]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - public void ShouldReplaceAssemblyVersionInRelativePathWithWhiteSpace(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension); - var fileName = Path.Combine(workingDir, assemblyInfoFile); + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + !s.Contains(@"AssemblyVersionAttribute(""1.0.0.0"")") && + !s.Contains(@"AssemblyInformationalVersionAttribute(""1.0.0.0"")") && + !s.Contains(@"AssemblyFileVersionAttribute(""1.0.0.0"")") && + s.Contains(@"AssemblyVersion(""2.3.1.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); + } + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => - { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + [TestCase("cs")] + [TestCase("fs")] + [TestCase("vb")] + public void ShouldAddAssemblyVersionIfMissingFromInfoFile(string fileExtension) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.*\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersionWithStar(string fileExtension, string assemblyFileContent) + VerifyAssemblyInfoFile("", fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); - - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + assemblyInfoFileUpdater.Update(); - [TestCase("cs", "[assembly: AssemblyVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersionAttribute(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersionWithAtttributeSuffix(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); + } + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => - { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - !s.Contains(@"AssemblyVersionAttribute(""1.0.0.0"")") && - !s.Contains(@"AssemblyInformationalVersionAttribute(""1.0.0.0"")") && - !s.Contains(@"AssemblyFileVersionAttribute(""1.0.0.0"")") && - s.Contains(@"AssemblyVersion(""2.3.1.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + [TestCase("cs", "[assembly: AssemblyVersion(\"2.2.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"2.2.0+5.Branch.foo.Sha.hash\")]\r\n[assembly: AssemblyFileVersion(\"2.2.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAlreadySubstitutedValues(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); - [TestCase("cs")] - [TestCase("fs")] - [TestCase("vb")] - public void ShouldAddAssemblyVersionIfMissingFromInfoFile(string fileExtension) + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); - - VerifyAssemblyInfoFile("", fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + assemblyInfoFileUpdater.Update(); - [TestCase("cs", "[assembly: AssemblyVersion(\"2.2.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"2.2.0+5.Branch.foo.Sha.hash\")]\r\n[assembly: AssemblyFileVersion(\"2.2.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAlreadySubstitutedValues(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); + } + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => - { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldReplaceAssemblyVersionWhenCreatingAssemblyVersionFileAndEnsureAssemblyInfo(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldReplaceAssemblyVersionWhenCreatingAssemblyVersionFileAndEnsureAssemblyInfo(string fileExtension, string assemblyFileContent) + VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); - - VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.1.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + assemblyInfoFileUpdater.Update(); - [TestCase("cs", "[assembly: AssemblyVersion (AssemblyInfo.Version) ]\r\n[assembly: AssemblyInformationalVersion(AssemblyInfo.InformationalVersion)]\r\n[assembly: AssemblyFileVersion(AssemblyInfo.FileVersion)]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - public void ShouldReplaceAssemblyVersionInRelativePathWithVariables(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension); - var fileName = Path.Combine(workingDir, assemblyInfoFile); + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.1.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); + } + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => - { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + [TestCase("cs", "[assembly: AssemblyVersion (AssemblyInfo.Version) ]\r\n[assembly: AssemblyInformationalVersion(AssemblyInfo.InformationalVersion)]\r\n[assembly: AssemblyFileVersion(AssemblyInfo.FileVersion)]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + public void ShouldReplaceAssemblyVersionInRelativePathWithVariables(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension); + var fileName = Path.Combine(workingDir, assemblyInfoFile); - [TestCase("cs", "[assembly: AssemblyVersion ( AssemblyInfo.VersionInfo ) ]\r\n[assembly: AssemblyInformationalVersion\t(\tAssemblyInfo.InformationalVersion\t)]\r\n[assembly: AssemblyFileVersion\r\n(\r\nAssemblyInfo.FileVersion\r\n)]")] - [TestCase("fs", "[]\r\n[]\r\n[]")] - [TestCase("vb", "\r\n\r\n")] - public void ShouldReplaceAssemblyVersionInRelativePathWithVariablesAndWhiteSpace(string fileExtension, string assemblyFileContent) + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension); - var fileName = Path.Combine(workingDir, assemblyInfoFile); - - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - fileSystem.Received().WriteAllText(fileName, Arg.Is(s => - s.Contains(@"AssemblyVersion(""2.3.0.0"")") && - s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && - s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); - } - }); - } + assemblyInfoFileUpdater.Update(); - [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]\r\n[]")] - [TestCase("vb", "\r\n")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile(string fileExtension, string assemblyFileContent) - { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); + } + }); + } - VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => - { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - assemblyFileContent = fileSystem.ReadAllText(fileName); - assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); - } - }); - } + [TestCase("cs", "[assembly: AssemblyVersion ( AssemblyInfo.VersionInfo ) ]\r\n[assembly: AssemblyInformationalVersion\t(\tAssemblyInfo.InformationalVersion\t)]\r\n[assembly: AssemblyFileVersion\r\n(\r\nAssemblyInfo.FileVersion\r\n)]")] + [TestCase("fs", "[]\r\n[]\r\n[]")] + [TestCase("vb", "\r\n\r\n")] + public void ShouldReplaceAssemblyVersionInRelativePathWithVariablesAndWhiteSpace(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = Path.Combine("Project", "src", "Properties", "AssemblyInfo." + fileExtension); + var fileName = Path.Combine(workingDir, assemblyInfoFile); - [TestCase("cs", "[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] - [TestCase("fs", "[]")] - [TestCase("vb", "")] - [Category("NoMono")] - [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] - public void ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone(string fileExtension, string assemblyFileContent) + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.MajorMinor, (fileSystem, variables) => { - var workingDir = Path.GetTempPath(); - var assemblyInfoFile = "AssemblyInfo." + fileExtension; - var fileName = Path.Combine(workingDir, assemblyInfoFile); + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) + { + assemblyInfoFileUpdater.Update(); + + fileSystem.Received().WriteAllText(fileName, Arg.Is(s => + s.Contains(@"AssemblyVersion(""2.3.0.0"")") && + s.Contains(@"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"")") && + s.Contains(@"AssemblyFileVersion(""2.3.1.0"")"))); + } + }); + } + + [TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]\r\n[]")] + [TestCase("vb", "\r\n")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); - VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.None, verify: (fileSystem, variables) => + VerifyAssemblyInfoFile(assemblyFileContent, fileName, verify: (fileSystem, variables) => + { + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) - { - assemblyInfoFileUpdater.Update(); - - assemblyFileContent = fileSystem.ReadAllText(fileName); - assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); - } - }); - } + assemblyInfoFileUpdater.Update(); + + assemblyFileContent = fileSystem.ReadAllText(fileName); + assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + } + }); + } - private static void VerifyAssemblyInfoFile( - string assemblyFileContent, - string fileName, - AssemblyVersioningScheme versioningScheme = AssemblyVersioningScheme.MajorMinorPatch, - Action verify = null) + [TestCase("cs", "[assembly: AssemblyFileVersion(\"1.0.0.0\")]")] + [TestCase("fs", "[]")] + [TestCase("vb", "")] + [Category("NoMono")] + [Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")] + public void ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone(string fileExtension, string assemblyFileContent) + { + var workingDir = Path.GetTempPath(); + var assemblyInfoFile = "AssemblyInfo." + fileExtension; + var fileName = Path.Combine(workingDir, assemblyInfoFile); + + VerifyAssemblyInfoFile(assemblyFileContent, fileName, AssemblyVersioningScheme.None, verify: (fileSystem, variables) => { - var fileSystem = Substitute.For(); - var version = new SemanticVersion + using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { - BuildMetaData = new SemanticVersionBuildMetaData(3, "foo", "hash", DateTimeOffset.Now), - Major = 2, - Minor = 3, - Patch = 1 - }; + assemblyInfoFileUpdater.Update(); + + assemblyFileContent = fileSystem.ReadAllText(fileName); + assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); + } + }); + } + + private static void VerifyAssemblyInfoFile( + string assemblyFileContent, + string fileName, + AssemblyVersioningScheme versioningScheme = AssemblyVersioningScheme.MajorMinorPatch, + Action verify = null) + { + var fileSystem = Substitute.For(); + var version = new SemanticVersion + { + BuildMetaData = new SemanticVersionBuildMetaData(3, "foo", "hash", DateTimeOffset.Now), + Major = 2, + Minor = 3, + Patch = 1 + }; - fileSystem.Exists(fileName).Returns(true); + fileSystem.Exists(fileName).Returns(true); + fileSystem.ReadAllText(fileName).Returns(assemblyFileContent); + fileSystem.When(f => f.WriteAllText(fileName, Arg.Any())).Do(c => + { + assemblyFileContent = c.ArgAt(1); fileSystem.ReadAllText(fileName).Returns(assemblyFileContent); - fileSystem.When(f => f.WriteAllText(fileName, Arg.Any())).Do(c => - { - assemblyFileContent = c.ArgAt(1); - fileSystem.ReadAllText(fileName).Returns(assemblyFileContent); - }); + }); - var config = new TestEffectiveConfiguration(assemblyVersioningScheme: versioningScheme); - var variables = VariableProvider.GetVariablesFor(version, config, false); + var config = new TestEffectiveConfiguration(assemblyVersioningScheme: versioningScheme); + var variables = VariableProvider.GetVariablesFor(version, config, false); - verify(fileSystem, variables); - } + verify(fileSystem, variables); } - } \ No newline at end of file From 6d46e03f0e853ac467ef3249ac511cf2c7b80488 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Tue, 7 Nov 2017 14:09:18 +0000 Subject: [PATCH 25/79] Removed attempt at setting content-length header as causing exception. --- src/GitVersionCore/BuildServers/AppVeyor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GitVersionCore/BuildServers/AppVeyor.cs b/src/GitVersionCore/BuildServers/AppVeyor.cs index 2363e4fb63..ef670d173b 100644 --- a/src/GitVersionCore/BuildServers/AppVeyor.cs +++ b/src/GitVersionCore/BuildServers/AppVeyor.cs @@ -39,9 +39,9 @@ public override string GenerateSetVersionMessage(VersionVariables variables) { request.Headers = new WebHeaderCollection(); } + var bytesLength = bytes.Length; - request.Headers["Content-Length"] = bytesLength.ToString(); - + //request.Headers["Content-Length"] = bytesLength.ToString(); // request.ContentLength = bytes.Length; request.ContentType = "application/json"; From 2e4cc16ea5a198bad95a6908f83618136f1d0661 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Tue, 7 Nov 2017 14:28:11 +0000 Subject: [PATCH 26/79] Removed another instance of setting content length --- src/GitVersionCore/BuildServers/AppVeyor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GitVersionCore/BuildServers/AppVeyor.cs b/src/GitVersionCore/BuildServers/AppVeyor.cs index ef670d173b..c430d6ab27 100644 --- a/src/GitVersionCore/BuildServers/AppVeyor.cs +++ b/src/GitVersionCore/BuildServers/AppVeyor.cs @@ -94,8 +94,8 @@ public override string[] GenerateSetParameterMessage(string name, string value) } var bytesLength = bytes.Length; // No property for content-length - and no Add() method on header collection? WHAAAAT - // request.ContentLength = bytes.Length; - request.Headers["Content-Length"] = bytesLength.ToString(); + // request.ContentLength = bytes.Length; + //request.Headers["Content-Length"] = bytesLength.ToString(); using (var writeStream = request.GetRequestStreamAsync().Result) { @@ -126,7 +126,7 @@ public override string GenerateSetVersionMessage(VersionVariables variables) request.Headers = new WebHeaderCollection(); } var bytesLength = bytes.Length; - request.Headers["Content-Length"] = bytesLength.ToString(); + // request.Headers["Content-Length"] = bytesLength.ToString(); // request.ContentLength = bytes.Length; request.ContentType = "application/json"; From 6383fd4eeb5d156e2c32f899aa0e9cecc329dee8 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 8 Nov 2017 12:13:47 +0000 Subject: [PATCH 27/79] Updated cake to version 0.22.2 --- tools/packages.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/packages.config b/tools/packages.config index 758efc6735..0002e9d537 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,5 +1,5 @@ - - + + From 374a1f7418746074446e37d4127c296597fae9c0 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 8 Nov 2017 14:44:04 +0000 Subject: [PATCH 28/79] Treid to switch tests to dotnettest to resolve issue with some tests failing locally with nunit console runner. --- build.cake | 34 +++++++++---------- .../GitVersionCore.Tests.csproj | 1 + .../GitVersionExe.Tests.csproj | 1 + .../GitVersionTask.Tests.csproj | 1 + 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/build.cake b/build.cake index c11f999ce8..bad456f1e1 100644 --- a/build.cake +++ b/build.cake @@ -26,11 +26,13 @@ void Build(string configuration, string nugetVersion, string semVersion, string .SetVerbosity(Verbosity.Minimal)); } else - { + { + var msBuildSettings = new MSBuildSettings() - .SetConfiguration(configuration) + .SetConfiguration(configuration) .SetPlatformTarget(PlatformTarget.MSIL) - .WithProperty("Windows", "True") + // .WithProperty("Platform", "Any CPU") + // .WithProperty("Windows", "True") .UseToolVersion(MSBuildToolVersion.VS2017) .SetVerbosity(Verbosity.Minimal) .SetNodeReuse(false); @@ -95,21 +97,17 @@ Task("Run-NUnit-Tests") .IsDependentOn("Build") .Does(() => { - var settings = new NUnit3Settings(); - if(IsRunningOnUnix()) - { - settings.Where = "cat != NoMono"; - } - NUnit3(new [] { - "src/GitVersionCore.Tests/bin/" + configuration + "/net461/GitVersionCore.Tests.dll", - "src/GitVersionExe.Tests/bin/" + configuration + "/net452/GitVersionExe.Tests.dll", - "src/GitVersionTask.Tests/bin/" + configuration + "/net461/GitVersionTask.Tests.dll" }, - settings); - if (AppVeyor.IsRunningOnAppVeyor) - { - Information("Uploading test results"); - AppVeyor.UploadTestResults("TestResult.xml", AppVeyorTestResultsType.NUnit3); - } + + var settings = new DotNetCoreTestSettings + { + Configuration = "Release", + NoBuild = true + }; + + DotNetCoreTest("./src/GitVersionCore.Tests/GitVersionCore.Tests.csproj", settings); + DotNetCoreTest("./src/GitVersionExe.Tests/GitVersionExe.Tests.csproj", settings); + DotNetCoreTest("./src/GitVersionTask.Tests/GitVersionTask.Tests.csproj", settings); + }); Task("Zip-Files") diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 91589d23c1..76b34cbc83 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -38,6 +38,7 @@ + diff --git a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj index a3cf45cb21..5ac479f9d6 100644 --- a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj +++ b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj @@ -44,6 +44,7 @@ + diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index 21da936061..ed2b4db3c6 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -51,6 +51,7 @@ + From 856d3f013eea5233ee4e7c12200813ade33257b0 Mon Sep 17 00:00:00 2001 From: dazinator Date: Fri, 29 Dec 2017 00:39:29 +0000 Subject: [PATCH 29/79] Attempt at fixing cake CI build issue. --- build.cake | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/build.cake b/build.cake index bad456f1e1..eee5360b31 100644 --- a/build.cake +++ b/build.cake @@ -38,13 +38,28 @@ void Build(string configuration, string nugetVersion, string semVersion, string .SetNodeReuse(false); if (BuildSystem.AppVeyor.IsRunningOnAppVeyor) - { - msBuildSettings = msBuildSettings - .WithProperty("GitVersion_NuGetVersion", nugetVersion) - .WithProperty("GitVersion_SemVer", semVersion) - .WithProperty("GitVersion_MajorMinorPatch", version) - .WithProperty("GitVersion_PreReleaseTag", preReleaseTag); + { + if (!string.IsNullOrWhiteSpace(nugetVersion)) + { + msBuildSettings.WithProperty("GitVersion_NuGetVersion", nugetVersion); + } + if (!string.IsNullOrWhiteSpace(semVersion + { + msBuildSettings.WithProperty("GitVersion_SemVer", semVersion); + } + + if (!string.IsNullOrWhiteSpace(version)) + { + msBuildSettings.WithProperty("GitVersion_MajorMinorPatch", version); + } + + if (!string.IsNullOrWhiteSpace(preReleaseTag)) + { + msBuildSettings.WithProperty("GitVersion_PreReleaseTag", preReleaseTag); + + } } + MSBuild("./src/GitVersion.sln", msBuildSettings); } } From 5496bc1eb10e63dc71d0a8fe2a150829e4be2148 Mon Sep 17 00:00:00 2001 From: dazinator Date: Fri, 29 Dec 2017 00:40:57 +0000 Subject: [PATCH 30/79] Corrected typo in cake script. --- build.cake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.cake b/build.cake index eee5360b31..076c17189c 100644 --- a/build.cake +++ b/build.cake @@ -43,7 +43,7 @@ void Build(string configuration, string nugetVersion, string semVersion, string { msBuildSettings.WithProperty("GitVersion_NuGetVersion", nugetVersion); } - if (!string.IsNullOrWhiteSpace(semVersion + if (!string.IsNullOrWhiteSpace(semVersion)) { msBuildSettings.WithProperty("GitVersion_SemVer", semVersion); } @@ -56,7 +56,6 @@ void Build(string configuration, string nugetVersion, string semVersion, string if (!string.IsNullOrWhiteSpace(preReleaseTag)) { msBuildSettings.WithProperty("GitVersion_PreReleaseTag", preReleaseTag); - } } From e0a0b6fe634a45d8aef4fee130b0a0be30e35259 Mon Sep 17 00:00:00 2001 From: dazinator Date: Fri, 29 Dec 2017 01:30:02 +0000 Subject: [PATCH 31/79] Attempt to use more detailed msbuild output via cake CI build. --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index 076c17189c..ca2adf0c51 100644 --- a/build.cake +++ b/build.cake @@ -34,7 +34,7 @@ void Build(string configuration, string nugetVersion, string semVersion, string // .WithProperty("Platform", "Any CPU") // .WithProperty("Windows", "True") .UseToolVersion(MSBuildToolVersion.VS2017) - .SetVerbosity(Verbosity.Minimal) + .SetVerbosity(Verbosity.Detailed) .SetNodeReuse(false); if (BuildSystem.AppVeyor.IsRunningOnAppVeyor) From 2604a33dfcd5b47497d6d9a8f751d357bfb76b84 Mon Sep 17 00:00:00 2001 From: dazinator Date: Fri, 29 Dec 2017 01:32:42 +0000 Subject: [PATCH 32/79] Changed cake msbuild verbosity to verbose. --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index ca2adf0c51..7596d1debe 100644 --- a/build.cake +++ b/build.cake @@ -23,7 +23,7 @@ void Build(string configuration, string nugetVersion, string semVersion, string XBuild("./src/GitVersion.sln", new XBuildSettings() .SetConfiguration(configuration) .WithProperty("POSIX", "True") - .SetVerbosity(Verbosity.Minimal)); + .SetVerbosity(Verbosity.Verbose)); } else { From 123a28c81f3d8cf52ad4b6660b7c8fd9131bf593 Mon Sep 17 00:00:00 2001 From: dazinator Date: Fri, 29 Dec 2017 01:38:37 +0000 Subject: [PATCH 33/79] Trying diagnostic msbuild output as Detailed didn't work. --- build.cake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cake b/build.cake index 7596d1debe..c4fe0631b7 100644 --- a/build.cake +++ b/build.cake @@ -23,7 +23,7 @@ void Build(string configuration, string nugetVersion, string semVersion, string XBuild("./src/GitVersion.sln", new XBuildSettings() .SetConfiguration(configuration) .WithProperty("POSIX", "True") - .SetVerbosity(Verbosity.Verbose)); + .SetVerbosity(Verbosity.Minimal)); } else { @@ -34,7 +34,7 @@ void Build(string configuration, string nugetVersion, string semVersion, string // .WithProperty("Platform", "Any CPU") // .WithProperty("Windows", "True") .UseToolVersion(MSBuildToolVersion.VS2017) - .SetVerbosity(Verbosity.Detailed) + .SetVerbosity(Verbosity.Diagnostic) .SetNodeReuse(false); if (BuildSystem.AppVeyor.IsRunningOnAppVeyor) From 9e169b35658f8df467d8f355eba56b641612bf31 Mon Sep 17 00:00:00 2001 From: dazinator Date: Fri, 29 Dec 2017 01:47:15 +0000 Subject: [PATCH 34/79] Added global.json to pin netcore sdk to version 2.0.0 Changed msbuilkd verbosity to Normal, as diagnostic blew up the AppVeyor ui. --- src/global.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/global.json diff --git a/src/global.json b/src/global.json new file mode 100644 index 0000000000..4d61027af6 --- /dev/null +++ b/src/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "2.0.0" + } +} \ No newline at end of file From eecdff712ca26c943daa2bd7662a896681c95feb Mon Sep 17 00:00:00 2001 From: dazinator Date: Fri, 29 Dec 2017 01:47:51 +0000 Subject: [PATCH 35/79] Added change missed from previous push.. --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index c4fe0631b7..317cf1f6ac 100644 --- a/build.cake +++ b/build.cake @@ -34,7 +34,7 @@ void Build(string configuration, string nugetVersion, string semVersion, string // .WithProperty("Platform", "Any CPU") // .WithProperty("Windows", "True") .UseToolVersion(MSBuildToolVersion.VS2017) - .SetVerbosity(Verbosity.Diagnostic) + .SetVerbosity(Verbosity.Normal) .SetNodeReuse(false); if (BuildSystem.AppVeyor.IsRunningOnAppVeyor) From 95e3d0958cde9d5c59abfaad9a6e7502840d5cfa Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Tue, 23 Jan 2018 16:42:12 +0000 Subject: [PATCH 36/79] #1269 - forward integration with master including gitpreparer changes. --- src/GitVersionCore/GitPreparer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GitVersionCore/GitPreparer.cs b/src/GitVersionCore/GitPreparer.cs index 50f0e48de3..919340889f 100644 --- a/src/GitVersionCore/GitPreparer.cs +++ b/src/GitVersionCore/GitPreparer.cs @@ -83,14 +83,14 @@ private void CleanupDuplicateOrigin() var repo = new Repository(GetDotGitDirectory()); // check that we have a remote that matches defaultRemoteName if not take the first remote - if (!repo.Network.Remotes.Any(remote => remote.Name.Equals(defaultRemoteName, StringComparison.InvariantCultureIgnoreCase))) + if (!repo.Network.Remotes.Any(remote => remote.Name.Equals(defaultRemoteName, StringComparerUtils.IngoreCaseComparison))) { remoteToKeep = repo.Network.Remotes.First().Name; } var duplicateRepos = repo.Network .Remotes - .Where(remote => !remote.Name.Equals(remoteToKeep, StringComparison.InvariantCultureIgnoreCase)) + .Where(remote => !remote.Name.Equals(remoteToKeep, StringComparerUtils.IngoreCaseComparison)) .Select(remote => remote.Name); // remove all remotes that are considered duplicates From 8713f12c8472400344b91ee58dcc0d05b554312b Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Tue, 23 Jan 2018 19:16:29 +0000 Subject: [PATCH 37/79] #1269 - switch back to nunit console runner - all tests passing for local cake build. --- build.cake | 32 ++++++++++++++++--- .../AssemblyInfoFileUpdaterTests.cs | 2 +- .../GitVersionCore.Tests.csproj | 12 ++++--- src/GitVersionCore/AssemblyInfo.cs | 2 +- .../GitVersionExe.Tests.csproj | 8 ++--- src/GitVersionExe/AssemblyInfo.cs | 2 +- src/GitVersionExe/FodyWeavers.xml | 2 +- src/GitVersionExe/GitVersionExe.csproj | 16 ++++++---- .../GitVersionTask.Tests.csproj | 4 +-- 9 files changed, 54 insertions(+), 26 deletions(-) diff --git a/build.cake b/build.cake index 51d4805e3d..41109efc43 100644 --- a/build.cake +++ b/build.cake @@ -108,14 +108,37 @@ Task("Build") Build(configuration, nugetVersion, semVersion, version, preReleaseTag); }); -Task("Run-NUnit-Tests") +Task("Run-Tests-In-NUnitConsole") + .IsDependentOn("DogfoodBuild") + .Does(() => +{ + var settings = new NUnit3Settings(); + var targetFramework = "net461"; + if(IsRunningOnUnix()) + { + settings.Where = "cat != NoMono"; + } + NUnit3(new [] { + "src/GitVersionCore.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionCore.Tests.dll", + "src/GitVersionExe.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionExe.Tests.dll", + "src/GitVersionTask.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionTask.Tests.dll" }, + settings); + if (AppVeyor.IsRunningOnAppVeyor) + { + Information("Uploading test results"); + AppVeyor.UploadTestResults("TestResult.xml", AppVeyorTestResultsType.NUnit3); + } +}); + + +Task("Run-Tests") .IsDependentOn("DogfoodBuild") .Does(() => { var settings = new DotNetCoreTestSettings { - Configuration = "Release", + Configuration = configuration, NoBuild = true }; @@ -127,7 +150,8 @@ Task("Run-NUnit-Tests") Task("Zip-Files") .IsDependentOn("Build") - .IsDependentOn("Run-NUnit-Tests") + .IsDependentOn("Run-Tests-In-NUnitConsole") + // .IsDependentOn("Run-Tests") .Does(() => { Zip("./build/NuGetCommandLineBuild/Tools/", "build/GitVersion_" + nugetVersion + ".zip"); @@ -205,7 +229,7 @@ Task("Upload-AppVeyor-Artifacts") Task("Travis") - .IsDependentOn("Run-NUnit-Tests"); + .IsDependentOn("Run-Tests"); Task("Default") .IsDependentOn("Upload-AppVeyor-Artifacts"); diff --git a/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs b/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs index dadc0c4bad..214db2c27f 100644 --- a/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs +++ b/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs @@ -424,7 +424,7 @@ public void ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false)) { assemblyInfoFileUpdater.Update(); - + assemblyFileContent = fileSystem.ReadAllText(fileName); assemblyFileContent.ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 76b34cbc83..a302ca8d20 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -29,23 +29,25 @@ false bin\Release\ TRACE - + true + + - + - + - + Designer diff --git a/src/GitVersionCore/AssemblyInfo.cs b/src/GitVersionCore/AssemblyInfo.cs index e99b097fdb..7ad8a85862 100644 --- a/src/GitVersionCore/AssemblyInfo.cs +++ b/src/GitVersionCore/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: InternalsVisibleTo("GitVersionCore.Tests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-beta.12+1291.Branch.master.Sha.bc74ac2247d8a58053a33316334ada6b771a8455")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1493.Branch.feature/netstandard.Sha.95e3d0958cde9d5c59abfaad9a6e7502840d5cfa")] diff --git a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj index 5ac479f9d6..735937d6ca 100644 --- a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj +++ b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj @@ -7,7 +7,7 @@ GitVersionExe.Tests GitVersionExe.Tests - net452 + net461 false false @@ -37,18 +37,18 @@ true - + - + - + diff --git a/src/GitVersionExe/AssemblyInfo.cs b/src/GitVersionExe/AssemblyInfo.cs index 10f78a2e2a..bb02fe409f 100644 --- a/src/GitVersionExe/AssemblyInfo.cs +++ b/src/GitVersionExe/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: InternalsVisibleTo("AcceptanceTests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-beta.12+1291.Branch.master.Sha.bc74ac2247d8a58053a33316334ada6b771a8455")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1493.Branch.feature/netstandard.Sha.95e3d0958cde9d5c59abfaad9a6e7502840d5cfa")] diff --git a/src/GitVersionExe/FodyWeavers.xml b/src/GitVersionExe/FodyWeavers.xml index ba2f99a4d5..74f14520c9 100644 --- a/src/GitVersionExe/FodyWeavers.xml +++ b/src/GitVersionExe/FodyWeavers.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index 45a8bb42e5..0a7e53065c 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -35,14 +35,14 @@ bin\Release\GitVersion.xml 1591 + AnyCPU - - + @@ -51,6 +51,10 @@ + + + Designer + @@ -75,11 +79,9 @@ - - - Designer - - + + + diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index ed2b4db3c6..a759d38ea1 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -37,7 +37,7 @@ true - + @@ -50,7 +50,7 @@ - + From 505d320fed2a79bac22635e83c83d8f35ca5ea71 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 24 Jan 2018 12:34:19 +0000 Subject: [PATCH 38/79] #1363 - Moved some packaging logic to cake. --- .gitignore | 3 +- build.cake | 140 ++++++++++++++++++++++++- src/GitVersionCore/AssemblyInfo.cs | 2 +- src/GitVersionExe/AssemblyInfo.cs | 2 +- src/GitVersionExe/GitVersionExe.csproj | 25 +---- 5 files changed, 144 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 9dd5228df2..96a6f29cb9 100644 --- a/.gitignore +++ b/.gitignore @@ -115,4 +115,5 @@ tools/* /*.zip GitVersion.CommandLine/*/ -releaseArtifacts \ No newline at end of file +releaseArtifacts +/ILMergeTemp diff --git a/build.cake b/build.cake index 41109efc43..eacab73f11 100644 --- a/build.cake +++ b/build.cake @@ -1,5 +1,7 @@ #tool "nuget:https://www.nuget.org/api/v2?package=NUnit.ConsoleRunner&version=3.7.0" #tool "nuget:https://www.nuget.org/api/v2?package=GitReleaseNotes&version=0.7.0" +#tool "nuget:https://www.nuget.org/api/v2?package=ILRepack&version=2.0.15" +#addin "nuget:?package=Cake.Incubator" var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); @@ -65,6 +67,7 @@ void Build(string configuration, string nugetVersion, string semVersion, string // This build task can be run to just build Task("DogfoodBuild") + .IsDependentOn("Clean") .IsDependentOn("NuGet-Package-Restore") .Does(() => { @@ -97,10 +100,22 @@ Task("Version") Task("NuGet-Package-Restore") .Does(() => { - NuGetRestore("./src/GitVersion.sln"); + DotNetCoreRestore("./src/GitVersion.sln"); + //NuGetRestore("./src/GitVersion.sln"); +}); + +Task("Clean") + .Does(() => +{ + CleanDirectories("./build"); + CleanDirectories("./**/obj"); + + var binDirs = GetDirectories("./**/bin") - GetDirectories("**/GemAssets/bin"); + CleanDirectories(binDirs); }); Task("Build") + .IsDependentOn("Clean") .IsDependentOn("Version") .IsDependentOn("NuGet-Package-Restore") .Does(() => @@ -148,8 +163,131 @@ Task("Run-Tests") }); +void ILRepackGitVersionExe(bool includeLibGit2Sharp) +{ + var tempMergeDir = "ILMergeTemp"; + var exeName = "GitVersion.exe"; + var keyFilePath = "./src/key.snk"; + var targetDir = "./src/GitVersionExe/bin/" + configuration + "/net40/"; + var targetPath = targetDir + exeName; + + CreateDirectory(tempMergeDir); + string outFilePath = "./" + tempMergeDir + "/" + exeName; + + var sourcePattern = targetDir + "*.dll"; + var sourceFiles = GetFiles(sourcePattern); + if(!includeLibGit2Sharp) + { + var excludePattern = "**/LibGit2Sharp.dll"; + sourceFiles = sourceFiles - GetFiles(excludePattern); + } + var settings = new ILRepackSettings { AllowDup = "", Keyfile = keyFilePath, Internalize = true, NDebug = true, TargetKind = TargetKind.Exe, TargetPlatform = TargetPlatformVersion.v4, XmlDocs = false }; + ILRepack(outFilePath, targetPath, sourceFiles, settings); +} + + +Task("Commandline-Package") + .IsDependentOn("Build") + .Does(() => +{ + + ILRepackGitVersionExe(false); + + var buildDir = "./build/"; + var outputDir = buildDir + "NuGetCommandLineBuild"; + var toolsDir = outputDir + "/tools"; + var libDir = toolsDir + "/lib"; + + CreateDirectory(outputDir); + CreateDirectory(toolsDir); + CreateDirectory(libDir); + + var targetDir = "./src/GitVersionExe/bin/" + configuration + "/net40/"; + + var libGitFiles = GetFiles(targetDir + "LibGit2Sharp.dll*"); + var nugetAssetsPath = "./src/GitVersionExe/NugetAssets/"; + Information("Copying files to packaging direcory.."); + + CopyFiles(targetDir + "GitVersion.pdb", outputDir + "/tools/"); + CopyFiles(targetDir + "GitVersion.exe.mdb", outputDir + "/tools/"); + + Information("Copying IL Merged exe file.."); + CopyFiles("./ILMergeTemp/GitVersion.exe", outputDir + "/tools/"); + + Information("Copying nuget assets.."); + CopyFiles(nugetAssetsPath + "GitVersion.CommandLine.nuspec", outputDir); + + Information("Copying libgit2sharp files.."); + CopyFiles(libGitFiles, outputDir + "/tools/"); + CopyDirectory(targetDir + "lib/", outputDir + "/tools/lib/"); + + Information("Creating Nuget Package.."); + var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; + + try + { + NuGetPack(outputDir + "/GitVersion.CommandLine.nuspec", nuGetPackSettings); + } + catch(Exception e) + { + Error(e.Dump()); + } + +}) +.ReportError(exception => +{ + Error(exception.Dump()); + // Report the error. +}); + + +Task("Portable-Package") + .IsDependentOn("Build") + .Does(() => +{ + + ILRepackGitVersionExe(true); + + var buildDir = "./build/"; + var outputDir = buildDir + "NuGetExeBuild"; + var toolsDir = outputDir + "/tools"; + var libDir = toolsDir + "/lib"; + + CreateDirectory(outputDir); + CreateDirectory(toolsDir); + CreateDirectory(libDir); + + var targetDir = "./src/GitVersionExe/bin/" + configuration + "/net40/"; + + var nugetAssetsPath = "./src/GitVersionExe/NugetAssets/"; + Information("Copying files to packaging direcory.."); + + CopyFiles(targetDir + "GitVersion.pdb", outputDir + "/tools/"); + CopyFiles(targetDir + "GitVersion.exe.mdb", outputDir + "/tools/"); + + Information("Copying IL Merged exe file.."); + CopyFiles("./ILMergeTemp/GitVersion.exe", outputDir + "/tools/"); + + Information("Copying nuget assets.."); +// + // + // + CopyFiles(nugetAssetsPath + "*.ps1", outputDir + "/tools/"); + CopyFiles(nugetAssetsPath + "GitVersion.Portable.nuspec", outputDir); + + Information("Copying libgit2sharp files.."); + CopyDirectory(targetDir + "lib/", outputDir + "/tools/lib/"); + + var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; + NuGetPack(outputDir + "/GitVersion.Portable.nuspec", nuGetPackSettings); + +}); + + Task("Zip-Files") .IsDependentOn("Build") + .IsDependentOn("Commandline-Package") + .IsDependentOn("Portable-Package") .IsDependentOn("Run-Tests-In-NUnitConsole") // .IsDependentOn("Run-Tests") .Does(() => diff --git a/src/GitVersionCore/AssemblyInfo.cs b/src/GitVersionCore/AssemblyInfo.cs index 7ad8a85862..f98800e395 100644 --- a/src/GitVersionCore/AssemblyInfo.cs +++ b/src/GitVersionCore/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: InternalsVisibleTo("GitVersionCore.Tests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1493.Branch.feature/netstandard.Sha.95e3d0958cde9d5c59abfaad9a6e7502840d5cfa")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1494.Branch.feature/netstandard.Sha.8713f12c8472400344b91ee58dcc0d05b554312b")] diff --git a/src/GitVersionExe/AssemblyInfo.cs b/src/GitVersionExe/AssemblyInfo.cs index bb02fe409f..4b0ff40d26 100644 --- a/src/GitVersionExe/AssemblyInfo.cs +++ b/src/GitVersionExe/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: InternalsVisibleTo("AcceptanceTests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1493.Branch.feature/netstandard.Sha.95e3d0958cde9d5c59abfaad9a6e7502840d5cfa")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1494.Branch.feature/netstandard.Sha.8713f12c8472400344b91ee58dcc0d05b554312b")] diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index 0a7e53065c..3321c09431 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -113,7 +113,6 @@ - mono @@ -125,29 +124,7 @@ - - - - - - - - - - - - - - - - - - - - - - - + From 0bf5d63a4f027038534eb89e244025c062546362 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 24 Jan 2018 13:17:55 +0000 Subject: [PATCH 39/79] #1363 - Moved GitVersionCore packaging logic into cake Had to change nuget package id of GitVersionCore to be GitVersionCore rather than GitVersion - as when the in the csproj is GitVersion (to enable dotnet pack style) VS shows all sorts of build errors - as it seems to get confused that there is also another output in the same solution called GitVersion (i.e the exe). --- build.cake | 65 +++++++++++++++++++++--------- src/GitVersionCore/AssemblyInfo.cs | 2 +- src/GitVersionExe/AssemblyInfo.cs | 2 +- 3 files changed, 47 insertions(+), 22 deletions(-) diff --git a/build.cake b/build.cake index eacab73f11..8c41a9b3b1 100644 --- a/build.cake +++ b/build.cake @@ -18,6 +18,8 @@ bool IsMainGitVersionRepo = StringComparer.OrdinalIgnoreCase.Equals("gittools/gi bool IsPullRequest = BuildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; bool IsMainGitVersionBranch = StringComparer.OrdinalIgnoreCase.Equals("master", BuildSystem.AppVeyor.Environment.Repository.Branch); +string buildDir = "./build/"; + void Build(string configuration, string nugetVersion, string semVersion, string version, string preReleaseTag) { if(IsRunningOnUnix()) @@ -150,11 +152,11 @@ Task("Run-Tests") .IsDependentOn("DogfoodBuild") .Does(() => { - + var settings = new DotNetCoreTestSettings { Configuration = configuration, - NoBuild = true + NoBuild = true, }; DotNetCoreTest("./src/GitVersionCore.Tests/GitVersionCore.Tests.csproj", settings); @@ -192,8 +194,7 @@ Task("Commandline-Package") { ILRepackGitVersionExe(false); - - var buildDir = "./build/"; + var outputDir = buildDir + "NuGetCommandLineBuild"; var toolsDir = outputDir + "/tools"; var libDir = toolsDir + "/lib"; @@ -222,16 +223,8 @@ Task("Commandline-Package") CopyDirectory(targetDir + "lib/", outputDir + "/tools/lib/"); Information("Creating Nuget Package.."); - var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; - - try - { - NuGetPack(outputDir + "/GitVersion.CommandLine.nuspec", nuGetPackSettings); - } - catch(Exception e) - { - Error(e.Dump()); - } + var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; + NuGetPack(outputDir + "/GitVersion.CommandLine.nuspec", nuGetPackSettings); }) .ReportError(exception => @@ -247,8 +240,7 @@ Task("Portable-Package") { ILRepackGitVersionExe(true); - - var buildDir = "./build/"; + var outputDir = buildDir + "NuGetExeBuild"; var toolsDir = outputDir + "/tools"; var libDir = toolsDir + "/lib"; @@ -269,9 +261,6 @@ Task("Portable-Package") CopyFiles("./ILMergeTemp/GitVersion.exe", outputDir + "/tools/"); Information("Copying nuget assets.."); -// - // - // CopyFiles(nugetAssetsPath + "*.ps1", outputDir + "/tools/"); CopyFiles(nugetAssetsPath + "GitVersion.Portable.nuspec", outputDir); @@ -281,20 +270,56 @@ Task("Portable-Package") var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; NuGetPack(outputDir + "/GitVersion.Portable.nuspec", nuGetPackSettings); +}) +.ReportError(exception => +{ + Error(exception.Dump()); }); +Task("GitVersionCore-Package") + .IsDependentOn("Build") + .Does(() => +{ + var outputDir = buildDir + "NuGetRefBuild"; + CreateDirectory(outputDir); + + var msBuildSettings = new DotNetCoreMSBuildSettings(); + msBuildSettings.SetVersion(nugetVersion); + // msBuildSettings.Properties.Add("PackageVersion", nugetVersion); + var settings = new DotNetCorePackSettings + { + Configuration = configuration, + OutputDirectory = outputDir, + NoBuild = true, + MSBuildSettings = msBuildSettings + }; + + DotNetCorePack("./src/GitVersionCore", settings); +}) +.ReportError(exception => +{ + Error(exception.Dump()); +}); + Task("Zip-Files") .IsDependentOn("Build") .IsDependentOn("Commandline-Package") .IsDependentOn("Portable-Package") + .IsDependentOn("GitVersionCore-Package") .IsDependentOn("Run-Tests-In-NUnitConsole") // .IsDependentOn("Run-Tests") .Does(() => { Zip("./build/NuGetCommandLineBuild/Tools/", "build/GitVersion_" + nugetVersion + ".zip"); +}) +.ReportError(exception => +{ + Error(exception.Dump()); + // Report the error. }); + Task("Create-Release-Notes") .IsDependentOn("Build") .WithCriteria(() => IsMainGitVersionRepo && IsMainGitVersionBranch && !IsPullRequest) @@ -349,7 +374,7 @@ Task("Upload-AppVeyor-Artifacts") AppVeyor.UploadArtifact("build/NuGetExeBuild/GitVersion.Portable." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetCommandLineBuild/GitVersion.CommandLine." + nugetVersion +".nupkg"); - AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersion." + nugetVersion +".nupkg"); + AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersionCore." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix"); AppVeyor.UploadArtifact("build/GitVersion_" + nugetVersion + ".zip"); diff --git a/src/GitVersionCore/AssemblyInfo.cs b/src/GitVersionCore/AssemblyInfo.cs index f98800e395..9bfcc80317 100644 --- a/src/GitVersionCore/AssemblyInfo.cs +++ b/src/GitVersionCore/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: InternalsVisibleTo("GitVersionCore.Tests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1494.Branch.feature/netstandard.Sha.8713f12c8472400344b91ee58dcc0d05b554312b")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1495.Branch.feature/netstandard.Sha.505d320fed2a79bac22635e83c83d8f35ca5ea71")] diff --git a/src/GitVersionExe/AssemblyInfo.cs b/src/GitVersionExe/AssemblyInfo.cs index 4b0ff40d26..fd426a6627 100644 --- a/src/GitVersionExe/AssemblyInfo.cs +++ b/src/GitVersionExe/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: InternalsVisibleTo("AcceptanceTests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1494.Branch.feature/netstandard.Sha.8713f12c8472400344b91ee58dcc0d05b554312b")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1495.Branch.feature/netstandard.Sha.505d320fed2a79bac22635e83c83d8f35ca5ea71")] From 677848e054672d7fcc1e43a7bb8a4daad75adeaf Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 24 Jan 2018 13:51:21 +0000 Subject: [PATCH 40/79] #1363 - Moved GitVersion task packaging logic to cake. --- build.cake | 53 +++++++++++++++++++++++++----- src/GitVersion.sln | 3 +- src/GitVersionCore/AssemblyInfo.cs | 2 +- src/GitVersionExe/AssemblyInfo.cs | 2 +- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/build.cake b/build.cake index 8c41a9b3b1..ce42668c49 100644 --- a/build.cake +++ b/build.cake @@ -302,13 +302,41 @@ Task("GitVersionCore-Package") Error(exception.Dump()); }); + +Task("GitVersionTaskPackage") + .Description("Produces the nuget package for GitVersionTask") + .Does(() => +{ + + var outputDir = buildDir + "NuGetTaskBuild"; + CreateDirectory(outputDir); + + var msBuildSettings = new DotNetCoreMSBuildSettings(); + msBuildSettings.SetVersion(nugetVersion); + // msBuildSettings.Properties.Add("PackageVersion", nugetVersion); + var settings = new DotNetCorePackSettings + { + Configuration = configuration, + OutputDirectory = outputDir, + NoBuild = true, + MSBuildSettings = msBuildSettings + }; + + DotNetCorePack("./src/GitVersionTask", settings); + +}) +.ReportError(exception => +{ + Error(exception.Dump()); +}); + Task("Zip-Files") .IsDependentOn("Build") .IsDependentOn("Commandline-Package") .IsDependentOn("Portable-Package") .IsDependentOn("GitVersionCore-Package") + .IsDependentOn("GitVersionTaskPackage") .IsDependentOn("Run-Tests-In-NUnitConsole") - // .IsDependentOn("Run-Tests") .Does(() => { Zip("./build/NuGetCommandLineBuild/Tools/", "build/GitVersion_" + nugetVersion + ".zip"); @@ -316,7 +344,6 @@ Task("Zip-Files") .ReportError(exception => { Error(exception.Dump()); - // Report the error. }); @@ -347,8 +374,13 @@ Task("Create-Release-Notes") { Information("Create-Release-Notes is being skipped, as GitHub Token is not present."); } +}) +.ReportError(exception => +{ + Error(exception.Dump()); }); + Task("Package") .IsDependentOn("Create-Release-Notes") .IsDependentOn("Zip-Files"); @@ -366,18 +398,18 @@ Task("Upload-AppVeyor-Artifacts") "NuGetExeBuild:GitVersion.Portable." + nugetVersion +".nupkg", "NuGetCommandLineBuild:GitVersion.CommandLine." + nugetVersion +".nupkg", "NuGetRefBuild:GitVersion." + nugetVersion +".nupkg", - "NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg", - "GitVersionTfsTaskBuild:gittools.gitversion-" + semVersion +".vsix", - "GemBuild:" + gem, - "zip:GitVersion_" + nugetVersion + ".zip" + "NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg", + "zip:GitVersion_" + nugetVersion + ".zip", + "GitVersionTfsTaskBuild:gittools.gitversion-" + semVersion +".vsix", + "GemBuild:" + gem }); AppVeyor.UploadArtifact("build/NuGetExeBuild/GitVersion.Portable." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetCommandLineBuild/GitVersion.CommandLine." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersionCore." + nugetVersion +".nupkg"); - AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg"); - AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix"); + AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/GitVersion_" + nugetVersion + ".zip"); + AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix"); AppVeyor.UploadArtifact("build/GemBuild/" + gem); AppVeyor.UploadArtifact("build/artifacts"); @@ -388,9 +420,14 @@ Task("Upload-AppVeyor-Artifacts") AppVeyor.UploadArtifact("build/releasenotes.md"); } } +}) +.ReportError(exception => +{ + Error(exception.Dump()); }); + Task("Travis") .IsDependentOn("Run-Tests"); diff --git a/src/GitVersion.sln b/src/GitVersion.sln index aa27c3886c..e345533315 100644 --- a/src/GitVersion.sln +++ b/src/GitVersion.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27004.2006 +VisualStudioVersion = 15.0.27130.2024 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionExe", "GitVersionExe\GitVersionExe.csproj", "{C3578A7B-09A6-4444-9383-0DEAFA4958BD}" EndProject @@ -34,6 +34,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionExe.Tests", "GitV EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TfsTask", "TfsTask", "{A0ED1410-E970-45E8-A357-05605E2B7BFF}" ProjectSection(SolutionItems) = preProject + GitVersionTfsTask\BuildTs.ps1 = GitVersionTfsTask\BuildTs.ps1 GitVersionTfsTask\Create-Vsix.ps1 = GitVersionTfsTask\Create-Vsix.ps1 GitVersionTfsTask\extension-icon.png = GitVersionTfsTask\extension-icon.png GitVersionTfsTask\GitVersion.ts = GitVersionTfsTask\GitVersion.ts diff --git a/src/GitVersionCore/AssemblyInfo.cs b/src/GitVersionCore/AssemblyInfo.cs index 9bfcc80317..5ca0dd6b11 100644 --- a/src/GitVersionCore/AssemblyInfo.cs +++ b/src/GitVersionCore/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: InternalsVisibleTo("GitVersionCore.Tests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1495.Branch.feature/netstandard.Sha.505d320fed2a79bac22635e83c83d8f35ca5ea71")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1496.Branch.feature/netstandard.Sha.0bf5d63a4f027038534eb89e244025c062546362")] diff --git a/src/GitVersionExe/AssemblyInfo.cs b/src/GitVersionExe/AssemblyInfo.cs index fd426a6627..1ef7974273 100644 --- a/src/GitVersionExe/AssemblyInfo.cs +++ b/src/GitVersionExe/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: InternalsVisibleTo("AcceptanceTests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1495.Branch.feature/netstandard.Sha.505d320fed2a79bac22635e83c83d8f35ca5ea71")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1496.Branch.feature/netstandard.Sha.0bf5d63a4f027038534eb89e244025c062546362")] From 7596c104e6c1496bd8371e76743c8360cd76f4b6 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 24 Jan 2018 20:27:02 +0000 Subject: [PATCH 41/79] Corrected case sensitive typo in cake script. --- build.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cake b/build.cake index ce42668c49..d94dcc5954 100644 --- a/build.cake +++ b/build.cake @@ -339,7 +339,7 @@ Task("Zip-Files") .IsDependentOn("Run-Tests-In-NUnitConsole") .Does(() => { - Zip("./build/NuGetCommandLineBuild/Tools/", "build/GitVersion_" + nugetVersion + ".zip"); + Zip("./build/NuGetCommandLineBuild/tools/", "build/GitVersion_" + nugetVersion + ".zip"); }) .ReportError(exception => { From 870d59b05cf96725516d732687387d5e210ef819 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Wed, 24 Jan 2018 20:41:48 +0000 Subject: [PATCH 42/79] Fixe package version cake script problem --- build.cake | 5 +++-- src/GitVersionCore/AssemblyInfo.cs | 2 +- src/GitVersionExe/AssemblyInfo.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build.cake b/build.cake index d94dcc5954..f3ccc1f025 100644 --- a/build.cake +++ b/build.cake @@ -286,7 +286,7 @@ Task("GitVersionCore-Package") var msBuildSettings = new DotNetCoreMSBuildSettings(); msBuildSettings.SetVersion(nugetVersion); - // msBuildSettings.Properties.Add("PackageVersion", nugetVersion); + msBuildSettings.Properties["PackageVersion"] = new string[]{ nugetVersion }; var settings = new DotNetCorePackSettings { Configuration = configuration, @@ -313,7 +313,8 @@ Task("GitVersionTaskPackage") var msBuildSettings = new DotNetCoreMSBuildSettings(); msBuildSettings.SetVersion(nugetVersion); - // msBuildSettings.Properties.Add("PackageVersion", nugetVersion); + + msBuildSettings.Properties["PackageVersion"] = new string[]{ nugetVersion }; var settings = new DotNetCorePackSettings { Configuration = configuration, diff --git a/src/GitVersionCore/AssemblyInfo.cs b/src/GitVersionCore/AssemblyInfo.cs index 5ca0dd6b11..60b4814b35 100644 --- a/src/GitVersionCore/AssemblyInfo.cs +++ b/src/GitVersionCore/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: InternalsVisibleTo("GitVersionCore.Tests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1496.Branch.feature/netstandard.Sha.0bf5d63a4f027038534eb89e244025c062546362")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1498.Branch.feature/netstandard.Sha.7596c104e6c1496bd8371e76743c8360cd76f4b6")] diff --git a/src/GitVersionExe/AssemblyInfo.cs b/src/GitVersionExe/AssemblyInfo.cs index 1ef7974273..5e02fab3d1 100644 --- a/src/GitVersionExe/AssemblyInfo.cs +++ b/src/GitVersionExe/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: InternalsVisibleTo("AcceptanceTests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1496.Branch.feature/netstandard.Sha.0bf5d63a4f027038534eb89e244025c062546362")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1498.Branch.feature/netstandard.Sha.7596c104e6c1496bd8371e76743c8360cd76f4b6")] From 7a062dca4c22b0c0415b9de98c86d2368e33cc8e Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 25 Jan 2018 12:16:48 +0000 Subject: [PATCH 43/79] Updated utilpack dependency. --- src/GitVersionTask/GitVersionTask.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 2df11d4a40..b93423ec6e 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -69,7 +69,7 @@ - + From 314bbf2db78fbf102d8b51805d200d8e61522896 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 25 Jan 2018 14:42:35 +0000 Subject: [PATCH 44/79] Updated nuspec, corrected util pack version. --- src/GitVersionTask/NugetAssets/GitVersionTask.nuspec | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index b06de95efb..94d7050ecb 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -17,15 +17,11 @@ Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer - + - - + From cdc628c36adaff43a68502ebcc6fe4c5c389f2fc Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 10 Mar 2018 14:36:47 +0000 Subject: [PATCH 45/79] Fix for props path on linux. --- .../NugetAssets/build/GitVersionTask.targets | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets b/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets index a097b516f2..1d50060976 100644 --- a/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets +++ b/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets @@ -1,13 +1,18 @@  + + + + + false - true + true - + - + \ No newline at end of file From 6e56f49ed6fc565a76f18b765265309c6c5350bf Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 10 Mar 2018 15:18:43 +0000 Subject: [PATCH 46/79] Commented out upload of vsix and gem in order to get build working. Will have to figure out how to get them produced and then can add them back.. --- build.cake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.cake b/build.cake index f3ccc1f025..aba6bde727 100644 --- a/build.cake +++ b/build.cake @@ -401,8 +401,8 @@ Task("Upload-AppVeyor-Artifacts") "NuGetRefBuild:GitVersion." + nugetVersion +".nupkg", "NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg", "zip:GitVersion_" + nugetVersion + ".zip", - "GitVersionTfsTaskBuild:gittools.gitversion-" + semVersion +".vsix", - "GemBuild:" + gem + // "GitVersionTfsTaskBuild:gittools.gitversion-" + semVersion +".vsix", + // "GemBuild:" + gem }); AppVeyor.UploadArtifact("build/NuGetExeBuild/GitVersion.Portable." + nugetVersion +".nupkg"); @@ -410,8 +410,8 @@ Task("Upload-AppVeyor-Artifacts") AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersionCore." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/GitVersion_" + nugetVersion + ".zip"); - AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix"); - AppVeyor.UploadArtifact("build/GemBuild/" + gem); + // AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix"); + // AppVeyor.UploadArtifact("build/GemBuild/" + gem); AppVeyor.UploadArtifact("build/artifacts"); if(IsMainGitVersionRepo && IsMainGitVersionBranch && !IsPullRequest) From 71c102eef44a36af64b85eff626caea4671ef72d Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 10 Mar 2018 16:20:02 +0000 Subject: [PATCH 47/79] Fixed props file util pack version typo. Have to be careful of this. --- src/GitVersionTask/NugetAssets/build/Infrastructure.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitVersionTask/NugetAssets/build/Infrastructure.props b/src/GitVersionTask/NugetAssets/build/Infrastructure.props index 7232ad14c9..d7f2698cc2 100644 --- a/src/GitVersionTask/NugetAssets/build/Infrastructure.props +++ b/src/GitVersionTask/NugetAssets/build/Infrastructure.props @@ -9,7 +9,7 @@ - $(MSBuildThisFileDirectory)../../../utilpack.nuget.msbuild/2.2.0/build/UtilPack.NuGet.MSBuild.props + $(MSBuildThisFileDirectory)../../../utilpack.nuget.msbuild/2.3.0/build/UtilPack.NuGet.MSBuild.props $([System.IO.Path]::GetFullPath('$(UtilPackNuGetMSBuildPropsPath)')) From 68eaa0334e19bae76d4667c3348163f882ddb98e Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 10 Mar 2018 18:05:23 +0000 Subject: [PATCH 48/79] Improved package versioning for util pack and some other dependencies. --- src/Directory.Build.props | 7 +++++++ src/GitVersion.sln | 1 + .../GitVersionCore.Tests.csproj | 2 +- src/GitVersionCore/GitVersionCore.csproj | 6 +++--- .../GitVersionExe.Tests.csproj | 2 +- .../GitVersionTask.Tests.csproj | 2 +- src/GitVersionTask/GitVersionTask.csproj | 17 ++++++++++++++--- .../NugetAssets/GitVersionTask.nuspec | 6 +++--- .../NugetAssets/build/Infrastructure.props | 4 +++- src/GitVersionTask/UtilPack.Version.props | 6 ++++++ 10 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 src/Directory.Build.props create mode 100644 src/GitVersionTask/UtilPack.Version.props diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000000..603025dd48 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + 1.3.1 + 4.2.1 + [1.0.185] + + \ No newline at end of file diff --git a/src/GitVersion.sln b/src/GitVersion.sln index e345533315..742843e32a 100644 --- a/src/GitVersion.sln +++ b/src/GitVersion.sln @@ -21,6 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\build.sh = ..\build.sh ..\CONTRIBUTING.md = ..\CONTRIBUTING.md ..\deploy.cake = ..\deploy.cake + Directory.Build.props = Directory.Build.props ..\GitVersion.yml = ..\GitVersion.yml ..\LICENSE = ..\LICENSE ..\mkdocs.yml = ..\mkdocs.yml diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index a302ca8d20..558c492278 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -35,7 +35,7 @@ - + diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index b97e39a9da..372354f9c8 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -54,9 +54,9 @@ - - - + + + diff --git a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj index 735937d6ca..83c480c772 100644 --- a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj +++ b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj @@ -38,7 +38,7 @@ - + diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index a759d38ea1..0b11dfa882 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -41,7 +41,7 @@ - + diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index b93423ec6e..8e139d1127 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -1,5 +1,8 @@  + + + Debug AnyCPU @@ -60,16 +63,24 @@ + + + + + + build\ + + - + All - + All - + diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index 94d7050ecb..c0a3336c0d 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -17,11 +17,11 @@ Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer - + - + @@ -29,6 +29,6 @@ - + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/build/Infrastructure.props b/src/GitVersionTask/NugetAssets/build/Infrastructure.props index d7f2698cc2..edeacf76e0 100644 --- a/src/GitVersionTask/NugetAssets/build/Infrastructure.props +++ b/src/GitVersionTask/NugetAssets/build/Infrastructure.props @@ -1,4 +1,5 @@  + @@ -9,7 +10,8 @@ - $(MSBuildThisFileDirectory)../../../utilpack.nuget.msbuild/2.3.0/build/UtilPack.NuGet.MSBuild.props + $(PackageVersion_UtilPackNuGetMSBuild) + $(MSBuildThisFileDirectory)../../../utilpack.nuget.msbuild/$(UtilPackVersion)/build/UtilPack.NuGet.MSBuild.props $([System.IO.Path]::GetFullPath('$(UtilPackNuGetMSBuildPropsPath)')) diff --git a/src/GitVersionTask/UtilPack.Version.props b/src/GitVersionTask/UtilPack.Version.props new file mode 100644 index 0000000000..978b7de7dc --- /dev/null +++ b/src/GitVersionTask/UtilPack.Version.props @@ -0,0 +1,6 @@ + + + 2.4.0 + + + From 66ad78d65f0d1a9ec688e1152fa0b935cc5b945b Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 10 Mar 2018 18:11:27 +0000 Subject: [PATCH 49/79] Set dependency versions in nuspec automatically during build. --- src/GitVersionTask/GitVersionTask.csproj | 2 +- src/GitVersionTask/NugetAssets/GitVersionTask.nuspec | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 8e139d1127..94a5757f3c 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -29,7 +29,7 @@ NugetAssets\GitVersionTask.nuspec 0.0.1-alpha-0001 - version=$(PackageVersion);configuration=$(Configuration) + version=$(PackageVersion);configuration=$(Configuration);utilpackversion=$(PackageVersion_UtilPackNuGetMSBuild);gittoolscoreversion=$(PackageVersion_GitToolsCore) diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index c0a3336c0d..fafdf05de9 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -17,11 +17,11 @@ Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer - - + + - + From c650925b15e866a06708a8e58139529e92d8d3a1 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sun, 11 Mar 2018 14:10:31 +0000 Subject: [PATCH 50/79] Removed costura embedding from GitVersionTask. --- src/GitVersionTask/FodyWeavers.xml | 3 +-- src/GitVersionTask/GitVersionTask.csproj | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/GitVersionTask/FodyWeavers.xml b/src/GitVersionTask/FodyWeavers.xml index 5adf0a8f9f..bb9492639e 100644 --- a/src/GitVersionTask/FodyWeavers.xml +++ b/src/GitVersionTask/FodyWeavers.xml @@ -1,5 +1,4 @@ - - + \ No newline at end of file diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 94a5757f3c..83752b6dc9 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -87,10 +87,7 @@ All - - - All - + From ce1782622c6b9d1770ced057f6c7a25c330dcad1 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sun, 11 Mar 2018 16:56:12 +0000 Subject: [PATCH 51/79] Fix for task not awaited. --- src/GitVersionCore/ExecuteCore.cs | 3 ++- src/GitVersionCore/GitVersionCache.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GitVersionCore/ExecuteCore.cs b/src/GitVersionCore/ExecuteCore.cs index 3132298baf..1080721420 100644 --- a/src/GitVersionCore/ExecuteCore.cs +++ b/src/GitVersionCore/ExecuteCore.cs @@ -6,6 +6,7 @@ namespace GitVersion using System; using System.ComponentModel; using System.Linq; + using System.Threading.Tasks; public class ExecuteCore { @@ -62,7 +63,7 @@ public VersionVariables ExecuteGitVersion(string targetUrl, string dynamicReposi { try { - gitVersionCache.WriteVariablesToDiskCacheAsync(gitPreparer, cacheKey, versionVariables); + gitVersionCache.WriteVariablesToDiskCache(gitPreparer, cacheKey, versionVariables); } catch (AggregateException e) { diff --git a/src/GitVersionCore/GitVersionCache.cs b/src/GitVersionCore/GitVersionCache.cs index c148cf75f8..d7d1783a37 100644 --- a/src/GitVersionCore/GitVersionCache.cs +++ b/src/GitVersionCore/GitVersionCache.cs @@ -17,7 +17,7 @@ public GitVersionCache(IFileSystem fileSystem) this.fileSystem = fileSystem; } - public async Task WriteVariablesToDiskCacheAsync(GitPreparer gitPreparer, GitVersionCacheKey cacheKey, VersionVariables variablesFromCache) + public void WriteVariablesToDiskCache(GitPreparer gitPreparer, GitVersionCacheKey cacheKey, VersionVariables variablesFromCache) { var cacheDir = PrepareCacheDirectory(gitPreparer); var cacheFileName = GetCacheFileName(cacheKey, cacheDir); @@ -46,7 +46,7 @@ public async Task WriteVariablesToDiskCacheAsync(GitPreparer gitPreparer, GitVer }; var retryOperation = new OperationWithExponentialBackoff(new ThreadSleep(), writeCacheOperation, maxRetries: 6); - await retryOperation.ExecuteAsync(); + retryOperation.ExecuteAsync().Wait(); } public static string GetCacheDirectory(GitPreparer gitPreparer) From 92ed30da6d6ca67c637f5b47673a6739341cf4c3 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sun, 11 Mar 2018 17:31:10 +0000 Subject: [PATCH 52/79] Added yamldotnet dependency to nuspec. --- src/GitVersionTask/GitVersionTask.csproj | 2 +- src/GitVersionTask/NugetAssets/GitVersionTask.nuspec | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 83752b6dc9..6fff43202f 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -29,7 +29,7 @@ NugetAssets\GitVersionTask.nuspec 0.0.1-alpha-0001 - version=$(PackageVersion);configuration=$(Configuration);utilpackversion=$(PackageVersion_UtilPackNuGetMSBuild);gittoolscoreversion=$(PackageVersion_GitToolsCore) + version=$(PackageVersion);configuration=$(Configuration);utilpackversion=$(PackageVersion_UtilPackNuGetMSBuild);gittoolscoreversion=$(PackageVersion_GitToolsCore);yamldotnetversion=$(PackageVersion_YamlDotNet) diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index fafdf05de9..cf00a3c794 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -18,7 +18,8 @@ - + + From a1a27d831fbc6de1edeef58b67376fa89c267dee Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sun, 11 Mar 2018 17:38:18 +0000 Subject: [PATCH 53/79] GitVersionTask - allow auto generate of assembly attributes. --- src/GitVersionTask/GitVersionTask.csproj | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 6fff43202f..bf7ff05f1d 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -35,11 +35,11 @@ $(Authors) $(AssemblyName) - false + true @@ -71,6 +71,7 @@ build\ + All @@ -81,9 +82,8 @@ - - - + + All @@ -95,13 +95,7 @@ - - - - - Designer - - + From a6847543d862b5c82c0ce187e992821c512d350a Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Mon, 12 Mar 2018 21:01:15 +0000 Subject: [PATCH 54/79] GitVersion task fix when targeting < netstandard1.5 --- src/GitVersionTask/NugetAssets/GitVersionTask.nuspec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index cf00a3c794..453538a518 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -16,6 +16,9 @@ Copyright GitTools 2015. Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer + + + From 9792af2caa316011e8e858175282b3a38420a26c Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 17 Mar 2018 18:56:26 +0000 Subject: [PATCH 55/79] Gitversion.exe builds for netstandard20 --- src/GitVersionCore.Tests/FodyWeavers.xml | 4 ---- .../GitVersionCore.Tests.csproj | 16 ++-------------- src/GitVersionCore/FodyWeavers.xml | 3 --- src/GitVersionCore/GitVersionCore.csproj | 7 +------ src/GitVersionExe/ArgumentParser.cs | 4 ++++ src/GitVersionExe/Arguments.cs | 7 ++++--- src/GitVersionExe/FodyWeavers.xml | 4 ---- src/GitVersionExe/GitVersionExe.csproj | 18 +++++++++--------- src/GitVersionExe/Program.cs | 11 +++++++++-- src/GitVersionExe/SpecifiedArgumentRunner.cs | 15 ++++++++++++--- src/GitVersionTask.Tests/FodyWeavers.xml | 4 ---- .../GitVersionTask.Tests.csproj | 3 --- src/GitVersionTask/FodyWeavers.xml | 4 ---- src/GitVersionTask/GitVersionTask.csproj | 5 +---- 14 files changed, 42 insertions(+), 63 deletions(-) delete mode 100644 src/GitVersionCore.Tests/FodyWeavers.xml delete mode 100644 src/GitVersionCore/FodyWeavers.xml delete mode 100644 src/GitVersionExe/FodyWeavers.xml delete mode 100644 src/GitVersionTask.Tests/FodyWeavers.xml delete mode 100644 src/GitVersionTask/FodyWeavers.xml diff --git a/src/GitVersionCore.Tests/FodyWeavers.xml b/src/GitVersionCore.Tests/FodyWeavers.xml deleted file mode 100644 index aeb3452852..0000000000 --- a/src/GitVersionCore.Tests/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 558c492278..1591d39ca7 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -43,18 +43,8 @@ - - - - Designer - - - + - @@ -63,8 +53,7 @@ - - + @@ -76,7 +65,6 @@ - diff --git a/src/GitVersionCore/FodyWeavers.xml b/src/GitVersionCore/FodyWeavers.xml deleted file mode 100644 index 70df84a215..0000000000 --- a/src/GitVersionCore/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/GitVersionCore/GitVersionCore.csproj b/src/GitVersionCore/GitVersionCore.csproj index 372354f9c8..ebb4e6db9a 100644 --- a/src/GitVersionCore/GitVersionCore.csproj +++ b/src/GitVersionCore/GitVersionCore.csproj @@ -68,12 +68,7 @@ - - All - - - Designer - + All diff --git a/src/GitVersionExe/ArgumentParser.cs b/src/GitVersionExe/ArgumentParser.cs index 3323686a3c..a4fec8f437 100644 --- a/src/GitVersionExe/ArgumentParser.cs +++ b/src/GitVersionExe/ArgumentParser.cs @@ -128,6 +128,7 @@ public static Arguments ParseArguments(List commandLineArguments) continue; } +#if NETDESKTOP if (name.IsSwitch("exec")) { EnsureArgumentValueCount(values); @@ -135,6 +136,7 @@ public static Arguments ParseArguments(List commandLineArguments) continue; } + if (name.IsSwitch("execargs")) { EnsureArgumentValueCount(values); @@ -166,6 +168,8 @@ public static Arguments ParseArguments(List commandLineArguments) continue; } +#endif + if (name.IsSwitch("updateAssemblyInfo")) { diff --git a/src/GitVersionExe/Arguments.cs b/src/GitVersionExe/Arguments.cs index 910ee131e2..ad21176a46 100644 --- a/src/GitVersionExe/Arguments.cs +++ b/src/GitVersionExe/Arguments.cs @@ -26,20 +26,21 @@ public Arguments() public string DynamicRepositoryLocation; public bool Init; +#if NETDESKTOP public bool Diag; - +#endif public bool IsVersion; public bool IsHelp; public string LogFilePath; public string ShowVariable; public OutputType Output; - +#if NETDESKTOP public string Proj; public string ProjArgs; public string Exec; public string ExecArgs; - +#endif public bool UpdateAssemblyInfo; public ISet UpdateAssemblyInfoFileName; public bool EnsureAssemblyInfo; diff --git a/src/GitVersionExe/FodyWeavers.xml b/src/GitVersionExe/FodyWeavers.xml deleted file mode 100644 index 74f14520c9..0000000000 --- a/src/GitVersionExe/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index 3321c09431..38a50214ba 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -6,7 +6,7 @@ Exe GitVersion GitVersion - net40 + net40;netstandard2 $(SolutionDir)..\build\ false @@ -37,11 +37,15 @@ 1591 AnyCPU - + + + NET40;NETDESKTOP + + + + - - - + @@ -51,10 +55,6 @@ - - - Designer - diff --git a/src/GitVersionExe/Program.cs b/src/GitVersionExe/Program.cs index efa7db3beb..540d71d24f 100644 --- a/src/GitVersionExe/Program.cs +++ b/src/GitVersionExe/Program.cs @@ -70,19 +70,23 @@ static int VerifyArgumentsAndRun() HelpWriter.Write(); return 0; } +#if NETDESKTOP if (arguments.Diag) { arguments.NoCache = true; arguments.Output = OutputType.BuildServer; - } + } +#endif ConfigureLogging(arguments); +#if NETDESKTOP if (arguments.Diag) { Logger.WriteInfo("Dumping commit graph: "); GitTools.LibGitExtensions.DumpGraph(arguments.TargetPath, Logger.WriteInfo, 100); } +#endif if (!Directory.Exists(arguments.TargetPath)) { Logger.WriteWarning(string.Format("The working directory '{0}' does not exist.", arguments.TargetPath)); @@ -104,11 +108,12 @@ static int VerifyArgumentsAndRun() return 0; } +#if NETDESKTOP if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec)) { arguments.Output = OutputType.BuildServer; } - +#endif SpecifiedArgumentRunner.Run(arguments, fileSystem); } catch (WarningException exception) @@ -130,7 +135,9 @@ static int VerifyArgumentsAndRun() try { +#if NETDESKTOP GitTools.LibGitExtensions.DumpGraph(arguments.TargetPath, Logger.WriteInfo, 100); +#endif } catch (Exception dumpGraphException) { diff --git a/src/GitVersionExe/SpecifiedArgumentRunner.cs b/src/GitVersionExe/SpecifiedArgumentRunner.cs index 2f585fef62..b4876b2022 100644 --- a/src/GitVersionExe/SpecifiedArgumentRunner.cs +++ b/src/GitVersionExe/SpecifiedArgumentRunner.cs @@ -62,9 +62,12 @@ public static void Run(Arguments arguments, IFileSystem fileSystem) { assemblyInfoUpdater.Update(); } - - var execRun = RunExecCommandIfNeeded(arguments, targetPath, variables); - var msbuildRun = RunMsBuildIfNeeded(arguments, targetPath, variables); + var execRun = false; + var msbuildRun = false; +#if NETDESKTOP + execRun = RunExecCommandIfNeeded(arguments, targetPath, variables); + msbuildRun = RunMsBuildIfNeeded(arguments, targetPath, variables); +#endif if (!execRun && !msbuildRun) { assemblyInfoUpdater.CommitChanges(); @@ -79,8 +82,11 @@ public static void Run(Arguments arguments, IFileSystem fileSystem) } } +#if NETDESKTOP static bool RunMsBuildIfNeeded(Arguments args, string workingDirectory, VersionVariables variables) { + + if (string.IsNullOrEmpty(args.Proj)) return false; Logger.WriteInfo(string.Format("Launching build tool {0} \"{1}\" {2}", BuildTool, args.Proj, args.ProjArgs)); @@ -95,6 +101,7 @@ static bool RunMsBuildIfNeeded(Arguments args, string workingDirectory, VersionV return true; } + static bool RunExecCommandIfNeeded(Arguments args, string workingDirectory, VersionVariables variables) { if (string.IsNullOrEmpty(args.Exec)) return false; @@ -111,6 +118,8 @@ static bool RunExecCommandIfNeeded(Arguments args, string workingDirectory, Vers return true; } +#endif + static KeyValuePair[] GetEnvironmentalVariables(VersionVariables variables) { return variables diff --git a/src/GitVersionTask.Tests/FodyWeavers.xml b/src/GitVersionTask.Tests/FodyWeavers.xml deleted file mode 100644 index 33a88dc373..0000000000 --- a/src/GitVersionTask.Tests/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index 0b11dfa882..d5b4407780 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -43,8 +43,6 @@ - - @@ -75,7 +73,6 @@ - diff --git a/src/GitVersionTask/FodyWeavers.xml b/src/GitVersionTask/FodyWeavers.xml deleted file mode 100644 index bb9492639e..0000000000 --- a/src/GitVersionTask/FodyWeavers.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index bf7ff05f1d..6da556cace 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -84,10 +84,7 @@ - - - All - + From 385861daea82b5cdfaea0c2a6169826e97e3be9b Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 17 Mar 2018 18:56:56 +0000 Subject: [PATCH 56/79] Added docker files to sln. --- .../DockerBase-Mono}/Dockerfile | 0 src/{DockerBase => Docker/DockerBase-Mono}/readme | 0 Dockerfile => src/Docker/Mono/Dockerfile | 0 src/GitVersion.sln | 13 +++++++++++++ .../NugetAssets/GitVersionTask.nuspec | 2 +- 5 files changed, 14 insertions(+), 1 deletion(-) rename src/{DockerBase => Docker/DockerBase-Mono}/Dockerfile (100%) rename src/{DockerBase => Docker/DockerBase-Mono}/readme (100%) rename Dockerfile => src/Docker/Mono/Dockerfile (100%) diff --git a/src/DockerBase/Dockerfile b/src/Docker/DockerBase-Mono/Dockerfile similarity index 100% rename from src/DockerBase/Dockerfile rename to src/Docker/DockerBase-Mono/Dockerfile diff --git a/src/DockerBase/readme b/src/Docker/DockerBase-Mono/readme similarity index 100% rename from src/DockerBase/readme rename to src/Docker/DockerBase-Mono/readme diff --git a/Dockerfile b/src/Docker/Mono/Dockerfile similarity index 100% rename from Dockerfile rename to src/Docker/Mono/Dockerfile diff --git a/src/GitVersion.sln b/src/GitVersion.sln index 742843e32a..92a81711bc 100644 --- a/src/GitVersion.sln +++ b/src/GitVersion.sln @@ -48,6 +48,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TfsTask", "TfsTask", "{A0ED EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionTask", "GitVersionTask\GitVersionTask.csproj", "{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{98C7108A-09FD-436D-8CA5-DF19E0FC5F8D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DockerBase-Mono", "DockerBase-Mono", "{BD9DA3C6-39E1-4E40-811E-FB59853D5DDA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mono", "Mono", "{6A6E0584-5392-4F03-8C14-799D400941AC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DotnetCore", "DotnetCore", "{E78ADE9E-5573-48E2-890C-EF59CB1BA7ED}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -82,6 +90,11 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {BD9DA3C6-39E1-4E40-811E-FB59853D5DDA} = {98C7108A-09FD-436D-8CA5-DF19E0FC5F8D} + {6A6E0584-5392-4F03-8C14-799D400941AC} = {98C7108A-09FD-436D-8CA5-DF19E0FC5F8D} + {E78ADE9E-5573-48E2-890C-EF59CB1BA7ED} = {98C7108A-09FD-436D-8CA5-DF19E0FC5F8D} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0C1C310E-7A4D-4032-878B-6DC375894C49} EndGlobalSection diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec index 453538a518..160e456e42 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec +++ b/src/GitVersionTask/NugetAssets/GitVersionTask.nuspec @@ -17,7 +17,7 @@ Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer - + From c6e827b0926b5b7b79d7821301aec87d8ee8e1c6 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 17 Mar 2018 19:18:08 +0000 Subject: [PATCH 57/79] Fixed tests. After removing Fody, needed manually call ModuleInit from tests in order to get logger set up. --- src/GitVersionCore.Tests/AssemblyFileVersionTests.cs | 2 +- .../AssemblyInfoFileUpdaterTests.cs | 2 +- .../BuildServers/BuildServerBaseTests.cs | 2 +- .../BuildServers/ContinuaCiTests.cs | 2 +- .../BuildServers/EnvironmentVariableJenkinsTests.cs | 3 ++- .../BuildServers/GitLabCiMessageGenerationTest.cs | 2 +- .../BuildServers/JenkinsMessageGenerationTests.cs | 2 +- src/GitVersionCore.Tests/BuildServers/MyGetTests.cs | 2 +- .../BuildServers/TeamCityTests.cs | 2 +- .../BuildServers/VsoAgentBuildNumberTests.cs | 2 +- .../BuildServers/VsoAgentTests.cs | 2 +- src/GitVersionCore.Tests/CommitDateTests.cs | 2 +- src/GitVersionCore.Tests/ConfigProviderTests.cs | 3 ++- .../Configuration/IgnoreConfigTests.cs | 2 +- src/GitVersionCore.Tests/DocumentationTests.cs | 4 ++-- src/GitVersionCore.Tests/DynamicRepositoryTests.cs | 3 ++- src/GitVersionCore.Tests/ExecuteCoreTests.cs | 3 ++- .../GitRepoMetadataProviderTests.cs | 2 +- src/GitVersionCore.Tests/GitVersionContextTests.cs | 2 +- .../GitVersionInformationGeneratorTests.cs | 2 +- .../InformationalVersionBuilderTests.cs | 3 ++- src/GitVersionCore.Tests/Init/InitScenarios.cs | 2 +- .../IntegrationTests/BranchWithoutCommitScenario.cs | 2 +- .../IntegrationTests/DevelopScenarios.cs | 2 +- .../IntegrationTests/DocumentationSamples.cs | 2 +- .../IntegrationTests/FeatureBranchScenarios.cs | 2 +- .../IntegrationTests/FileSystemTests.cs | 4 ++-- .../IntegrationTests/HotfixBranchScenarios.cs | 2 +- .../IntegrationTests/MainlineDevelopmentMode.cs | 2 +- .../IntegrationTests/MasterScenarios.cs | 2 +- .../IntegrationTests/OtherBranchScenarios.cs | 2 +- .../IntegrationTests/OtherScenarios.cs | 2 +- .../IntegrationTests/PullRequestScenarios.cs | 2 +- .../IntegrationTests/ReleaseBranchScenarios.cs | 2 +- .../IntegrationTests/RemoteRepositoryScenarios.cs | 2 +- .../IntegrationTests/SupportBranchScenarios.cs | 2 +- .../IntegrationTests/SwitchingToGitFlowScenarios.cs | 2 +- .../IntegrationTests/VersionBumpingScenarios.cs | 2 +- src/GitVersionCore.Tests/JsonVersionBuilderTests.cs | 2 +- src/GitVersionCore.Tests/LoggerTest.cs | 2 +- .../OperationWithExponentialBackoffTests.cs | 3 ++- src/GitVersionCore.Tests/SemanticVersionTests.cs | 3 ++- src/GitVersionCore.Tests/TestBase.cs | 11 +++++++++++ src/GitVersionCore.Tests/VariableProviderTests.cs | 5 +++-- .../VersionCalculation/BaseVersionCalculatorTests.cs | 2 +- .../VersionCalculation/NextVersionCalculatorTests.cs | 2 +- .../ConfigNextVersionBaseVersionStrategyTests.cs | 2 +- .../MergeMessageBaseVersionStrategyTests.cs | 2 +- .../VersionInBranchNameBaseVersionStrategyTests.cs | 2 +- .../VersionFilters/MinDateVersionFilterTests.cs | 2 +- .../VersionFilters/ShaVersionFilterTests.cs | 2 +- 51 files changed, 72 insertions(+), 53 deletions(-) create mode 100644 src/GitVersionCore.Tests/TestBase.cs diff --git a/src/GitVersionCore.Tests/AssemblyFileVersionTests.cs b/src/GitVersionCore.Tests/AssemblyFileVersionTests.cs index e09f186191..db65691e48 100644 --- a/src/GitVersionCore.Tests/AssemblyFileVersionTests.cs +++ b/src/GitVersionCore.Tests/AssemblyFileVersionTests.cs @@ -6,7 +6,7 @@ namespace GitVersionCore.Tests using Shouldly; [TestFixture] - public class AssemblyFileVersionTests + public class AssemblyFileVersionTests : TestBase { [TestCase(AssemblyFileVersioningScheme.None, 1, 2, 3, 4, null)] [TestCase(AssemblyFileVersioningScheme.Major, 1, 2, 3, 4, "1.0.0.0")] diff --git a/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs b/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs index 214db2c27f..38593e255c 100644 --- a/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs +++ b/src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs @@ -10,7 +10,7 @@ using Shouldly; [TestFixture] -public class AssemblyInfoFileUpdaterTests +public class AssemblyInfoFileUpdaterTests : TestBase { [SetUp] public void Setup() diff --git a/src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs b/src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs index 2e7fc23413..c224fdc611 100644 --- a/src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs @@ -6,7 +6,7 @@ using Shouldly; [TestFixture] -public class BuildServerBaseTests +public class BuildServerBaseTests : TestBase { [Test] public void BuildNumberIsFullSemVer() diff --git a/src/GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs b/src/GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs index f039f7f546..38edab1c24 100644 --- a/src/GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/ContinuaCiTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; [TestFixture] -public class ContinuaCiTests +public class ContinuaCiTests : TestBase { [Test] diff --git a/src/GitVersionCore.Tests/BuildServers/EnvironmentVariableJenkinsTests.cs b/src/GitVersionCore.Tests/BuildServers/EnvironmentVariableJenkinsTests.cs index 511822d2c4..8a651fd4e7 100644 --- a/src/GitVersionCore.Tests/BuildServers/EnvironmentVariableJenkinsTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/EnvironmentVariableJenkinsTests.cs @@ -1,10 +1,11 @@ using System; using GitVersion; +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; [TestFixture] -public class EnvironmentVariableJenkinsTests +public class EnvironmentVariableJenkinsTests : TestBase { string key = "JENKINS_URL"; string branch = "GIT_BRANCH"; diff --git a/src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs b/src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs index 2c6ea5e39d..12d6c2e60e 100755 --- a/src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs +++ b/src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs @@ -8,7 +8,7 @@ using System.Reflection; [TestFixture] -public class GitLabCiMessageGenerationTests +public class GitLabCiMessageGenerationTests : TestBase { [Test] public void GenerateSetVersionMessageReturnsVersionAsIs_AlthoughThisIsNotUsedByJenkins() diff --git a/src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs b/src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs index 418463dbc9..ed2d13a948 100644 --- a/src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs @@ -8,7 +8,7 @@ using System.Reflection; [TestFixture] -public class JenkinsMessageGenerationTests +public class JenkinsMessageGenerationTests : TestBase { [Test] public void GenerateSetVersionMessageReturnsVersionAsIs_AlthoughThisIsNotUsedByJenkins() diff --git a/src/GitVersionCore.Tests/BuildServers/MyGetTests.cs b/src/GitVersionCore.Tests/BuildServers/MyGetTests.cs index 82a420b7bb..440ca933a9 100644 --- a/src/GitVersionCore.Tests/BuildServers/MyGetTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/MyGetTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; [TestFixture] -public class MyGetTests +public class MyGetTests : TestBase { [Test] public void Develop_branch() diff --git a/src/GitVersionCore.Tests/BuildServers/TeamCityTests.cs b/src/GitVersionCore.Tests/BuildServers/TeamCityTests.cs index c391aca037..3731abfadf 100644 --- a/src/GitVersionCore.Tests/BuildServers/TeamCityTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/TeamCityTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; [TestFixture] -public class TeamCityTests +public class TeamCityTests : TestBase { [Test] public void Develop_branch() diff --git a/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs b/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs index c3aecb813a..16552b821d 100644 --- a/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/VsoAgentBuildNumberTests.cs @@ -5,7 +5,7 @@ using Shouldly; [TestFixture] -public class VsoAgentBuildNumberTests +public class VsoAgentBuildNumberTests : TestBase { string key = "BUILD_BUILDNUMBER"; string logPrefix = "##vso[build.updatebuildnumber]"; diff --git a/src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs b/src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs index e9e629e632..f78abd3476 100644 --- a/src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs +++ b/src/GitVersionCore.Tests/BuildServers/VsoAgentTests.cs @@ -5,7 +5,7 @@ using Shouldly; [TestFixture] -public class VsoAgentTests +public class VsoAgentTests : TestBase { string key = "BUILD_BUILDNUMBER"; diff --git a/src/GitVersionCore.Tests/CommitDateTests.cs b/src/GitVersionCore.Tests/CommitDateTests.cs index 4872031fdd..596a938dbb 100644 --- a/src/GitVersionCore.Tests/CommitDateTests.cs +++ b/src/GitVersionCore.Tests/CommitDateTests.cs @@ -9,7 +9,7 @@ namespace GitVersionCore.Tests { [TestFixture] - public class CommitDateTests + public class CommitDateTests : TestBase { [Test] [TestCase("yyyy-MM-dd", "2017-10-06")] diff --git a/src/GitVersionCore.Tests/ConfigProviderTests.cs b/src/GitVersionCore.Tests/ConfigProviderTests.cs index 0330d5349f..035d4d15b6 100644 --- a/src/GitVersionCore.Tests/ConfigProviderTests.cs +++ b/src/GitVersionCore.Tests/ConfigProviderTests.cs @@ -1,6 +1,7 @@ using GitTools; using GitVersion; using GitVersion.Helpers; +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; using System; @@ -11,7 +12,7 @@ using YamlDotNet.Serialization; [TestFixture] -public class ConfigProviderTests +public class ConfigProviderTests : TestBase { private const string DefaultRepoPath = "c:\\MyGitRepo"; private const string DefaultWorkingPath = "c:\\MyGitRepo\\Working"; diff --git a/src/GitVersionCore.Tests/Configuration/IgnoreConfigTests.cs b/src/GitVersionCore.Tests/Configuration/IgnoreConfigTests.cs index aae3807a23..513e1327a6 100644 --- a/src/GitVersionCore.Tests/Configuration/IgnoreConfigTests.cs +++ b/src/GitVersionCore.Tests/Configuration/IgnoreConfigTests.cs @@ -8,7 +8,7 @@ namespace GitVersionCore.Tests.Configuration { [TestFixture] - public class IgnoreConfigTests + public class IgnoreConfigTests : TestBase { [Test] public void CanDeserialize() diff --git a/src/GitVersionCore.Tests/DocumentationTests.cs b/src/GitVersionCore.Tests/DocumentationTests.cs index b2aed4ab2f..660ea9f356 100644 --- a/src/GitVersionCore.Tests/DocumentationTests.cs +++ b/src/GitVersionCore.Tests/DocumentationTests.cs @@ -4,7 +4,7 @@ using System.Reflection; using GitVersion; - +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; @@ -12,7 +12,7 @@ using YamlDotNet.Serialization; [TestFixture] -public class DocumentationTests +public class DocumentationTests : TestBase { private DirectoryInfo docsDirectory; diff --git a/src/GitVersionCore.Tests/DynamicRepositoryTests.cs b/src/GitVersionCore.Tests/DynamicRepositoryTests.cs index 968f691ae0..a8a2782ca8 100644 --- a/src/GitVersionCore.Tests/DynamicRepositoryTests.cs +++ b/src/GitVersionCore.Tests/DynamicRepositoryTests.cs @@ -1,9 +1,10 @@ using System.IO; using GitVersion; +using GitVersionCore.Tests; using NUnit.Framework; [TestFixture] -public class DynamicRepositoryTests +public class DynamicRepositoryTests : TestBase { string workDirectory; diff --git a/src/GitVersionCore.Tests/ExecuteCoreTests.cs b/src/GitVersionCore.Tests/ExecuteCoreTests.cs index d167b60a52..bb6be7a756 100644 --- a/src/GitVersionCore.Tests/ExecuteCoreTests.cs +++ b/src/GitVersionCore.Tests/ExecuteCoreTests.cs @@ -1,6 +1,7 @@ using GitTools.Testing; using GitVersion; using GitVersion.Helpers; +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; using System; @@ -8,7 +9,7 @@ using System.Text; [TestFixture] -public class ExecuteCoreTests +public class ExecuteCoreTests : TestBase { IFileSystem fileSystem; diff --git a/src/GitVersionCore.Tests/GitRepoMetadataProviderTests.cs b/src/GitVersionCore.Tests/GitRepoMetadataProviderTests.cs index ec7d50c345..aa247383f0 100644 --- a/src/GitVersionCore.Tests/GitRepoMetadataProviderTests.cs +++ b/src/GitVersionCore.Tests/GitRepoMetadataProviderTests.cs @@ -8,7 +8,7 @@ using Shouldly; [TestFixture] - public class GitRepoMetadataProviderTests + public class GitRepoMetadataProviderTests : TestBase { [Test] public void FindsCorrectMergeBaseForForwardMerge() diff --git a/src/GitVersionCore.Tests/GitVersionContextTests.cs b/src/GitVersionCore.Tests/GitVersionContextTests.cs index 21dcbd4d22..96440bf28a 100644 --- a/src/GitVersionCore.Tests/GitVersionContextTests.cs +++ b/src/GitVersionCore.Tests/GitVersionContextTests.cs @@ -7,7 +7,7 @@ using Shouldly; using System.Collections.Generic; - public class GitVersionContextTests + public class GitVersionContextTests : TestBase { [Test] [Theory] diff --git a/src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs b/src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs index a22a8bca1d..49416daadd 100644 --- a/src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs +++ b/src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs @@ -11,7 +11,7 @@ namespace GitVersionCore.Tests { [TestFixture] - public class GitVersionInformationGeneratorTests + public class GitVersionInformationGeneratorTests : TestBase { [SetUp] public void Setup() diff --git a/src/GitVersionCore.Tests/InformationalVersionBuilderTests.cs b/src/GitVersionCore.Tests/InformationalVersionBuilderTests.cs index cc23f81f69..dc2416f1df 100644 --- a/src/GitVersionCore.Tests/InformationalVersionBuilderTests.cs +++ b/src/GitVersionCore.Tests/InformationalVersionBuilderTests.cs @@ -1,9 +1,10 @@ using System; using GitVersion; +using GitVersionCore.Tests; using NUnit.Framework; [TestFixture] -public class InformationalVersionBuilderTests +public class InformationalVersionBuilderTests : TestBase { [TestCase("feature1", "a682956dc1a2752aa24597a0f5cd939f93614509", 1, 2, 3, "unstable", 1, "1.2.3-unstable+1.Branch.feature1.Sha.a682956dc1a2752aa24597a0f5cd939f93614509")] [TestCase("develop", "a682956dc1a2752aa24597a0f5cd939f93614509", 1, 2, 3, "alpha645", null, "1.2.3-alpha.645+Branch.develop.Sha.a682956dc1a2752aa24597a0f5cd939f93614509")] diff --git a/src/GitVersionCore.Tests/Init/InitScenarios.cs b/src/GitVersionCore.Tests/Init/InitScenarios.cs index 57748cc488..4978a81425 100644 --- a/src/GitVersionCore.Tests/Init/InitScenarios.cs +++ b/src/GitVersionCore.Tests/Init/InitScenarios.cs @@ -9,7 +9,7 @@ using TestStack.ConventionTests.ConventionData; [TestFixture] - public class InitScenarios + public class InitScenarios : TestBase { [SetUp] public void Setup() diff --git a/src/GitVersionCore.Tests/IntegrationTests/BranchWithoutCommitScenario.cs b/src/GitVersionCore.Tests/IntegrationTests/BranchWithoutCommitScenario.cs index e7b3793ca9..aec7d8d465 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/BranchWithoutCommitScenario.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/BranchWithoutCommitScenario.cs @@ -4,7 +4,7 @@ using NUnit.Framework; [TestFixture] -public class BranchWithoutCommitScenario +public class BranchWithoutCommitScenario : TestBase { [Test] public void CanTakeVersionFromReleaseBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs index e95d420615..72d9029b9e 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; [TestFixture] -public class DevelopScenarios +public class DevelopScenarios : TestBase { [Test] public void WhenDevelopHasMultipleCommits_SpecifyExistingCommitId() diff --git a/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs b/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs index d61baa7d12..ed834cbd8d 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs @@ -6,7 +6,7 @@ using Shouldly; [TestFixture] -public class DocumentationSamples +public class DocumentationSamples : TestBase { [Test] public void GitFlowFeatureBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs index 7d5bf8c5ae..7bd7506d1a 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/FeatureBranchScenarios.cs @@ -6,7 +6,7 @@ using NUnit.Framework; [TestFixture] -public class FeatureBranchScenarios +public class FeatureBranchScenarios : TestBase { [Test] public void ShouldInheritIncrementCorrectlyWithMultiplePossibleParentsAndWeirdlyNamedDevelopBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/FileSystemTests.cs b/src/GitVersionCore.Tests/IntegrationTests/FileSystemTests.cs index b047022b24..378c30e123 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/FileSystemTests.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/FileSystemTests.cs @@ -2,13 +2,13 @@ using System.Text; using GitVersion.Helpers; - +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; [TestFixture] -public class FileSystemTests +public class FileSystemTests : TestBase { public string TempFilePath { get; set; } diff --git a/src/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs index 285a542958..8481cd3295 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/HotfixBranchScenarios.cs @@ -5,7 +5,7 @@ using NUnit.Framework; [TestFixture] -public class HotfixBranchScenarios +public class HotfixBranchScenarios : TestBase { [Test] // This test actually validates #465 as well diff --git a/src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs b/src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs index f062d66a9c..e5836e87e3 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs @@ -8,7 +8,7 @@ using NUnit.Framework; using System.Collections.Generic; -public class MainlineDevelopmentMode +public class MainlineDevelopmentMode : TestBase { private Config config = new Config { diff --git a/src/GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs index 93f9fc3832..bc5f4dded1 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/MasterScenarios.cs @@ -5,7 +5,7 @@ using NUnit.Framework; [TestFixture] -public class MasterScenarios +public class MasterScenarios : TestBase { [Test] public void CanHandleContinuousDelivery() diff --git a/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs index c1c03b5243..0efcc15121 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs @@ -5,7 +5,7 @@ using Shouldly; [TestFixture] -public class OtherBranchScenarios +public class OtherBranchScenarios : TestBase { [Test] public void CanTakeVersionFromReleaseBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs index 5fef1447c6..e4bda5e637 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs @@ -8,7 +8,7 @@ using System.Collections.Generic; [TestFixture] - public class OtherScenarios + public class OtherScenarios : TestBase { // This is an attempt to automatically resolve the issue where you cannot build // when multiple branches point at the same commit diff --git a/src/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs index 73951c9068..558233eed3 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/PullRequestScenarios.cs @@ -5,7 +5,7 @@ using NUnit.Framework; [TestFixture] -public class PullRequestScenarios +public class PullRequestScenarios : TestBase { [Test] public void CanCalculatePullRequestChanges() diff --git a/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs index 0dacc90c58..06f96b35e1 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs @@ -5,7 +5,7 @@ using NUnit.Framework; [TestFixture] -public class ReleaseBranchScenarios +public class ReleaseBranchScenarios : TestBase { [Test] public void NoMergeBacksToDevelopInCaseThereAreNoChangesInReleaseBranch() diff --git a/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs index 2dedb40287..1812a8a475 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs @@ -8,7 +8,7 @@ using GitTools; [TestFixture] -public class RemoteRepositoryScenarios +public class RemoteRepositoryScenarios : TestBase { [Test] public void GivenARemoteGitRepositoryWithCommits_ThenClonedLocalShouldMatchRemoteVersion() diff --git a/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs index 47f4037dee..2684e9b9b6 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs @@ -4,7 +4,7 @@ using NUnit.Framework; [TestFixture] -public class SupportBranchScenarios +public class SupportBranchScenarios : TestBase { [Test] public void SupportIsCalculatedCorrectly() diff --git a/src/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs index b26e05ca79..61da2ebfab 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/SwitchingToGitFlowScenarios.cs @@ -4,7 +4,7 @@ using NUnit.Framework; [TestFixture] -public class SwitchingToGitFlowScenarios +public class SwitchingToGitFlowScenarios : TestBase { [Test] public void WhenDevelopBranchedFromMasterWithLegacyVersionTags_DevelopCanUseReachableTag() diff --git a/src/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs index bc583af524..aad1a5c164 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/VersionBumpingScenarios.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; [TestFixture] -public class VersionBumpingScenarios +public class VersionBumpingScenarios : TestBase { [Test] public void AppliedPrereleaseTagCausesBump() diff --git a/src/GitVersionCore.Tests/JsonVersionBuilderTests.cs b/src/GitVersionCore.Tests/JsonVersionBuilderTests.cs index 72989d8a99..cfcc45684d 100644 --- a/src/GitVersionCore.Tests/JsonVersionBuilderTests.cs +++ b/src/GitVersionCore.Tests/JsonVersionBuilderTests.cs @@ -5,7 +5,7 @@ using Shouldly; [TestFixture] -public class JsonVersionBuilderTests +public class JsonVersionBuilderTests : TestBase { [SetUp] public void Setup() diff --git a/src/GitVersionCore.Tests/LoggerTest.cs b/src/GitVersionCore.Tests/LoggerTest.cs index e4f43f33a1..e6d0a77278 100644 --- a/src/GitVersionCore.Tests/LoggerTest.cs +++ b/src/GitVersionCore.Tests/LoggerTest.cs @@ -6,7 +6,7 @@ namespace GitVersionCore.Tests { [TestFixture] - public class LoggerTest + public class LoggerTest : TestBase { [Test] [TestCase("http")] diff --git a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs index 699faad16c..9f1b84634f 100644 --- a/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs +++ b/src/GitVersionCore.Tests/OperationWithExponentialBackoffTests.cs @@ -4,9 +4,10 @@ using NUnit.Framework; using Shouldly; using System.Threading.Tasks; +using GitVersionCore.Tests; [TestFixture] -public class OperationWithExponentialBackoffTests +public class OperationWithExponentialBackoffTests : TestBase { [Test] public void RetryOperationThrowsWhenNegativeMaxRetries() diff --git a/src/GitVersionCore.Tests/SemanticVersionTests.cs b/src/GitVersionCore.Tests/SemanticVersionTests.cs index 498d91c998..a44cb3e04c 100644 --- a/src/GitVersionCore.Tests/SemanticVersionTests.cs +++ b/src/GitVersionCore.Tests/SemanticVersionTests.cs @@ -1,9 +1,10 @@ using GitVersion; +using GitVersionCore.Tests; using NUnit.Framework; using Shouldly; [TestFixture] -public class SemanticVersionTests +public class SemanticVersionTests : TestBase { [TestCase("1.2.3", 1, 2, 3, null, null, null, null, null, null, null, null)] diff --git a/src/GitVersionCore.Tests/TestBase.cs b/src/GitVersionCore.Tests/TestBase.cs new file mode 100644 index 0000000000..53381cf9cc --- /dev/null +++ b/src/GitVersionCore.Tests/TestBase.cs @@ -0,0 +1,11 @@ +namespace GitVersionCore.Tests +{ + public class TestBase + { + static TestBase() + { + ModuleInitializer.Initialize(); + } + + } +} diff --git a/src/GitVersionCore.Tests/VariableProviderTests.cs b/src/GitVersionCore.Tests/VariableProviderTests.cs index cebf0d6862..f8bdf1f895 100644 --- a/src/GitVersionCore.Tests/VariableProviderTests.cs +++ b/src/GitVersionCore.Tests/VariableProviderTests.cs @@ -5,8 +5,9 @@ using Shouldly; [TestFixture] -public class VariableProviderTests -{ +public class VariableProviderTests : TestBase +{ + [SetUp] public void Setup() { diff --git a/src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs b/src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs index 7a7057b058..dd53f77941 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/BaseVersionCalculatorTests.cs @@ -12,7 +12,7 @@ using Shouldly; [TestFixture] - public class BaseVersionCalculatorTests + public class BaseVersionCalculatorTests : TestBase { [Test] public void ChoosesHighestVersionReturnedFromStrategies() diff --git a/src/GitVersionCore.Tests/VersionCalculation/NextVersionCalculatorTests.cs b/src/GitVersionCore.Tests/VersionCalculation/NextVersionCalculatorTests.cs index b3b947b796..aade87827e 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/NextVersionCalculatorTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/NextVersionCalculatorTests.cs @@ -10,7 +10,7 @@ using NUnit.Framework; using Shouldly; - public class NextVersionCalculatorTests + public class NextVersionCalculatorTests : TestBase { [Test] public void ShouldIncrementVersionBasedOnConfig() diff --git a/src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs b/src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs index 1938c10d3d..e0a6f8e6cd 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/Strategies/ConfigNextVersionBaseVersionStrategyTests.cs @@ -7,7 +7,7 @@ using Shouldly; [TestFixture] - public class ConfigNextVersionBaseVersionStrategyTests + public class ConfigNextVersionBaseVersionStrategyTests : TestBase { [Test] public void ShouldNotBeIncremented() diff --git a/src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs b/src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs index 18d0892aaa..407940265a 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs @@ -8,7 +8,7 @@ using Shouldly; [TestFixture] - public class MergeMessageBaseVersionStrategyTests + public class MergeMessageBaseVersionStrategyTests : TestBase { [Test] public void ShouldNotAllowIncrementOfVersion() diff --git a/src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs b/src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs index 01afaa0ea8..106d729260 100644 --- a/src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs +++ b/src/GitVersionCore.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs @@ -9,7 +9,7 @@ using Shouldly; [TestFixture] - public class VersionInBranchNameBaseVersionStrategyTests + public class VersionInBranchNameBaseVersionStrategyTests : TestBase { [Test] [TestCase("release-2.0.0", "2.0.0")] diff --git a/src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs b/src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs index 6733c8ad28..a10dda8adf 100644 --- a/src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs +++ b/src/GitVersionCore.Tests/VersionFilters/MinDateVersionFilterTests.cs @@ -8,7 +8,7 @@ namespace GitVersionCore.Tests.VersionFilters { [TestFixture] - public class MinDateVersionFilterTests + public class MinDateVersionFilterTests : TestBase { [Test] public void VerifyNullGuard() diff --git a/src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs b/src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs index 9374fa7b0b..ce36271a4f 100644 --- a/src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs +++ b/src/GitVersionCore.Tests/VersionFilters/ShaVersionFilterTests.cs @@ -8,7 +8,7 @@ namespace GitVersionCore.Tests.VersionFilters { [TestFixture] - public class ShaVersionFilterTests + public class ShaVersionFilterTests : TestBase { [Test] public void VerifyNullGuard() From 91536c107ba91f755f14904fc69965a9ad70fcb0 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 17 Mar 2018 19:39:04 +0000 Subject: [PATCH 58/79] Fix tests after removing fody module init. --- src/GitVersionExe/GitVersionExe.csproj | 2 +- src/GitVersionExe/HelpWriter.cs | 8 +++++--- src/GitVersionTask.Tests/GetVersionTaskTests.cs | 2 +- src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs | 2 +- src/GitVersionTask.Tests/InvalidFileCheckerTests.cs | 2 +- src/GitVersionTask.Tests/TestBase.cs | 9 +++++++++ 6 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 src/GitVersionTask.Tests/TestBase.cs diff --git a/src/GitVersionExe/GitVersionExe.csproj b/src/GitVersionExe/GitVersionExe.csproj index 38a50214ba..96ad53b903 100644 --- a/src/GitVersionExe/GitVersionExe.csproj +++ b/src/GitVersionExe/GitVersionExe.csproj @@ -6,7 +6,7 @@ Exe GitVersion GitVersion - net40;netstandard2 + net40;netcoreapp20 $(SolutionDir)..\build\ false diff --git a/src/GitVersionExe/HelpWriter.cs b/src/GitVersionExe/HelpWriter.cs index 6dc97a5de9..ca2f4161d2 100644 --- a/src/GitVersionExe/HelpWriter.cs +++ b/src/GitVersionExe/HelpWriter.cs @@ -16,6 +16,7 @@ public static void WriteTo(Action writeAction) Assembly assembly = Assembly.GetExecutingAssembly(); VersionWriter.WriteTo(assembly, v => version = v); + string message = "GitVersion " + version + @" Use convention to derive a SemVer product version from a GitFlow or GitHub based repository. @@ -37,7 +38,7 @@ path The directory containing .git. If not defined current directory Currently supported config overrides: tag-prefix /nocache Bypasses the cache, result will not be written to the cache. - # AssemblyInfo updating + # AssemblyInfo updating /updateassemblyinfo Will recursively search for all 'AssemblyInfo.cs' files in the git repo and update them /updateassemblyinfofilename @@ -47,7 +48,7 @@ Specify name of AssemblyInfo file. Can also /updateAssemblyInfo GlobalAssemblyIn it be created with these attributes: AssemblyFileVersion, AssemblyVersion and AssemblyInformationalVersion --- Supports writing version info for: C#, F#, VB - # Remote repository args +# Remote repository args /url Url to remote git repository. /b Name of the branch to use on the remote repository, must be used in combination with /url. /u Username in case authentication is required. @@ -57,7 +58,7 @@ Specify name of AssemblyInfo file. Can also /updateAssemblyInfo GlobalAssemblyIn By default dynamic repositories will be cloned to %tmp%. Use this switch to override /nofetch Disables 'git fetch' during version calculation. Might cause GitVersion to not calculate your version as expected. - # Execute build args +# Execute build args /exec Executes target executable making GitVersion variables available as environmental variables /execargs Arguments for the executable specified by /exec /proj Build a msbuild file, GitVersion variables will be passed as msbuild properties @@ -68,6 +69,7 @@ Specify name of AssemblyInfo file. Can also /updateAssemblyInfo GlobalAssemblyIn gitversion init Configuration utility for gitversion "; + writeAction(message); } } diff --git a/src/GitVersionTask.Tests/GetVersionTaskTests.cs b/src/GitVersionTask.Tests/GetVersionTaskTests.cs index 0030d56da0..a3f6d5c7d1 100644 --- a/src/GitVersionTask.Tests/GetVersionTaskTests.cs +++ b/src/GitVersionTask.Tests/GetVersionTaskTests.cs @@ -6,7 +6,7 @@ using Shouldly; [TestFixture] -public class GetVersionTaskTests +public class GetVersionTaskTests : TestBase { [Test] public void OutputsShouldMatchVariableProvider() diff --git a/src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs b/src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs index 9ba0c96cfc..c928e6735f 100644 --- a/src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs +++ b/src/GitVersionTask.Tests/GitVersionTaskDirectoryTests.cs @@ -8,7 +8,7 @@ using NUnit.Framework; [TestFixture] -public class GitVersionTaskDirectoryTests +public class GitVersionTaskDirectoryTests : TestBase { ExecuteCore executeCore; string gitDirectory; diff --git a/src/GitVersionTask.Tests/InvalidFileCheckerTests.cs b/src/GitVersionTask.Tests/InvalidFileCheckerTests.cs index 9ae2b5c8c3..d22afabd61 100644 --- a/src/GitVersionTask.Tests/InvalidFileCheckerTests.cs +++ b/src/GitVersionTask.Tests/InvalidFileCheckerTests.cs @@ -6,7 +6,7 @@ using GitTools; [TestFixture] -public class InvalidFileCheckerTests +public class InvalidFileCheckerTests : TestBase { string projectDirectory; string projectFile; diff --git a/src/GitVersionTask.Tests/TestBase.cs b/src/GitVersionTask.Tests/TestBase.cs new file mode 100644 index 0000000000..2d183c187f --- /dev/null +++ b/src/GitVersionTask.Tests/TestBase.cs @@ -0,0 +1,9 @@ +public class TestBase +{ + static TestBase() + { + ModuleInitializer.Initialize(); + } + +} + From b4d18e6943d5ab6758d4032da746aac673021e46 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 17 Mar 2018 20:17:20 +0000 Subject: [PATCH 59/79] Cake build now uses dotnet sdk. --- build.cake | 43 +++++++++++------------------- src/GitVersionCore/AssemblyInfo.cs | 2 +- src/GitVersionExe/AssemblyInfo.cs | 2 +- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/build.cake b/build.cake index aba6bde727..63ff3b4370 100644 --- a/build.cake +++ b/build.cake @@ -22,49 +22,36 @@ string buildDir = "./build/"; void Build(string configuration, string nugetVersion, string semVersion, string version, string preReleaseTag) { - if(IsRunningOnUnix()) - { - XBuild("./src/GitVersion.sln", new XBuildSettings() - .SetConfiguration(configuration) - .WithProperty("POSIX", "True") - .SetVerbosity(Verbosity.Minimal)); - } - else - { - - var msBuildSettings = new MSBuildSettings() - .SetConfiguration(configuration) - .SetPlatformTarget(PlatformTarget.MSIL) - // .WithProperty("Platform", "Any CPU") - // .WithProperty("Windows", "True") - .UseToolVersion(MSBuildToolVersion.VS2017) - .SetVerbosity(Verbosity.Normal) - .SetNodeReuse(false); - - if (BuildSystem.AppVeyor.IsRunningOnAppVeyor) + + DotNetBuild("./src/GitVersion.sln", settings => + { + settings.SetConfiguration(configuration) + .SetVerbosity(Verbosity.Minimal) + .WithTarget("Build") + .WithProperty("POSIX",IsRunningOnUnix().ToString()); + + if (BuildSystem.AppVeyor.IsRunningOnAppVeyor) { if (!string.IsNullOrWhiteSpace(nugetVersion)) { - msBuildSettings.WithProperty("GitVersion_NuGetVersion", nugetVersion); + settings.WithProperty("GitVersion_NuGetVersion", nugetVersion); } if (!string.IsNullOrWhiteSpace(semVersion)) { - msBuildSettings.WithProperty("GitVersion_SemVer", semVersion); + settings.WithProperty("GitVersion_SemVer", semVersion); } if (!string.IsNullOrWhiteSpace(version)) { - msBuildSettings.WithProperty("GitVersion_MajorMinorPatch", version); + settings.WithProperty("GitVersion_MajorMinorPatch", version); } if (!string.IsNullOrWhiteSpace(preReleaseTag)) { - msBuildSettings.WithProperty("GitVersion_PreReleaseTag", preReleaseTag); + settings.WithProperty("GitVersion_PreReleaseTag", preReleaseTag); } - } - - MSBuild("./src/GitVersion.sln", msBuildSettings); - } + } + }); } // This build task can be run to just build diff --git a/src/GitVersionCore/AssemblyInfo.cs b/src/GitVersionCore/AssemblyInfo.cs index 60b4814b35..b4a21bb9ee 100644 --- a/src/GitVersionCore/AssemblyInfo.cs +++ b/src/GitVersionCore/AssemblyInfo.cs @@ -10,4 +10,4 @@ [assembly: InternalsVisibleTo("GitVersionCore.Tests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1498.Branch.feature/netstandard.Sha.7596c104e6c1496bd8371e76743c8360cd76f4b6")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1538.Branch.feature/netstandard.Sha.91536c107ba91f755f14904fc69965a9ad70fcb0")] diff --git a/src/GitVersionExe/AssemblyInfo.cs b/src/GitVersionExe/AssemblyInfo.cs index 5e02fab3d1..8830673801 100644 --- a/src/GitVersionExe/AssemblyInfo.cs +++ b/src/GitVersionExe/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: InternalsVisibleTo("AcceptanceTests")] [assembly: InternalsVisibleTo("GitVersionExe.Tests")] -[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1498.Branch.feature/netstandard.Sha.7596c104e6c1496bd8371e76743c8360cd76f4b6")] +[assembly: AssemblyInformationalVersion("4.0.0-netstandard.1+1538.Branch.feature/netstandard.Sha.91536c107ba91f755f14904fc69965a9ad70fcb0")] From acc05c9648b675c1b3d50974b578ace3f363d9e3 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Sat, 17 Mar 2018 21:27:12 +0000 Subject: [PATCH 60/79] New build artifact - GitVersion.CommandLine.DotNetCore.. --- build.cake | 59 ++++++++++++++++++- .../GitVersion.CommandLine.DotNetCore.nuspec | 19 ++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/GitVersionExe/NugetAssets/GitVersion.CommandLine.DotNetCore.nuspec diff --git a/build.cake b/build.cake index 63ff3b4370..123a0c2b90 100644 --- a/build.cake +++ b/build.cake @@ -289,6 +289,60 @@ Task("GitVersionCore-Package") Error(exception.Dump()); }); +Task("GitVersion-DotNet-Package") + .IsDependentOn("Build") + .Does(() => +{ + + // var publishDir = buildDir + "Published"; + // CreateDirectory(outputDir); + + var outputDir = buildDir + "NuGetExeDotNetCoreBuild"; + var toolsDir = outputDir + "/tools"; + var libDir = toolsDir + "/lib"; + + CreateDirectory(outputDir); + CreateDirectory(toolsDir); + CreateDirectory(libDir); + + + var msBuildSettings = new DotNetCoreMSBuildSettings(); + msBuildSettings.SetVersion(nugetVersion); + msBuildSettings.Properties["PackageVersion"] = new string[]{ nugetVersion }; + + var framework = "netcoreapp20"; + + var settings = new DotNetCorePublishSettings + { + Framework = framework, + Configuration = configuration, + OutputDirectory = toolsDir, + MSBuildSettings = msBuildSettings + }; + + DotNetCorePublish("./src/GitVersionExe", settings); + + + + // var targetDir = "./src/GitVersionExe/bin/" + configuration + "/" + framework + "/"; + + var nugetAssetsPath = "./src/GitVersionExe/NugetAssets/"; + Information("Copying files to packaging direcory.."); + + Information("Copying nuget assets.."); + CopyFiles(nugetAssetsPath + "GitVersion.CommandLine.DotNetCore.nuspec", outputDir); + + //Information("Copying libgit2sharp files.."); + //CopyDirectory(targetDir + "lib/", outputDir + "/tools/lib/"); + + var nuGetPackSettings = new NuGetPackSettings { Version = nugetVersion, BasePath = outputDir, OutputDirectory = outputDir }; + NuGetPack(outputDir + "/GitVersion.CommandLine.DotNetCore.nuspec", nuGetPackSettings); +}) +.ReportError(exception => +{ + Error(exception.Dump()); +}); + Task("GitVersionTaskPackage") .Description("Produces the nuget package for GitVersionTask") @@ -324,6 +378,7 @@ Task("Zip-Files") .IsDependentOn("Portable-Package") .IsDependentOn("GitVersionCore-Package") .IsDependentOn("GitVersionTaskPackage") + .IsDependentOn("GitVersion-DotNet-Package") .IsDependentOn("Run-Tests-In-NUnitConsole") .Does(() => { @@ -385,8 +440,9 @@ Task("Upload-AppVeyor-Artifacts") System.IO.File.WriteAllLines("build/artifacts", new[]{ "NuGetExeBuild:GitVersion.Portable." + nugetVersion +".nupkg", "NuGetCommandLineBuild:GitVersion.CommandLine." + nugetVersion +".nupkg", + "NuGetExeDotNetCoreBuild:GitVersion.CommandLine.DotNetCore." + nugetVersion +".nupkg", "NuGetRefBuild:GitVersion." + nugetVersion +".nupkg", - "NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg", + "NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg", "zip:GitVersion_" + nugetVersion + ".zip", // "GitVersionTfsTaskBuild:gittools.gitversion-" + semVersion +".vsix", // "GemBuild:" + gem @@ -394,6 +450,7 @@ Task("Upload-AppVeyor-Artifacts") AppVeyor.UploadArtifact("build/NuGetExeBuild/GitVersion.Portable." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetCommandLineBuild/GitVersion.CommandLine." + nugetVersion +".nupkg"); + AppVeyor.UploadArtifact("build/NuGetExeDotNetCoreBuild/GitVersion.CommandLine.DotNetCore." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersionCore." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/GitVersion_" + nugetVersion + ".zip"); diff --git a/src/GitVersionExe/NugetAssets/GitVersion.CommandLine.DotNetCore.nuspec b/src/GitVersionExe/NugetAssets/GitVersion.CommandLine.DotNetCore.nuspec new file mode 100644 index 0000000000..bd1bc66925 --- /dev/null +++ b/src/GitVersionExe/NugetAssets/GitVersion.CommandLine.DotNetCore.nuspec @@ -0,0 +1,19 @@ + + + + GitVersion.CommandLine.DotNetCore + $version$ + GitVersion.CommandLine.DotNetCore + GitTools and Contributors + GitTools and Contributors + http://www.opensource.org/licenses/mit-license.php + https://github.com/GitTools/GitVersion + https://raw.githubusercontent.com/GitTools/GitVersion/master/docs/img/package_icon.png + false + Derives SemVer information from a repository following GitFlow or GitHubFlow. + en-AU + Git Versioning GitVersion GitFlowVersion GitFlow GitHubFlow SemVer + true + https://github.com/GitTools/GitVersion/releases + + From ad47e39f02bb479290952aea53efe23e908110e6 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Mon, 19 Mar 2018 01:35:59 +0000 Subject: [PATCH 61/79] Added dotnet core docker image to build. --- build.cake | 3 + deploy.cake | 89 +++++++++++++++---- src/Docker/DotNetCore/Dockerfile | 8 ++ .../DockerBase}/Dockerfile | 0 .../DockerBase}/readme | 0 src/Docker/Mono/Dockerfile | 8 +- src/GitVersion.sln | 18 +++- 7 files changed, 101 insertions(+), 25 deletions(-) create mode 100644 src/Docker/DotNetCore/Dockerfile rename src/Docker/{DockerBase-Mono => Mono/DockerBase}/Dockerfile (100%) rename src/Docker/{DockerBase-Mono => Mono/DockerBase}/readme (100%) diff --git a/build.cake b/build.cake index 123a0c2b90..ddeb1b5033 100644 --- a/build.cake +++ b/build.cake @@ -383,6 +383,7 @@ Task("Zip-Files") .Does(() => { Zip("./build/NuGetCommandLineBuild/tools/", "build/GitVersion_" + nugetVersion + ".zip"); + Zip("./build/NuGetExeDotNetCoreBuild/tools/", "build/GitVersionDotNetCore_" + nugetVersion + ".zip"); }) .ReportError(exception => { @@ -444,6 +445,7 @@ Task("Upload-AppVeyor-Artifacts") "NuGetRefBuild:GitVersion." + nugetVersion +".nupkg", "NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg", "zip:GitVersion_" + nugetVersion + ".zip", + "zip-dotnetcore:GitVersionDotNetCore_" + nugetVersion + ".zip" // "GitVersionTfsTaskBuild:gittools.gitversion-" + semVersion +".vsix", // "GemBuild:" + gem }); @@ -454,6 +456,7 @@ Task("Upload-AppVeyor-Artifacts") AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersionCore." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg"); AppVeyor.UploadArtifact("build/GitVersion_" + nugetVersion + ".zip"); + AppVeyor.UploadArtifact("build/GitVersionDotNetCore_" + nugetVersion + ".zip"); // AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix"); // AppVeyor.UploadArtifact("build/GemBuild/" + gem); AppVeyor.UploadArtifact("build/artifacts"); diff --git a/deploy.cake b/deploy.cake index c02b35b545..af1f67543e 100644 --- a/deploy.cake +++ b/deploy.cake @@ -80,11 +80,13 @@ Task("DownloadGitHubReleaseArtifacts") // Have had missing artifacts before, lets fail early in that scenario if (!artifactLookup.ContainsKey("NuGetRefBuild")) { throw new Exception("NuGetRefBuild artifact missing"); } if (!artifactLookup.ContainsKey("NuGetCommandLineBuild")) { throw new Exception("NuGetCommandLineBuild artifact missing"); } + if (!artifactLookup.ContainsKey("NuGetExeDotNetCoreBuild")) { throw new Exception("NuGetExeDotNetCoreBuild artifact missing"); } if (!artifactLookup.ContainsKey("NuGetTaskBuild")) { throw new Exception("NuGetTaskBuild artifact missing"); } if (!artifactLookup.ContainsKey("NuGetExeBuild")) { throw new Exception("NuGetExeBuild artifact missing"); } if (!artifactLookup.ContainsKey("GemBuild")) { throw new Exception("GemBuild artifact missing"); } if (!artifactLookup.ContainsKey("GitVersionTfsTaskBuild")) { throw new Exception("GitVersionTfsTaskBuild artifact missing"); } if (!artifactLookup.ContainsKey("zip")) { throw new Exception("zip artifact missing"); } + if (!artifactLookup.ContainsKey("zip-dotnetcore")) { throw new Exception("zip-dotnetcore artifact missing"); } }); Task("Publish-NuGetPackage") @@ -121,6 +123,23 @@ Task("Publish-NuGetCommandLine") publishingError = true; }); +Task("Publish-NuGetExeDotNetCore") + .IsDependentOn("DownloadGitHubReleaseArtifacts") + .Does(() => +{ + NuGetPush( + "./releaseArtifacts/" + artifactLookup["NuGetExeDotNetCoreBuild"], + new NuGetPushSettings { + ApiKey = EnvironmentVariable("NuGetApiKey"), + Source = "https://www.nuget.org/api/v2/package" + }); +}) +.OnError(exception => +{ + Information("Publish-NuGet Task failed, but continuing with next Task..."); + publishingError = true; +}); + Task("Publish-MsBuildTask") .IsDependentOn("DownloadGitHubReleaseArtifacts") @@ -187,37 +206,61 @@ Task("Publish-VstsTask") } }); - -Task("Publish-DockerImage") - .IsDependentOn("DownloadGitHubReleaseArtifacts") - .Does(() => +// PublishDocker("gittools/gitversion", tag, "content.zip", "/some/path/DockerFile"); +bool PublishDocker(string name, tagName, contentZip, dockerFilePath, containerVolume) { + Information("Starting Docker Build for Image: " + name); + var username = EnvironmentVariable("DOCKER_USERNAME"); var password = EnvironmentVariable("DOCKER_PASSWORD"); - if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) + + if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { Warning("Skipping docker publish due to missing credentials"); - return; + return false; } - var returnCode = StartProcess("docker", new ProcessSettings + // copy the docker file to a build directory, along with the contents of the specified content.zip. + // This directory should then contain all we need for the docker build. + var dockerBuildFolder = "./build/Docker/"; + CreateDirectory(dockerBuildFolder); + + //var folderName = name.Replace("/", "-"); + var dockerFileBuildFolder = dockerBuildFolder + name; + CreateDirectory(dockerFileBuildFolder); + + Information("Copying docker file to " + dockerFileBuildFolder); + CopyFiles(dockerFilePath, dockerFileBuildFolder); + + var contentPath = "/content"; + var contentFolder = dockerFileBuildFolder + contentPath; + + Information("Extracting docker image content to " + contentFolder); + Unzip(contentZip, contentFolder); + + var dockerFilePathForBuild = dockerFileBuildFolder + "/DockerFile"; + Information("Beginning Docker Build command for " + dockerFilePathForBuild); + + var returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "build . --build-arg GitVersionZip=" + artifactLookup["zip"] + " --tag gittools/gitversion:" + tag + Arguments = "build -f " + dockerFilePathForBuild + " " + dockerFileBuildFolder + " --build-arg contentFolder=" + contentPath + " --tag " + name + ":" + tagName }); + if (returnCode != 0) { Information("Publish-DockerImage Task failed to build image, but continuing with next Task..."); publishingError = true; - return; + return false; } returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "run -v " + System.IO.Directory.GetCurrentDirectory() + ":/repo gittools/gitversion:" + tag + Arguments = "run -v " + System.IO.Directory.GetCurrentDirectory() + ":" + containerVolume + " " + name + ":" + tag }); + if (returnCode != 0) { Information("Publish-DockerImage Task failed to run built image, but continuing with next Task..."); publishingError = true; - return; + return false; } // Login to dockerhub @@ -228,39 +271,51 @@ Task("Publish-DockerImage") if (returnCode != 0) { Information("Publish-DockerImage Task failed to login, but continuing with next Task..."); publishingError = true; - return; + return false; } // Publish Tag returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "push gittools/gitversion:" + tag + Arguments = "push " + name + ":" + tag }); if (returnCode != 0) { Information("Publish-DockerImage Task failed push version tag, but continuing with next Task..."); publishingError = true; - return; + return false; } // Publish latest returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "tag gittools/gitversion:" + tag + " gittools/gitversion:latest" + Arguments = "tag " + name + ":" + tag + " " + name + ":latest" }); if (returnCode != 0) { Information("Publish-DockerImage Task failed latest tag, but continuing with next Task..."); - publishingError = true; + publishingError = true; } + returnCode = StartProcess("docker", new ProcessSettings { - Arguments = "push gittools/gitversion:latest" + Arguments = "push " + name + ":latest" }); if (returnCode != 0) { Information("Publish-DockerImage Task failed latest tag, but continuing with next Task..."); publishingError = true; + return false; } + +} + +Task("Publish-DockerImage") + .IsDependentOn("DownloadGitHubReleaseArtifacts") + .Does(() => +{ + PublishDocker("gittools/gitversion", tag, artifactLookup["zip"], "src/Docker/Mono/DockerFile", "/repo"); + PublishDocker("gittools/gitversion-dotnetcore", tag, artifactLookup["zip-dotnetcore"], "src/Docker/DotNetCore/DockerFile", "c:/repo"); }); + Task("Deploy") .IsDependentOn("Publish-NuGetPackage") .IsDependentOn("Publish-NuGetCommandLine") diff --git a/src/Docker/DotNetCore/Dockerfile b/src/Docker/DotNetCore/Dockerfile new file mode 100644 index 0000000000..62ae308c35 --- /dev/null +++ b/src/Docker/DotNetCore/Dockerfile @@ -0,0 +1,8 @@ +FROM microsoft/dotnet:2.0-runtime +LABEL maintainers="GitTools Maintainers" +ARG contentFolder + +WORKDIR /app +COPY $contentFolder/**/* ./ + +ENTRYPOINT ["dotnet", "GitVersion.dll"] \ No newline at end of file diff --git a/src/Docker/DockerBase-Mono/Dockerfile b/src/Docker/Mono/DockerBase/Dockerfile similarity index 100% rename from src/Docker/DockerBase-Mono/Dockerfile rename to src/Docker/Mono/DockerBase/Dockerfile diff --git a/src/Docker/DockerBase-Mono/readme b/src/Docker/Mono/DockerBase/readme similarity index 100% rename from src/Docker/DockerBase-Mono/readme rename to src/Docker/Mono/DockerBase/readme diff --git a/src/Docker/Mono/Dockerfile b/src/Docker/Mono/Dockerfile index 35fa9a1b39..e765eb0be8 100644 --- a/src/Docker/Mono/Dockerfile +++ b/src/Docker/Mono/Dockerfile @@ -1,12 +1,10 @@ FROM gittools/libgit2sharp-mono MAINTAINER GitTools Maintainers -ARG GitVersionZip +ARG contentFolder -# Add GitVersion - -ADD ./releaseArtifacts/$GitVersionZip . -RUN unzip -d /usr/lib/GitVersion/ $GitVersionZip && rm $GitVersionZip +# Copy GitVersion +COPY $contentFolder /usr/lib/GitVersion/ WORKDIR /usr/lib/GitVersion/ # Libgit2 can't resolve relative paths, patch to absolute path diff --git a/src/GitVersion.sln b/src/GitVersion.sln index 92a81711bc..c018de2420 100644 --- a/src/GitVersion.sln +++ b/src/GitVersion.sln @@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\.gitattributes = ..\.gitattributes ..\.gitignore = ..\.gitignore ..\.travis.yml = ..\.travis.yml + ..\appveyor.deploy.yml = ..\appveyor.deploy.yml ..\appveyor.yml = ..\appveyor.yml ..\BREAKING CHANGES.md = ..\BREAKING CHANGES.md ..\build.cake = ..\build.cake @@ -21,6 +22,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\build.sh = ..\build.sh ..\CONTRIBUTING.md = ..\CONTRIBUTING.md ..\deploy.cake = ..\deploy.cake + ..\deploy.ps1 = ..\deploy.ps1 Directory.Build.props = Directory.Build.props ..\GitVersion.yml = ..\GitVersion.yml ..\LICENSE = ..\LICENSE @@ -50,11 +52,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitVersionTask", "GitVersio EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{98C7108A-09FD-436D-8CA5-DF19E0FC5F8D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DockerBase-Mono", "DockerBase-Mono", "{BD9DA3C6-39E1-4E40-811E-FB59853D5DDA}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mono", "Mono", "{6A6E0584-5392-4F03-8C14-799D400941AC}" + ProjectSection(SolutionItems) = preProject + Docker\Mono\Dockerfile = Docker\Mono\Dockerfile + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DotnetCore", "DotnetCore", "{E78ADE9E-5573-48E2-890C-EF59CB1BA7ED}" + ProjectSection(SolutionItems) = preProject + Docker\DotNetCore\Dockerfile = Docker\DotNetCore\Dockerfile + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DockerBase", "DockerBase", "{C4479215-01B1-4EC0-A33D-C90D1579BD13}" + ProjectSection(SolutionItems) = preProject + Docker\Mono\DockerBase\Dockerfile = Docker\Mono\DockerBase\Dockerfile + Docker\Mono\DockerBase\readme = Docker\Mono\DockerBase\readme + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -91,9 +103,9 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {BD9DA3C6-39E1-4E40-811E-FB59853D5DDA} = {98C7108A-09FD-436D-8CA5-DF19E0FC5F8D} {6A6E0584-5392-4F03-8C14-799D400941AC} = {98C7108A-09FD-436D-8CA5-DF19E0FC5F8D} {E78ADE9E-5573-48E2-890C-EF59CB1BA7ED} = {98C7108A-09FD-436D-8CA5-DF19E0FC5F8D} + {C4479215-01B1-4EC0-A33D-C90D1579BD13} = {6A6E0584-5392-4F03-8C14-799D400941AC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0C1C310E-7A4D-4032-878B-6DC375894C49} From 784660a9808bca99b29cd084cb92738eedc72f84 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 12:42:03 +0100 Subject: [PATCH 62/79] Update travis.yml to add dotnet sdk. --- .travis.yml | 8 +++++--- build.cake | 13 ++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f95b12cf3..bf09dc0bd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,17 @@ language: csharp -sudo: false +sudo: required +dist: trusty +dotnet: 2.0.0 mono: - latest os: - linux - osx before_install: - - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags + - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags script: - ./build.sh cache: directories: - src/packages - - tools + - tools \ No newline at end of file diff --git a/build.cake b/build.cake index ddeb1b5033..5e6466fa7b 100644 --- a/build.cake +++ b/build.cake @@ -113,15 +113,13 @@ Task("Build") }); Task("Run-Tests-In-NUnitConsole") + .WithCriteria(IsRunningOnWindows()) .IsDependentOn("DogfoodBuild") .Does(() => { var settings = new NUnit3Settings(); - var targetFramework = "net461"; - if(IsRunningOnUnix()) - { - settings.Where = "cat != NoMono"; - } + var targetFramework = "net461"; + NUnit3(new [] { "src/GitVersionCore.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionCore.Tests.dll", "src/GitVersionExe.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionExe.Tests.dll", @@ -136,10 +134,10 @@ Task("Run-Tests-In-NUnitConsole") Task("Run-Tests") + .WithCriteria(IsRunningOnUnix()) .IsDependentOn("DogfoodBuild") .Does(() => -{ - +{ var settings = new DotNetCoreTestSettings { Configuration = configuration, @@ -380,6 +378,7 @@ Task("Zip-Files") .IsDependentOn("GitVersionTaskPackage") .IsDependentOn("GitVersion-DotNet-Package") .IsDependentOn("Run-Tests-In-NUnitConsole") + .IsDependentOn("Run-Tests") .Does(() => { Zip("./build/NuGetCommandLineBuild/tools/", "build/GitVersion_" + nugetVersion + ".zip"); From 1613cb3d59b3ef37b96dc959c1ffc3b40436a2c9 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 12:44:56 +0100 Subject: [PATCH 63/79] Reverted a change to cake script to keep using nunit console runner. --- build.cake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/build.cake b/build.cake index 5e6466fa7b..b688b092ca 100644 --- a/build.cake +++ b/build.cake @@ -112,14 +112,17 @@ Task("Build") Build(configuration, nugetVersion, semVersion, version, preReleaseTag); }); -Task("Run-Tests-In-NUnitConsole") - .WithCriteria(IsRunningOnWindows()) +Task("Run-Tests-In-NUnitConsole") .IsDependentOn("DogfoodBuild") .Does(() => { var settings = new NUnit3Settings(); var targetFramework = "net461"; - + if(IsRunningOnUnix()) + { + settings.Where = "cat != NoMono"; + } + NUnit3(new [] { "src/GitVersionCore.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionCore.Tests.dll", "src/GitVersionExe.Tests/bin/" + configuration + "/" + targetFramework + "/GitVersionExe.Tests.dll", @@ -132,9 +135,8 @@ Task("Run-Tests-In-NUnitConsole") } }); - -Task("Run-Tests") - .WithCriteria(IsRunningOnUnix()) +// Note: this task is not used for time being as unable to produce sensible test results output file via dotnet cli.. so using nunit console runner above instead. +Task("Run-Tests") .IsDependentOn("DogfoodBuild") .Does(() => { @@ -378,7 +380,6 @@ Task("Zip-Files") .IsDependentOn("GitVersionTaskPackage") .IsDependentOn("GitVersion-DotNet-Package") .IsDependentOn("Run-Tests-In-NUnitConsole") - .IsDependentOn("Run-Tests") .Does(() => { Zip("./build/NuGetCommandLineBuild/tools/", "build/GitVersion_" + nugetVersion + ".zip"); From 714342ed8f9d4e500102644f804483250cf36846 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 13:22:16 +0100 Subject: [PATCH 64/79] Updated dotnet sdk to 2.1.4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf09dc0bd5..96d681bd76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp sudo: required dist: trusty -dotnet: 2.0.0 +dotnet: 2.1.4 mono: - latest os: From 20f13aba8037133837ee0f695b5c91fc5f873eaa Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 17:00:58 +0100 Subject: [PATCH 65/79] Cake update to get fix: https://github.com/cake-build/cake/issues/2063 --- tools/packages.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/packages.config b/tools/packages.config index 0002e9d537..0581e5aec2 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,5 +1,5 @@ - - + + From 22484ed0e23879a3851c3e49e13787cd083238a3 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 17:56:49 +0100 Subject: [PATCH 66/79] Try mono 5.4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 96d681bd76..91987366c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: required dist: trusty dotnet: 2.1.4 mono: - - latest + - 5.4 os: - linux - osx From 404fde6fb7956b2ab3613b8a95b07fc8cf1cdbc6 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 17:59:40 +0100 Subject: [PATCH 67/79] Try mono 5.4.0.201 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 91987366c6..35dd20855a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: required dist: trusty dotnet: 2.1.4 mono: - - 5.4 + - 5.4.0.201 os: - linux - osx From 48cea45fec189c92a54a716e085c9e2bdd1436ca Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 18:10:56 +0100 Subject: [PATCH 68/79] Change mono to 5.4.2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 35dd20855a..f44e3ad886 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: required dist: trusty dotnet: 2.1.4 mono: - - 5.4.0.201 + - 5.4.0 os: - linux - osx From cd83398ad3d939d6a77af68c040843b79f09748b Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 20:13:41 +0100 Subject: [PATCH 69/79] Change mono on travis to 5.4.1 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f44e3ad886..9d543c2b68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,8 @@ sudo: required dist: trusty dotnet: 2.1.4 mono: - - 5.4.0 + - 5.4.1 + - latest os: - linux - osx From 8327129184c21f8a2a45df041c59e1e901fbe1cd Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 20:24:00 +0100 Subject: [PATCH 70/79] Add in dotnet sdk env var for telemetry optout etc. --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d543c2b68..868f49b11d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp sudo: required dist: trusty -dotnet: 2.1.4 +dotnet: 2.0.3 mono: - 5.4.1 - latest @@ -15,4 +15,8 @@ script: cache: directories: - src/packages - - tools \ No newline at end of file + - tools +env: + global: + - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true \ No newline at end of file From 566d38332e4be7e3c93469715b389cca5a7cd953 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 21:11:42 +0100 Subject: [PATCH 71/79] try mono 5.2.0 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 868f49b11d..415f7c2038 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ sudo: required dist: trusty dotnet: 2.0.3 mono: + - 5.2.0 - 5.4.1 - latest os: From 085896a831410729f422e993ef85632ae4597d8c Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 21:17:02 +0100 Subject: [PATCH 72/79] Added mono 5.4.0 to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 415f7c2038..c0a238bd66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ dotnet: 2.0.3 mono: - 5.2.0 - 5.4.1 + - 5.4.0 - latest os: - linux From f1141e641933c10110bd592bfb3d6941634ec53e Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Thu, 5 Apr 2018 21:18:00 +0100 Subject: [PATCH 73/79] Try dotnet core sdk 2.1.103 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c0a238bd66..127180d488 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp sudo: required dist: trusty -dotnet: 2.0.3 +dotnet: 2.1.103 mono: - 5.2.0 - 5.4.1 From 3cebff4267dcf837351ad0c4cf942f926429ff78 Mon Sep 17 00:00:00 2001 From: Darrell Tunnell Date: Fri, 6 Apr 2018 16:09:19 +0100 Subject: [PATCH 74/79] Cahged cake to diagnostic verbosity. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 127180d488..00ca52ef6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ os: before_install: - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags script: - - ./build.sh + - ./build.sh -v Diagnostic cache: directories: - src/packages From cfe2711345ee34a23b3a2a75a18cc72e4287c4b0 Mon Sep 17 00:00:00 2001 From: Farthom Date: Wed, 9 May 2018 10:00:59 -0600 Subject: [PATCH 75/79] Fix for deserializing DateTimeOffset. (Bug in YAML.net) https://github.com/aaubry/YamlDotNet/issues/293 --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 603025dd48..6e345ab46f 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ 1.3.1 - 4.2.1 + 4.2.3 [1.0.185] \ No newline at end of file From 367e79141cc2b7758bf42bdd5ceb1e823008803c Mon Sep 17 00:00:00 2001 From: Farthom Date: Wed, 9 May 2018 12:19:39 -0600 Subject: [PATCH 76/79] Fix for GitVersionCore.Tests.csproj not using common shared package version properties. --- src/GitVersionCore.Tests/GitVersionCore.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 1591d39ca7..d1fc934800 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -43,7 +43,7 @@ - + From f770d40f40f84fc9ed4e28e0855ace39f07a6227 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Wed, 23 May 2018 11:21:08 +0300 Subject: [PATCH 77/79] updated Shouldly --- src/GitVersionCore.Tests/GitVersionCore.Tests.csproj | 2 +- src/GitVersionExe.Tests/GitVersionExe.Tests.csproj | 2 +- src/GitVersionTask.Tests/GitVersionTask.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj index d1fc934800..83cde8af1c 100644 --- a/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/src/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -41,7 +41,7 @@ - + diff --git a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj index 83c480c772..d2a5c3aa2a 100644 --- a/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj +++ b/src/GitVersionExe.Tests/GitVersionExe.Tests.csproj @@ -45,7 +45,7 @@ - + diff --git a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj index d5b4407780..b58c15326f 100644 --- a/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/src/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -51,7 +51,7 @@ - + From 33c15191421a6195ffdbea4172b2916370398af2 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Wed, 23 May 2018 11:22:35 +0300 Subject: [PATCH 78/79] update cake to 0.27.2, remove travis cache, using MSBuild instead of DotNetBuild --- .travis.yml | 9 +-------- build.cake | 4 ++-- tools/packages.config | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00ca52ef6f..5259e80a37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,8 @@ language: csharp sudo: required dist: trusty -dotnet: 2.1.103 +dotnet: 2.1.105 mono: - - 5.2.0 - - 5.4.1 - - 5.4.0 - latest os: - linux @@ -14,10 +11,6 @@ before_install: - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags script: - ./build.sh -v Diagnostic -cache: - directories: - - src/packages - - tools env: global: - DOTNET_CLI_TELEMETRY_OPTOUT: 1 diff --git a/build.cake b/build.cake index b688b092ca..fb318ecdcd 100644 --- a/build.cake +++ b/build.cake @@ -23,7 +23,7 @@ string buildDir = "./build/"; void Build(string configuration, string nugetVersion, string semVersion, string version, string preReleaseTag) { - DotNetBuild("./src/GitVersion.sln", settings => + MSBuild("./src/GitVersion.sln", settings => { settings.SetConfiguration(configuration) .SetVerbosity(Verbosity.Minimal) @@ -477,7 +477,7 @@ Task("Upload-AppVeyor-Artifacts") Task("Travis") - .IsDependentOn("Run-Tests"); + .IsDependentOn("Run-Tests-In-NUnitConsole"); Task("Default") .IsDependentOn("Upload-AppVeyor-Artifacts"); diff --git a/tools/packages.config b/tools/packages.config index 0581e5aec2..0f070f2afe 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,5 +1,5 @@ - - + + From 835493e0f9f63da86a15e47dd19c85e5ee45fbe8 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Thu, 24 May 2018 11:24:27 +0300 Subject: [PATCH 79/79] running the tests using dotnet test --- build.cake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build.cake b/build.cake index fb318ecdcd..10930a0e24 100644 --- a/build.cake +++ b/build.cake @@ -142,8 +142,9 @@ Task("Run-Tests") { var settings = new DotNetCoreTestSettings { - Configuration = configuration, - NoBuild = true, + Configuration = configuration, + NoBuild = true, + Filter = "TestCategory!=NoMono" }; DotNetCoreTest("./src/GitVersionCore.Tests/GitVersionCore.Tests.csproj", settings); @@ -474,10 +475,8 @@ Task("Upload-AppVeyor-Artifacts") Error(exception.Dump()); }); - - Task("Travis") - .IsDependentOn("Run-Tests-In-NUnitConsole"); + .IsDependentOn("Run-Tests"); Task("Default") .IsDependentOn("Upload-AppVeyor-Artifacts");