public bool Execute(string modulePackagesConfig, string propsFile, string targetsFile, string[] inputs, string[] modulePaths)
        {
            if (File.Exists(PropsFile) && File.Exists(TargetsFile) && IsFileUpToDate(propsFile, inputs) && IsFileUpToDate(targetsFile, inputs))
            {
                return true;
            }

            BuildEngine = new CBTBuildEngine();

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

            return Execute();
        }
Ejemplo n.º 2
0
        public bool Execute(string file, string msBuildVersion, string packagesDirectory, bool requireConsent, string solutionDirectory, 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)
        {
            BuildEngine = new CBTBuildEngine();

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

                return true;
            }

            File = file;
            MsBuildVersion = msBuildVersion;
            PackagesDirectory = packagesDirectory;
            RequireConsent = RequireConsent;
            SolutionDirectory = !String.IsNullOrWhiteSpace(solutionDirectory) ? solutionDirectory : null;
            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;

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

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

            bool ret = false;

            try
            {
                ret = Execute();

                if (enableOptimization)
                {
                    Log.LogMessage(MessageImportance.Low, "Creating marker file for NuGet package restore optimization: '{0}'", markerPath);

                    string dir = Path.GetDirectoryName(markerPath);

                    using (Mutex mutex = new Mutex(false, markerPath.ToUpper().GetHashCode().ToString("X")))
                    {
                        if (!mutex.WaitOne(TimeSpan.FromMinutes(30)))
                        {
                            return false;
                        }

                        if (!System.IO.File.Exists(markerPath))
                        {
                            if (!String.IsNullOrWhiteSpace(dir) && !Directory.Exists(dir))
                            {
                                Directory.CreateDirectory(dir);
                            }

                            System.IO.File.WriteAllText(markerPath, String.Empty);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
            }

            return ret;
        }
Ejemplo n.º 3
0
        public bool GenerateNuGetProperties(string file, string[] inputs, string propsFile, string propertyNamePrefix, string propertyValuePrefix)
        {
            BuildEngine = new CBTBuildEngine();

            if (IsFileUpToDate(propsFile, inputs))
            {
                return true;
            }

            NuGetPropertyGenerator nuGetPropertyGenerator = new NuGetPropertyGenerator(file);

            Log.LogMessage(MessageImportance.Low, "Generating MSBuild property file '{0}' for NuGet packages", propsFile);

            nuGetPropertyGenerator.Generate(propsFile, propertyNamePrefix, propertyValuePrefix);

            return true;
        }