예제 #1
0
        public void OnAfterLogo(
            NukeBuild build,
            IReadOnlyCollection <ExecutableTarget> executableTargets,
            IReadOnlyCollection <ExecutableTarget> executionPlan)
        {
            if (!AutoGenerate || NukeBuild.IsServerBuild)
            {
                return;
            }

            GeneratedFiles.ForEach(EnsureExistingParentDirectory);

            // TODO: necessary?
            Logger.LogLevel = LogLevel.Trace;
            var previousHashes = GeneratedFiles
                                 .Where(File.Exists)
                                 .ToDictionary(x => x, GetFileHash);

            var assembly = Assembly.GetEntryAssembly().NotNull("assembly != null");

            ProcessTasks.StartProcess(
                assembly.Location,
                $"--{ConfigurationParameterName} --host {HostType}",
                logInvocation: false,
                logOutput: true)
            .AssertZeroExitCode();

            var changedFiles = GeneratedFiles
                               .Where(x => GetFileHash(x) != previousHashes.GetValueOrDefault(x))
                               .Select(x => NukeBuild.RootDirectory.GetRelativePathTo(x)).ToList();

            if (changedFiles.Count > 0)
            {
                Logger.Warn($"{HostType} configuration files have changed.");
                changedFiles.ForEach(x => Logger.Trace($"Updated {x}"));
            }
        }