public bool Execute(string modulePackagesConfig, string propsFile, string targetsFile, string[] inputs, string[] modulePaths)
        {
            try
            {
                BuildEngine = new CBTBuildEngine();

                Log.LogMessage(MessageImportance.Low, "Generate module build package imports:");
                Log.LogMessage(MessageImportance.Low, $"  ModulePackagesConfig = {modulePackagesConfig}");
                Log.LogMessage(MessageImportance.Low, $"  PropsFile = {propsFile}");
                Log.LogMessage(MessageImportance.Low, $"  TargetsFile = {targetsFile}");
                Log.LogMessage(MessageImportance.Low, $"  Inputs = {String.Join(";", inputs)}");
                Log.LogMessage(MessageImportance.Low, $"  ModulePaths = {String.Join(";", modulePaths)}");

                if (NuGetRestore.IsFileUpToDate(Log, propsFile, inputs) && NuGetRestore.IsFileUpToDate(Log, targetsFile, inputs))
                {
                    Log.LogMessage(MessageImportance.Low, $"Module build package import files '{propsFile}' and '{targetsFile}' are up-to-date");
                    return(true);
                }

                ModulePackagesConfig = modulePackagesConfig;
                PropsFile            = propsFile;
                TargetsFile          = targetsFile;
                ModulePaths          = modulePaths;

                return(Execute());
            }
            catch (Exception e)
            {
                Log.LogError(e.ToString());
                return(false);
            }
        }
 public bool Execute(string aggregateDestRoot, string packagesToAggregate, string propsFile, string immutableRoots)
 {
     BuildEngine         = new CBTBuildEngine();
     AggregateDestRoot   = aggregateDestRoot;
     PackagesToAggregate = packagesToAggregate;
     PropsFile           = propsFile;
     ImmutableRoots      = immutableRoots;
     return(Execute());
 }
Esempio n. 3
0
        public bool Execute(string file, string projectsFile, string msBuildVersion, bool requireConsent, bool disableParallelProcessing, string[] fallbackSources, bool noCache, string packageSaveMode, string[] sources, string configFile, bool nonInteractive, string verbosity, int timeout, string toolPath, bool enableOptimization, string markerPath, string[] inputs, string msbuildToolsVersion, string project, string globalProperties, string msbuildPath, string additionalArguments)
        {
            if (BuildEngine == null)
            {
                BuildEngine = new CBTBuildEngine();
            }

            MSBuildToolsVersion = msbuildToolsVersion;
            Project             = project;
            GlobalProperties    = globalProperties;
            File = file;

            FileInfo projectsFileInfo = !String.IsNullOrWhiteSpace(projectsFile) ? new FileInfo(projectsFile) : null;

            inputs = inputs.Concat(GetAllPathsFromProjectsFile(projectsFileInfo)).ToArray();

            if (enableOptimization && IsFileUpToDate(Log, markerPath, inputs))
            {
                Log.LogMessage(MessageImportance.Low, "Traversal NuGet packages are up-to-date");
                return(true);
            }

            MSBuildProjectLoader projectLoader = new MSBuildProjectLoader(GlobalProperties.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries).Where(i => !String.IsNullOrWhiteSpace(i)).Select(i => i.Trim().Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)).ToDictionary(i => i.First(), i => i.Last()), MSBuildToolsVersion, Log, ProjectLoadSettings.IgnoreMissingImports);

            Log.LogMessage(MessageImportance.Normal, $"Loading project references for '{Project}'...");
            _projectCollection  = projectLoader.LoadProjectsAndReferences(new[] { Project });
            _enableOptimization = enableOptimization;

            Log.LogMessage(MessageImportance.Low, "10 Slowest Loading Projects:");
            foreach (var loadTimes in projectLoader.Statistics.ProjectLoadTimes.OrderByDescending(i => i.Value).Take(10))
            {
                Log.LogMessage(MessageImportance.Low, $"  {loadTimes.Key} {loadTimes.Value}");
            }

            if (Log.HasLoggedErrors)
            {
                return(false);
            }

            Log.LogMessage(MessageImportance.Normal, $"Loaded '{_projectCollection.LoadedProjects.Count}' projects");

            if (!TryWriteSolutionFile(_projectCollection))
            {
                return(false);
            }

            if (projectsFileInfo != null && !TryWriteProjectsFile(_projectCollection, projectsFileInfo))
            {
                return(false);
            }

            bool ret = Execute(file, msBuildVersion, requireConsent, disableParallelProcessing, fallbackSources, noCache, packageSaveMode, sources, configFile, nonInteractive, verbosity, timeout, toolPath, enableOptimization, markerPath, inputs, msbuildPath, additionalArguments);

            return(ret && !Log.HasLoggedErrors);
        }
        public bool Execute(string packageRestoreFile, string[] inputs, string propsFile, string propertyVersionNamePrefix, string propertyPathNamePrefix, string restoreInfoFile = "")
        {
            try
            {
                BuildEngine = new CBTBuildEngine();
                Log.LogMessage(MessageImportance.Low, "Generate NuGet packages properties:");
                Log.LogMessage(MessageImportance.Low, $"  Inputs = {String.Join(";", inputs)}");
                Log.LogMessage(MessageImportance.Low, $"  PackageRestoreFile = {packageRestoreFile}");
                Log.LogMessage(MessageImportance.Low, $"  PropertyPathNamePrefix = {propertyPathNamePrefix}");
                Log.LogMessage(MessageImportance.Low, $"  PropertyVersionNamePrefix = {propertyVersionNamePrefix}");
                Log.LogMessage(MessageImportance.Low, $"  PropsFile = {propsFile}");
                Log.LogMessage(MessageImportance.Low, $"  RestoreInfoFile = {restoreInfoFile}");

                if (NuGetRestore.IsFileUpToDate(Log, propsFile, inputs))
                {
                    Log.LogMessage(MessageImportance.Low, $"NuGet package properties file '{propsFile}' is up-to-date");
                    return(true);
                }

                if (Directory.Exists(packageRestoreFile))
                {
                    Log.LogMessage(MessageImportance.Low, $"A directory with the name '{packageRestoreFile}' exist.  Please consider renaming this directory to avoid breaking NuGet convention.");
                    return(true);
                }

                PackageRestoreFile        = packageRestoreFile;
                Inputs                    = inputs;
                PropsFile                 = propsFile;
                PropertyVersionNamePrefix = propertyVersionNamePrefix;
                PropertyPathNamePrefix    = propertyPathNamePrefix;
                RestoreInfoFile           = restoreInfoFile;

                return(Execute());
            }
            catch (Exception e)
            {
                Log.LogError(e.ToString());
                return(false);
            }
        }
Esempio n. 5
0
        public bool Execute(string file, string msBuildVersion, bool requireConsent, bool disableParallelProcessing, string[] fallbackSources, bool noCache, string packageSaveMode, string[] sources, string configFile, bool nonInteractive, string verbosity, int timeout, string toolPath, bool enableOptimization, string markerPath, string[] inputs, string msBuildPath, string additionalArguments)
        {
            if (BuildEngine == null)
            {
                BuildEngine = new CBTBuildEngine();
            }

            Log.LogMessage(MessageImportance.Low, "Restore NuGet Packages:");
            Log.LogMessage(MessageImportance.Low, $"  File = {file}");
            Log.LogMessage(MessageImportance.Low, $"  MSBuildVersion = {msBuildVersion}");
            Log.LogMessage(MessageImportance.Low, $"  MSBuildPath = {msBuildPath}");
            Log.LogMessage(MessageImportance.Low, $"  RequireConsent = {requireConsent}");
            Log.LogMessage(MessageImportance.Low, $"  DisableParallelProcessing = {disableParallelProcessing}");
            Log.LogMessage(MessageImportance.Low, $"  FallbackSources = {String.Join(";", fallbackSources)}");
            Log.LogMessage(MessageImportance.Low, $"  NoCache = {noCache}");
            Log.LogMessage(MessageImportance.Low, $"  PackageSaveMode = {packageSaveMode}");
            Log.LogMessage(MessageImportance.Low, $"  Sources = {String.Join(";", sources)}");
            Log.LogMessage(MessageImportance.Low, $"  ConfigFile = {configFile}");
            Log.LogMessage(MessageImportance.Low, $"  NonInteractive = {nonInteractive}");
            Log.LogMessage(MessageImportance.Low, $"  Verbosity = {verbosity}");
            Log.LogMessage(MessageImportance.Low, $"  Timeout = {timeout}");
            Log.LogMessage(MessageImportance.Low, $"  ToolPath = {toolPath}");
            Log.LogMessage(MessageImportance.Low, $"  EnableOptimization = {enableOptimization}");
            Log.LogMessage(MessageImportance.Low, $"  MarkerPath = {markerPath}");
            Log.LogMessage(MessageImportance.Low, $"  Inputs = {String.Join(";", inputs)}");
            Log.LogMessage(MessageImportance.Low, $"  AdditionalArguments = {additionalArguments}");

            if (enableOptimization && IsFileUpToDate(Log, markerPath, inputs))
            {
                Log.LogMessage(MessageImportance.Low, "NuGet packages are up-to-date");
                return(true);
            }

            if (Directory.Exists(file))
            {
                Log.LogMessage(MessageImportance.Low, $"A directory with the name '{file}' exist.  Please consider renaming this directory to avoid breaking nuget convention.");
                return(true);
            }
            File                      = file;
            MsBuildVersion            = msBuildVersion;
            MSBuildPath               = msBuildPath;
            RequireConsent            = RequireConsent;
            DisableParallelProcessing = disableParallelProcessing;
            FallbackSource            = fallbackSources.Any() ? fallbackSources.Where(i => !String.IsNullOrWhiteSpace(i)).Select(i => new TaskItem(i)).Cast <ITaskItem>().ToArray() : null;
            NoCache                   = noCache;
            PackageSaveMode           = !String.IsNullOrWhiteSpace(packageSaveMode) ? packageSaveMode : null;
            Source                    = sources.Any() ? sources.Where(i => !String.IsNullOrWhiteSpace(i)).Select(i => new TaskItem(i)).Cast <ITaskItem>().ToArray() : null;
            ConfigFile                = !String.IsNullOrWhiteSpace(configFile) ? configFile : null;
            NonInteractive            = nonInteractive;
            Verbosity                 = verbosity;
            AdditionalArguments       = additionalArguments;

            if (timeout > 0)
            {
                Timeout = timeout;
            }

            if (!String.IsNullOrEmpty(toolPath))
            {
                ToolPath = toolPath;
            }

            bool ret = false;

            try
            {
                ret = Execute();

                if (enableOptimization && !String.IsNullOrWhiteSpace(markerPath))
                {
                    GenerateNuGetOptimizationFile(markerPath);
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
            }

            return(ret);
        }