Пример #1
0
        /// <summary>
        /// Builds the full build script from the list of snippets for each platform.
        /// </summary>
        /// <returns>Finalized build script as a string.</returns>
        private string BuildScriptFromSnippets(
            BuildScriptGeneratorContext context,
            IList <BuildScriptSnippet> snippets,
            IDictionary <string, string> toolsToVersion,
            List <string> directoriesToExcludeFromCopyToIntermediateDir,
            List <string> directoriesToExcludeFromCopyToBuildOutputDir)
        {
            string script;
            string benvArgs = GetBenvArgs(toolsToVersion);

            _environmentSettingsProvider.TryGetAndLoadSettings(out var environmentSettings);

            Dictionary <string, string> buildProperties = snippets
                                                          .Where(s => s.BuildProperties != null)
                                                          .SelectMany(s => s.BuildProperties)
                                                          .ToDictionary(p => p.Key, p => p.Value);

            buildProperties[ManifestFilePropertyKeys.OperationId] = context.OperationId;

            (var preBuildCommand, var postBuildCommand) = PreAndPostBuildCommandHelper.GetPreAndPostBuildCommands(
                context.SourceRepo,
                environmentSettings);

            var buildScriptProps = new BaseBashBuildScriptProperties()
            {
                BuildScriptSnippets = snippets.Select(s => s.BashBuildScriptSnippet),
                BenvArgs            = benvArgs,
                PreBuildCommand     = preBuildCommand,
                PostBuildCommand    = postBuildCommand,
                DirectoriesToExcludeFromCopyToIntermediateDir = directoriesToExcludeFromCopyToIntermediateDir,
                DirectoriesToExcludeFromCopyToBuildOutputDir  = directoriesToExcludeFromCopyToBuildOutputDir,
                ManifestFileName = FilePaths.BuildManifestFileName,
                BuildProperties  = buildProperties
            };

            LogScriptIfGiven("pre-build", buildScriptProps.PreBuildCommand);
            LogScriptIfGiven("post-build", buildScriptProps.PostBuildCommand);

            script = TemplateHelpers.Render(
                TemplateHelpers.TemplateResource.BaseBashScript,
                buildScriptProps,
                _logger);
            return(script);
        }
Пример #2
0
        /// <summary>
        /// Builds the full build script from the list of snippets for each platform.
        /// </summary>
        /// <returns>Finalized build script as a string.</returns>
        private string BuildScriptFromSnippets(List <BuildScriptSnippet> snippets, Dictionary <string, string> toolsToVersion)
        {
            string script;
            string benvArgs = GetBenvArgs(toolsToVersion);

            _environmentSettingsProvider.TryGetAndLoadSettings(out var environmentSettings);

            var buildScriptProps = new BaseBashBuildScriptProperties()
            {
                BuildScriptSnippets = snippets.Select(s => s.BashBuildScriptSnippet),
                BenvArgs            = benvArgs,
                PreBuildScriptPath  = environmentSettings?.PreBuildScriptPath,
                PostBuildScriptPath = environmentSettings?.PostBuildScriptPath
            };

            LogScriptIfGiven("pre-build", buildScriptProps.PreBuildScriptPath);
            LogScriptIfGiven("post-build", buildScriptProps.PostBuildScriptPath);

            script = TemplateHelpers.Render(TemplateHelpers.TemplateResource.BaseBashScript, buildScriptProps, _logger);
            return(script);
        }
        /// <summary>
        /// Builds the full build script from the list of snippets for each platform.
        /// </summary>
        /// <returns>Finalized build script as a string.</returns>
        private string BuildScriptFromSnippets(
            List <BuildScriptSnippet> snippets,
            Dictionary <string, string> toolsToVersion,
            List <string> directoriesToExcludeFromCopyToIntermediateDir,
            List <string> directoriesToExcludeFromCopyToBuildOutputDir)
        {
            string script;
            string benvArgs = GetBenvArgs(toolsToVersion);

            _environmentSettingsProvider.TryGetAndLoadSettings(out var environmentSettings);

            Dictionary <string, string> buildProperties = snippets
                                                          .Where(s => s.BuildProperties != null)
                                                          .SelectMany(s => s.BuildProperties)
                                                          .ToDictionary(p => p.Key, p => p.Value);

            var buildScriptProps = new BaseBashBuildScriptProperties()
            {
                BuildScriptSnippets = snippets.Select(s => s.BashBuildScriptSnippet),
                BenvArgs            = benvArgs,
                PreBuildScriptPath  = environmentSettings?.PreBuildScriptPath,
                PostBuildScriptPath = environmentSettings?.PostBuildScriptPath,
                DirectoriesToExcludeFromCopyToIntermediateDir = directoriesToExcludeFromCopyToIntermediateDir,
                DirectoriesToExcludeFromCopyToBuildOutputDir  = directoriesToExcludeFromCopyToBuildOutputDir,
                ManifestFileName = Constants.ManifestFileName,
                BuildProperties  = buildProperties
            };

            LogScriptIfGiven("pre-build", buildScriptProps.PreBuildScriptPath);
            LogScriptIfGiven("post-build", buildScriptProps.PostBuildScriptPath);

            script = TemplateHelpers.Render(
                TemplateHelpers.TemplateResource.BaseBashScript,
                buildScriptProps,
                _logger);
            return(script);
        }