Exemple #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);
        }
Exemple #2
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);
        }
        public static bool TryGetVersion(string directory, out SemanticVersion versionAndBranch)
        {
            var gitDirectory = GitDirFinder.TreeWalkForGitDir(directory);

            if (string.IsNullOrEmpty(gitDirectory))
            {
                var message =
                    "No .git directory found in provided solution path. This means the assembly may not be versioned correctly. " +
                    "To fix this warning either clone the repository using git or remove the `GitVersion.Fody` nuget package. " +
                    "To temporarily work around this issue add a AssemblyInfo.cs with an appropriate `AssemblyVersionAttribute`." +
                    "If it is detected that this build is occurring on a CI server an error may be thrown.";
                Logger.WriteWarning(message);
                versionAndBranch = null;
                return(false);
            }

            var arguments = new Arguments();

            foreach (var buildServer in BuildServerList.GetApplicableBuildServers(arguments))
            {
                Logger.WriteInfo(string.Format("Executing PerformPreProcessingSteps for '{0}'.", buildServer.GetType().Name));
                buildServer.PerformPreProcessingSteps(gitDirectory);
            }
            versionAndBranch = VersionCache.GetVersion(gitDirectory);
            return(true);
        }
        protected override void InnerExecute()
        {
            if (GetVersionVariables(out var versionVariables))
            {
                return;
            }

            WriteIntegrationParameters(BuildServerList.GetApplicableBuildServers(), versionVariables);
        }
        public void InnerExecute()
        {
            VersionVariables result;

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

            WriteIntegrationParameters(BuildServerList.GetApplicableBuildServers(), result);
        }
        void InnerExecute()
        {
            VersionVariables result;

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

            WriteIntegrationParameters(BuildServerList.GetApplicableBuildServers(), result);
        }
Exemple #7
0
        private static int Main(string[] args)
        {
#if DEBUG
            LogManager.AddDebugListener(true);
#endif

            var consoleLogListener = new OutputLogListener();
            LogManager.AddListener(consoleLogListener);

            try
            {
                HelpWriter.WriteAppHeader(s => Log.Write(LogEvent.Info, s));

                Log.Info("Arguments: {0}", string.Join(" ", args));
                Log.Info(string.Empty);

                var context = ArgumentParser.ParseArguments(args);
                if (context.IsHelp)
                {
                    HelpWriter.WriteHelp(s => Log.Write(LogEvent.Info, s));

                    WaitForKeyPress();

                    return(0);
                }

                var parameters  = new List <IParameter>();
                var typeFactory = TypeFactory.Default;
                var initTypes   = TypeCache.GetTypes(x => typeof(RuleBase).IsAssignableFromEx(x) && !x.IsAbstract);
                foreach (var initType in initTypes)
                {
                    var initializer = (RuleBase)typeFactory.CreateInstance(initType);
                    parameters.Add(initializer.GetParameter(context));
                }

                foreach (var buildServer in BuildServerList.GetApplicableBuildServers(context))
                {
                    buildServer.WriteIntegration(parameters, x => Log.Info(x));
                }

#if DEBUG
                if (Debugger.IsAttached)
                {
                    WaitForKeyPress();
                }
#endif

                return(0);
            }
            catch (Exception)
            {
                return(-1);
            }
        }
        private static Output InnerExecute(Input input, TaskLogger logger)
        {
            if (!GitVersionTaskUtils.GetVersionVariables(input, out var versionVariables))
            {
                return(null);
            }

            WriteIntegrationParameters(logger, BuildServerList.GetApplicableBuildServers(), versionVariables);

            return(new Output());
        }
Exemple #9
0
        public void InnerExecute()
        {
            SemanticVersion semanticVersion;

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

            var authentication = new Authentication();

            WriteIntegrationParameters(semanticVersion, BuildServerList.GetApplicableBuildServers(authentication));
        }
        private static Output InnerExecute(Input input, TaskLogger logger)
        {
            var execute = GitVersionTaskCommonFunctionality.CreateExecuteCore();

            if (!execute.TryGetVersion(input.SolutionDirectory, out var result, input.NoFetch, new Authentication()))
            {
                return(null);
            }

            WriteIntegrationParameters(logger, BuildServerList.GetApplicableBuildServers(), result);

            return(new Output());
        }
Exemple #11
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 static bool WriteVersionInfoToBuildLog(WriteVersionInfoToBuildLog task)
        {
            return(ExecuteGitVersionTask(task, t =>
            {
                if (!GetVersionVariables(task, out var versionVariables))
                {
                    return;
                }

                var logger = t.Log;
                foreach (var buildServer in BuildServerList.GetApplicableBuildServers())
                {
                    logger.LogMessage($"Executing GenerateSetVersionMessage for '{ buildServer.GetType().Name }'.");
                    logger.LogMessage(buildServer.GenerateSetVersionMessage(versionVariables));
                    logger.LogMessage($"Executing GenerateBuildLogOutput for '{ buildServer.GetType().Name }'.");
                    foreach (var buildParameter in BuildOutputFormatter.GenerateBuildLogOutput(buildServer, versionVariables))
                    {
                        logger.LogMessage(buildParameter);
                    }
                }
            }));
        }
Exemple #13
0
 public new void TearDown()
 {
     BuildServerList.ResetSelector();
 }