Exemple #1
0
 public static bool ValidProjectForDependencyCollection(string projectFile) =>
 !string.IsNullOrEmpty(projectFile) &&
 ProjectHelper.IsSupportedProject(projectFile) &&
 !ProjectHelper.HasNuspecFile(projectFile);
Exemple #2
0
        /// <summary>
        /// Task execution override
        /// </summary>
        /// <returns>
        /// True if successful
        /// False otherwise
        /// </returns>
        public override Boolean Execute()
        {
            try
            {
                Debug.WriteLine("\n=== NuPackage on {0} ===", (object)Path.GetFileName(ProjectPath));

                // we must check the tool version that used to edit the NuBuild project,
                // if that is higher than the current, than there is a good chance that a new feature is used
                // in that case we can't build the packages with an older NuBuild framework
                // this is usefull with multiple developers and/or CI/TFS server
                string          assemblyInformationalVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;
                SemanticVersion semanticToolVersionInProject;
                if (SemanticVersion.TryParse(ToolVersion, out semanticToolVersionInProject) &&
                    semanticToolVersionInProject > SemanticVersion.Parse(assemblyInformationalVersion))
                {
                    Log.LogError("The project properties are edited with a higher version NuBuild ({0}). Update the NuBuild project system from {1} to the latest version!",
                                 semanticToolVersionInProject, assemblyInformationalVersion);
                    return(false);
                }

                // prepare the task for execution
                if (this.ReferenceProjects == null)
                {
                    this.ReferenceProjects = new ITaskItem[0];
                }
                if (this.ReferenceLibraries == null)
                {
                    this.ReferenceLibraries = new ITaskItem[0];
                }
                if (!Path.IsPathRooted(this.OutputPath))
                {
                    this.OutputPath = Path.GetFullPath(this.OutputPath);
                }
                if (!Directory.Exists(this.OutputPath))
                {
                    Directory.CreateDirectory(this.OutputPath);
                }
                propertyProvider = new PropertyProvider(ProjectPath, this.ReferenceLibraries
                                                        .ValidReferenceLibraryForBinaryNuSource()
                                                        .ValidReferenceLibraryForPropertyProvider()
                                                        .ToArray());

                // remove previous outputs (.nupkg and .nupkgs files)
                var nupkgsFullPath = ProjectHelper.GetNupkgsFullPath(ProjectPath, OutputPath);
                if (File.Exists(nupkgsFullPath))
                {
                    foreach (var pkgPath in System.IO.File.ReadAllLines(nupkgsFullPath))
                    {
                        if (File.Exists(pkgPath))
                        {
                            File.Delete(pkgPath);
                        }
                    }
                    File.Delete(nupkgsFullPath);
                }
                // write out the new .nupkgs intermediate file
                System.IO.File.WriteAllLines(nupkgsFullPath, this.NuSpec.Select(ti => ti.GetMetadata("NuPackagePath")), System.Text.Encoding.UTF8);
                // compile the nuget packages
                foreach (var specItem in this.NuSpec)
                {
                    BuildPackage(specItem);
                }
            }
            catch (Exception e)
            {
                Log.LogError("{0} ({1})", e.ToString(), e.GetType().Name);
                return(false);
            }
            return(true);
        }
Exemple #3
0
 // MsBuild can't cache these projects (no binary output), these reference information are stored in intermediate files
 private IEnumerable <string> ResolveNuTargets() =>
 System.IO.File.ReadAllLines(ProjectHelper.GetNupkgsFullPath(FullPath, TargetDir))
 .AsEnumerable();