public static XElement GenerateContentFilesItem(string path, LockFileContentFile item, string packageId, string packageVersion) { var entry = new XElement(Namespace + item.BuildAction.Value, new XAttribute("Include", path), new XAttribute("Condition", $"Exists('{path}')"), new XElement(Namespace + "NuGetPackageId", packageId), new XElement(Namespace + "NuGetPackageVersion", packageVersion), new XElement(Namespace + "NuGetItemType", item.BuildAction), new XElement(Namespace + "Pack", false)); var privateFlag = false; if (item.CopyToOutput) { var outputPath = item.OutputPath ?? item.PPOutputPath; if (outputPath != null) { // Convert / to \ outputPath = LockFileUtils.ToDirectorySeparator(outputPath); privateFlag = true; entry.Add(new XElement(Namespace + "CopyToOutputDirectory", "PreserveNewest")); entry.Add(new XElement(Namespace + "TargetPath", outputPath)); var destinationSubDirectory = Path.GetDirectoryName(outputPath); if (!string.IsNullOrEmpty(destinationSubDirectory)) { entry.Add(new XElement(Namespace + "DestinationSubDirectory", destinationSubDirectory + Path.DirectorySeparatorChar)); } } } entry.Add(new XElement(Namespace + "Private", privateFlag.ToString())); // Remove contentFile/lang/tfm/ from start of the path var linkPath = string.Join(string.Empty + Path.DirectorySeparatorChar, item.Path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries) .Skip(3) .ToArray()); if (linkPath != null) { entry.Add(new XElement(Namespace + "Link", linkPath)); } return(entry); }
private static string GetAbsolutePath(this Lazy <LocalPackageSourceInfo> package, LockFileItem item) { return(Path.Combine(package.Value.Package.ExpandedPath, LockFileUtils.ToDirectorySeparator(item.Path))); }