Ejemplo n.º 1
0
        public override bool Execute()
        {
            try
            {
                var assets = Assets.OrderBy(a => a.GetMetadata("FullPath")).Select(StaticWebAsset.FromTaskItem);

                var assetsByTargetPath = assets.GroupBy(a => a.ComputeTargetPath("", '/'), StringComparer.OrdinalIgnoreCase);
                foreach (var group in assetsByTargetPath)
                {
                    if (!StaticWebAsset.ValidateAssetGroup(group.Key, group.ToArray(), ManifestType, out var reason))
                    {
                        Log.LogError(reason);
                        return(false);
                    }
                }

                var discoveryPatterns = DiscoveryPatterns
                                        .OrderBy(a => a.ItemSpec)
                                        .Select(StaticWebAssetsManifest.DiscoveryPattern.FromTaskItem)
                                        .ToArray();

                var referencedProjectsConfiguration = ReferencedProjectsConfigurations.OrderBy(a => a.ItemSpec)
                                                      .Select(StaticWebAssetsManifest.ReferencedProjectConfiguration.FromTaskItem)
                                                      .ToArray();

                PersistManifest(
                    StaticWebAssetsManifest.Create(
                        Source,
                        BasePath,
                        Mode,
                        ManifestType,
                        referencedProjectsConfiguration,
                        discoveryPatterns,
                        assets.ToArray()));
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex, showStackTrace: true, showDetail: true, file: null);
            }
            return(!Log.HasLoggedErrors);
        }
Ejemplo n.º 2
0
        public override bool Execute()
        {
            try
            {
                var assets = Assets.OrderBy(a => a.GetMetadata("FullPath")).Select(StaticWebAsset.FromTaskItem);

                var relatedManifests = RelatedManifests.OrderBy(a => a.GetMetadata("FullPath"))
                                       .Select(ComputeManifestReference)
                                       .Where(r => r != null)
                                       .ToArray();

                if (Log.HasLoggedErrors)
                {
                    return(false);
                }

                var discoveryPatterns = DiscoveryPatterns
                                        .OrderBy(a => a.ItemSpec)
                                        .Select(ComputeDiscoveryPattern)
                                        .ToArray();

                PersistManifest(
                    StaticWebAssetsManifest.Create(
                        Source,
                        BasePath,
                        Mode,
                        ManifestType,
                        relatedManifests,
                        discoveryPatterns,
                        assets.ToArray()));
            }
            catch (Exception ex)
            {
                Log.LogError(ex.ToString());
                Log.LogErrorFromException(ex);
            }
            return(!Log.HasLoggedErrors);
        }