Example #1
0
        public void InnerExecute()
        {
            Tuple <CachedVersion, GitVersionContext> result;
            var gitDirectory = GitDirFinder.TreeWalkForDotGitDir(SolutionDirectory);

            if (gitDirectory == null)
            {
                throw new DirectoryNotFoundException(string.Format("Unable to locate a git repository in \"{0}\". Make sure that the solution is located in a git controlled folder. If you are using continous integration make sure that the sources are checked out on the build agent.", SolutionDirectory));
            }

            var configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out result, configuration, NoFetch))
            {
                return;
            }

            var authentication = new Authentication();

            var cachedVersion            = result.Item1;
            var gitVersionContext        = result.Item2;
            var config                   = gitVersionContext.Configuration;
            var assemblyVersioningScheme = config.AssemblyVersioningScheme;
            var versioningMode           = config.VersioningMode;

            var variablesFor = VariableProvider.GetVariablesFor(
                cachedVersion.SemanticVersion, assemblyVersioningScheme, versioningMode,
                config.ContinuousDeploymentFallbackTag,
                gitVersionContext.IsCurrentCommitTagged);

            WriteIntegrationParameters(cachedVersion, BuildServerList.GetApplicableBuildServers(authentication), variablesFor);
        }
Example #2
0
        public override bool Execute()
        {
            try
            {
                VersionVariables variables;

                if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out variables, NoFetch, new Authentication(), fileSystem))
                {
                    var thisType = typeof(GetVersion);
                    foreach (var variable in variables)
                    {
                        thisType.GetProperty(variable.Key).SetValue(this, variable.Value, null);
                    }
                }
                return(true);
            }
            catch (WarningException errorException)
            {
                logger.LogWarning(errorException.Message);
                return(true);
            }
            catch (Exception exception)
            {
                logger.LogError("Error occurred: " + exception);
                return(false);
            }
            finally
            {
                Logger.Reset();
            }
        }
Example #3
0
 public override bool Execute()
 {
     try
     {
         SemanticVersion versionAndBranch;
         if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch))
         {
             var thisType  = typeof(GetVersion);
             var variables = VariableProvider.GetVariablesFor(versionAndBranch);
             foreach (var variable in variables)
             {
                 thisType.GetProperty(variable.Key).SetValue(this, variable.Value, null);
             }
         }
         return(true);
     }
     catch (WarningException errorException)
     {
         logger.LogWarning(errorException.Message);
         return(true);
     }
     catch (Exception exception)
     {
         logger.LogError("Error occurred: " + exception);
         return(false);
     }
     finally
     {
         Logger.Reset();
     }
 }
Example #4
0
        public void InnerExecute()
        {
            Tuple <CachedVersion, GitVersionContext> result;
            var gitDirectory  = GitDirFinder.TreeWalkForGitDir(SolutionDirectory);
            var configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out result, configuration))
            {
                return;
            }

            var authentication = new Authentication();

            var cachedVersion            = result.Item1;
            var gitVersionContext        = result.Item2;
            var config                   = gitVersionContext.Configuration;
            var assemblyVersioningScheme = config.AssemblyVersioningScheme;
            var versioningMode           = config.VersioningMode;

            var variablesFor = VariableProvider.GetVariablesFor(
                cachedVersion.SemanticVersion, assemblyVersioningScheme, versioningMode,
                config.ContinuousDeploymentFallbackTag,
                gitVersionContext.IsCurrentCommitTagged);

            WriteIntegrationParameters(cachedVersion, BuildServerList.GetApplicableBuildServers(authentication), variablesFor);
        }
Example #5
0
        public void InnerExecute()
        {
            TempFileTracker.DeleteTempFiles();

            InvalidFileChecker.CheckForInvalidFiles(CompileFiles, ProjectFile);

            var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory);

            if (string.IsNullOrEmpty(gitDirectory))
            {
                return;
            }

            var configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);

            if (!string.IsNullOrEmpty(AssemblyVersioningScheme))
            {
                AssemblyVersioningScheme versioningScheme;
                if (Enum.TryParse(AssemblyVersioningScheme, true, out versioningScheme))
                {
                    configuration.AssemblyVersioningScheme = versioningScheme;
                }
                else
                {
                    throw new WarningException(string.Format("Unexpected assembly versioning scheme '{0}'.", AssemblyVersioningScheme));
                }
            }

            // TODO This should be covered by tests
            // TODO would be good to not have to duplicate this in both msbuild tasks
            // Null is intentional. Empty string means the user has set the value to an empty string and wants to clear the tag
            if (DevelopBranchTag != null)
            {
                configuration.DevelopBranchTag = DevelopBranchTag;
            }

            if (ReleaseBranchTag != null)
            {
                configuration.ReleaseBranchTag = ReleaseBranchTag;
            }

            if (TagPrefix != null)
            {
                configuration.TagPrefix = TagPrefix;
            }

            if (NextVersion != null)
            {
                configuration.NextVersion = NextVersion;
            }

            CachedVersion semanticVersion;

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, configuration))
            {
                return;
            }
            CreateTempAssemblyInfo(semanticVersion, configuration);
        }
Example #6
0
        public override bool Execute()
        {
            try
            {
                CachedVersion versionAndBranch;
                var           gitDirectory  = GitDirFinder.TreeWalkForGitDir(SolutionDirectory);
                var           configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);

                // TODO This should be covered by tests
                // Null is intentional. Empty string means the user has set the value to an empty string and wants to clear the tag
                if (DevelopBranchTag != null)
                {
                    configuration.DevelopBranchTag = DevelopBranchTag;
                }

                if (ReleaseBranchTag != null)
                {
                    configuration.ReleaseBranchTag = ReleaseBranchTag;
                }

                if (TagPrefix != null)
                {
                    configuration.TagPrefix = TagPrefix;
                }

                if (NextVersion != null)
                {
                    configuration.NextVersion = NextVersion;
                }

                if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, configuration))
                {
                    var thisType  = typeof(GetVersion);
                    var variables = VariableProvider.GetVariablesFor(versionAndBranch.SemanticVersion, configuration);
                    foreach (var variable in variables)
                    {
                        thisType.GetProperty(variable.Key).SetValue(this, variable.Value, null);
                    }
                }
                return(true);
            }
            catch (WarningException errorException)
            {
                logger.LogWarning(errorException.Message);
                return(true);
            }
            catch (Exception exception)
            {
                logger.LogError("Error occurred: " + exception);
                return(false);
            }
            finally
            {
                Logger.Reset();
            }
        }
        public void InnerExecute()
        {
            VersionVariables result;

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out result, NoFetch, new Authentication(), fileSystem))
            {
                return;
            }

            WriteIntegrationParameters(BuildServerList.GetApplicableBuildServers(), result);
        }
Example #8
0
        public void InnerExecute()
        {
            SemanticVersion semanticVersion;

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion))
            {
                return;
            }

            var authentication = new Authentication();

            WriteIntegrationParameters(semanticVersion, BuildServerList.GetApplicableBuildServers(authentication));
        }
Example #9
0
        public void InnerExecute()
        {
            TempFileTracker.DeleteTempFiles();

            InvalidFileChecker.CheckForInvalidFiles(CompileFiles, ProjectFile);

            VersionVariables versionVariables;

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionVariables, NoFetch, new Authentication(), fileSystem))
            {
                return;
            }
            CreateTempAssemblyInfo(versionVariables);
        }
Example #10
0
        public void InnerExecute()
        {
            CachedVersion semanticVersion;
            var           gitDirectory  = GitDirFinder.TreeWalkForGitDir(SolutionDirectory);
            var           configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, configuration))
            {
                return;
            }

            var authentication = new Authentication();

            WriteIntegrationParameters(semanticVersion, BuildServerList.GetApplicableBuildServers(authentication));
        }
        public void InnerExecute()
        {
            TempFileTracker.DeleteTempFiles();

            InvalidFileChecker.CheckForInvalidFiles(CompileFiles, ProjectFile);

            VersionAndBranchAndDate versionAndBranch;

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch))
            {
                return;
            }

            CreateTempAssemblyInfo(versionAndBranch);
        }
        public void InnerExecute()
        {
            TempFileTracker.DeleteTempFiles();

            InvalidFileChecker.CheckForInvalidFiles(CompileFiles, ProjectFile);

            CachedVersion semanticVersion;

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion))
            {
                return;
            }

            CreateTempAssemblyInfo(semanticVersion);
        }
Example #13
0
        public void InnerExecute()
        {
            var avs = ParseAssemblyVersioningScheme(AssemblyVersioningScheme);

            TempFileTracker.DeleteTempFiles();

            InvalidFileChecker.CheckForInvalidFiles(CompileFiles, ProjectFile);

            SemanticVersion semanticVersion;

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion))
            {
                return;
            }

            CreateTempAssemblyInfo(semanticVersion, avs);
        }
Example #14
0
        public override bool Execute()
        {
            try
            {
                Tuple <CachedVersion, GitVersionContext> versionAndBranch;
                var gitDirectory  = GitDirFinder.TreeWalkForGitDir(SolutionDirectory);
                var configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);

                if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, configuration))
                {
                    var thisType          = typeof(GetVersion);
                    var cachedVersion     = versionAndBranch.Item1;
                    var gitVersionContext = versionAndBranch.Item2;
                    var config            = gitVersionContext.Configuration;
                    var variables         = VariableProvider.GetVariablesFor(
                        cachedVersion.SemanticVersion, config.AssemblyVersioningScheme,
                        config.VersioningMode, config.ContinuousDeploymentFallbackTag,
                        gitVersionContext.IsCurrentCommitTagged);
                    foreach (var variable in variables)
                    {
                        thisType.GetProperty(variable.Key).SetValue(this, variable.Value, null);
                    }
                }
                return(true);
            }
            catch (WarningException errorException)
            {
                logger.LogWarning(errorException.Message);
                return(true);
            }
            catch (Exception exception)
            {
                logger.LogError("Error occurred: " + exception);
                return(false);
            }
            finally
            {
                Logger.Reset();
            }
        }
Example #15
0
        public void InnerExecute()
        {
            TempFileTracker.DeleteTempFiles();

            InvalidFileChecker.CheckForInvalidFiles(CompileFiles, ProjectFile);

            var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory);

            if (string.IsNullOrEmpty(gitDirectory))
            {
                return;
            }

            var configuration = ConfigurationProvider.Provide(gitDirectory, fileSystem);

            Tuple <CachedVersion, GitVersionContext> semanticVersion;

            if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, configuration))
            {
                return;
            }
            CreateTempAssemblyInfo(semanticVersion.Item1, semanticVersion.Item2.Configuration);
        }