/// <summary> /// Task execution override /// </summary> /// <returns> /// True if successful /// False otherwise /// </returns> public override Boolean Execute() { try { // parepare the task for execution if (!Path.IsPathRooted(this.OutputPath)) { this.OutputPath = Path.GetFullPath(this.OutputPath); } // read in .nupkgs intermediate file // MsBuild can't cache these projects (no binary output), these reference information are stored in intermediate files // and we can read it back for clean targets var nupkgsFullPath = ProjectHelper.GetNupkgsFullPath(ProjectPath, OutputPath); if (File.Exists(nupkgsFullPath)) { this.targetList.AddRange(System.IO.File.ReadAllLines(nupkgsFullPath) .AsEnumerable() .Select(pkgPath => new TaskItem(pkgPath))); this.targetList.Add(new TaskItem(nupkgsFullPath)); } // return the list of clean targets this.Targets = this.targetList.ToArray(); } catch (Exception e) { Log.LogError("{0} ({1})", e.ToString(), e.GetType().Name); return(false); } return(true); }
/// <summary> /// Task execution override /// </summary> /// <returns> /// True if successful /// False otherwise /// </returns> public override Boolean Execute() { try { // parepare the task for execution if (this.ReferenceLibraries == null) { this.ReferenceLibraries = new ITaskItem[0]; } if (!Path.IsPathRooted(this.OutputPath)) { this.OutputPath = Path.GetFullPath(this.OutputPath); } propertyProvider = new PropertyProvider(ProjectPath, this.ReferenceLibraries .ValidReferenceLibraryForBinaryNuSource() .ValidReferenceLibraryForPropertyProvider() .ToArray()); // add binary and NuBuild build dependencies to the list of sources this.sourceList.AddRange(this.ReferenceLibraries .ValidReferenceLibraryForBinaryNuSource()); this.sourceList.AddRange(this.ReferenceLibraries .ValidReferenceLibraryForNuBuildNuSource() .Select(referenceLibrary => new TaskItem(ProjectHelper.GetNupkgsFullPath( referenceLibrary.MSBuildSourceProjectFile(), Path.GetDirectoryName(referenceLibrary.FullPath()))))); // add build dependencies from the embedded resource file(s) this.sourceList.AddRange(this.Embedded); // parse the version source name this.versionSource = (VersionSource)Enum.Parse( typeof(VersionSource), this.VersionSource, true ); // configure each nuspec item (NuPackage will use the metadata added now) // it also adds the referred files in .nuspec files to the sources // and certainly adds the .nuspec files to sources and the .nupkg files to targets foreach (var specItem in this.NuSpec) { PreparePackage(specItem); } // add intermediate .nupkgs file to targets var nupkgsFullPath = ProjectHelper.GetNupkgsFullPath(ProjectPath, OutputPath); this.targetList.Add(new TaskItem(nupkgsFullPath)); // return the list of build sources/targets this.Prepared = this.preparedList.ToArray(); this.Sources = this.sourceList.ToArray(); this.Targets = this.targetList.ToArray(); } catch (Exception e) { Log.LogError("{0} ({1})", e.ToString(), e.GetType().Name); return(false); } return(true); }
/// <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); }
// 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();