/// <nodoc/> public Artifact(ArtifactKind kind, FileArtifact file) : this() { Kind = kind; m_fileArtifact = file; Type = ArtifactValueType.File; }
/// <nodoc/> public Artifact(ArtifactKind kind, DirectoryArtifact directory) : this() { // Rewrite only works for files. Contract.Requires(kind != ArtifactKind.Rewritten); Kind = kind; m_directoryArtifact = directory; Type = ArtifactValueType.Directory; }
/// <nodoc/> public Artifact(ArtifactKind kind, AbsolutePath path, FileArtifact original = default(FileArtifact)) : this() { Contract.Requires(kind != ArtifactKind.Rewritten || original.IsValid); // i.e., kind == ArtifactKind.Rewritten ==> original.IsValid Kind = kind; m_absolutePath = path; Type = ArtifactValueType.AbsolutePath; Original = original; }
private static IEnumerable DownloadAndUnpackAsync(string product, SemanticVersion version, ArtifactKind kind, string destinationDirectory, Action <string, float> progressCallback = null) { var packageId = GetPackageId(product); var getContentAsync = Feed.GetPackageContent(packageId, version, progressCallback); yield return(getContentAsync); var touchedFiles = new List <FileInfo>(); var packageDirectory = getContentAsync.GetResult(); var toolsDirectory = packageDirectory.GetDirectories().FirstOrDefault(d => string.Equals(d.Name, "tools", StringComparison.OrdinalIgnoreCase)); var libDirectory = packageDirectory.GetDirectories().FirstOrDefault(d => string.Equals(d.Name, "lib", StringComparison.OrdinalIgnoreCase)); if (kind == ArtifactKind.Library && libDirectory != null && libDirectory.Exists) { var prefTargets = default(string[]); if (Environment.Version > new Version(4, 0)) { prefTargets = new string[] { "net46", "net452", "net451", "net45", "net403", "net40", "net35", "net20", "net11" }; } else { prefTargets = new string[] { "net35", "net20", "net11" }; } var targetFrameworkDirectories = libDirectory.GetDirectories().Where(d => Array.IndexOf(prefTargets, d.Name) >= 0).ToArray(); Array.Sort(targetFrameworkDirectories, (x, y) => Array.IndexOf(prefTargets, x.Name).CompareTo(Array.IndexOf(prefTargets, y.Name))); foreach (var targetFrameworkDirectory in targetFrameworkDirectories) { if (Directory.Exists(destinationDirectory) == false) { Directory.CreateDirectory(destinationDirectory); } foreach (var file in targetFrameworkDirectory.GetFiles()) { touchedFiles.Add(DeployAtPath(file, destinationDirectory)); } yield return(touchedFiles.ToArray()); yield break; } } else if (kind == ArtifactKind.Tool && toolsDirectory != null && toolsDirectory.Exists) { if (Directory.Exists(destinationDirectory) == false) { Directory.CreateDirectory(destinationDirectory); } foreach (var file in toolsDirectory.GetFiles()) { touchedFiles.Add(DeployAtPath(file, destinationDirectory)); } yield return(touchedFiles.ToArray()); yield break; } throw new InvalidOperationException("Package '{0}' doesn't contains libraries or tools to deploy."); }
public static Promise <FileInfo[]> DownloadAndUnpack(string product, SemanticVersion version, ArtifactKind kind, string destinationDirectory, Action <string, float> progressCallback = null) { if (product == null) { throw new ArgumentNullException("product"); } if (version == null) { throw new ArgumentNullException("version"); } if (destinationDirectory == null) { throw new ArgumentNullException("destinationDirectory"); } return(new Coroutine <FileInfo[]>(DownloadAndUnpackAsync(product, version, kind, destinationDirectory, progressCallback))); }
/// <nodoc/> public static ArgumentValue FromArtifact(ArtifactKind kind, DirectoryArtifact directory) { return(new ArgumentValue(new Artifact(kind, directory))); }
/// <nodoc/> public static ArgumentValue FromAbsolutePath(ArtifactKind kind, AbsolutePath file, FileArtifact original = default(FileArtifact)) { return(new ArgumentValue(new Artifact(kind, file, original))); }
/// <nodoc/> public static ArgumentValue FromArtifact(ArtifactKind kind, FileArtifact file) { return(new ArgumentValue(new Artifact(kind, file))); }