public override bool Execute() { try { Log.LogMessage(MessageImportance.Low, "Using path prefix '{0}'", PathPrefix); AssetsWithTargetPath = new TaskItem[Assets.Length]; for (var i = 0; i < Assets.Length; i++) { var staticWebAsset = StaticWebAsset.FromTaskItem(Assets[i]); var result = staticWebAsset.ToTaskItem(); var targetPath = staticWebAsset.ComputeTargetPath( PathPrefix, UseAlternatePathDirectorySeparator ? Path.AltDirectorySeparatorChar : Path.DirectorySeparatorChar); if (AdjustPathsForPack && string.IsNullOrEmpty(Path.GetExtension(targetPath))) { targetPath = Path.GetDirectoryName(targetPath); } result.SetMetadata("TargetPath", targetPath); AssetsWithTargetPath[i] = result; } } catch (Exception ex) { Log.LogError(ex.Message); } return(!Log.HasLoggedErrors); }
public override bool Execute() { try { Log.LogMessage("Using path prefix '{0}'", PathPrefix); AssetsWithTargetPath = new TaskItem[Assets.Length]; for (var i = 0; i < Assets.Length; i++) { var staticWebAsset = StaticWebAsset.FromTaskItem(Assets[i]); var result = staticWebAsset.ToTaskItem(); var targetPath = staticWebAsset.ComputeTargetPath( PathPrefix, UseAlternatePathDirectorySeparator ? Path.AltDirectorySeparatorChar : Path.DirectorySeparatorChar); result.SetMetadata("TargetPath", targetPath); AssetsWithTargetPath[i] = result; } } catch (Exception ex) { Log.LogError(ex.Message); } return(!Log.HasLoggedErrors); }
public override bool Execute() { try { var manifest = ComputeDevelopmentManifest( Assets.Select(a => StaticWebAsset.FromTaskItem(a)), DiscoveryPatterns.Select(ComputeDiscoveryPattern)); PersistManifest(manifest); } catch (Exception ex) { Log.LogError(ex.ToString()); Log.LogErrorFromException(ex); } return(!Log.HasLoggedErrors); }
public override bool Execute() { try { var manifests = new List <StaticWebAssetsManifest>(); ReadCandidateManifests(manifests); if (Log.HasLoggedErrors) { return(false); } var existingAssets = ExistingAssets .ToDictionary(a => (a.GetMetadata("AssetKind"), a.ItemSpec), a => StaticWebAsset.FromTaskItem(a)); var staticWebAssets = new Dictionary <(string, string), StaticWebAsset>(); var discoveryPatterns = new Dictionary <string, StaticWebAssetsManifest.DiscoveryPattern>(); foreach (var manifest in manifests) { MergeDiscoveryPatterns(discoveryPatterns, manifest); if (Log.HasLoggedErrors) { break; } MergeStaticWebAssets(staticWebAssets, existingAssets, manifest); if (Log.HasLoggedErrors) { break; } } StaticWebAssets = staticWebAssets.Select(a => a.Value.ToTaskItem()).ToArray(); DiscoveryPatterns = discoveryPatterns.Select(d => d.Value.ToTaskItem()).ToArray(); } catch (Exception ex) { Log.LogError(ex.ToString()); } return(!Log.HasLoggedErrors); }
public override bool Execute() { var copyToOutputFolder = new List <ITaskItem>(); var normalizedOutputPath = StaticWebAsset.NormalizeContentRootPath(Path.GetFullPath(OutputPath)); try { foreach (var asset in Assets.Select(a => StaticWebAsset.FromTaskItem(a))) { string fileOutputPath = null; if (!(asset.IsDiscovered() || asset.IsComputed())) { Log.LogMessage("Skipping asset '{0}' since source type is '{1}'", asset.Identity, asset.SourceType); continue; } if (asset.IsForReferencedProjectsOnly()) { Log.LogMessage("Skipping asset '{0}' since asset mode is '{1}'", asset.Identity, asset.AssetMode); } if (asset.ShouldCopyToOutputDirectory()) { // We have an asset we want to copy to the output folder. fileOutputPath = Path.Combine(normalizedOutputPath, asset.RelativePath); string source = null; if (asset.IsComputed()) { if (asset.Identity.StartsWith(normalizedOutputPath, StringComparison.Ordinal)) { Log.LogMessage("Source for asset '{0}' is '{1}' since the identity points to the output path.", asset.Identity, asset.OriginalItemSpec); source = asset.OriginalItemSpec; } else if (File.Exists(asset.Identity)) { Log.LogMessage("Source for asset '{0}' is '{0}' since the asset exists.", asset.Identity); source = asset.Identity; } else { Log.LogMessage("Source for asset '{0}' is '{1}' since the asset does not exist.", asset.Identity, asset.OriginalItemSpec); source = asset.OriginalItemSpec; } } else { source = asset.Identity; } copyToOutputFolder.Add(new TaskItem(source, new Dictionary <string, string> { ["OriginalItemSpec"] = asset.Identity, ["TargetPath"] = fileOutputPath, ["CopyToOutputDirectory"] = asset.CopyToOutputDirectory })); } else { Log.LogMessage("Skipping asset '{0}' since copy to output directory option is '{1}'", asset.Identity, asset.CopyToOutputDirectory); } } AssetsToCopy = copyToOutputFolder.ToArray(); } catch (Exception ex) { Log.LogError(ex.ToString()); } return(!Log.HasLoggedErrors); }