Beispiel #1
0
        public static PackageArtifactModel CreatePackageArtifactModel(ITaskItem item)
        {
            NupkgInfo info = new NupkgInfo(item.ItemSpec);

            return(new PackageArtifactModel
            {
                Attributes = ParseCustomAttributes(item),
                Id = info.Id,
                Version = info.Version
            });
        }
Beispiel #2
0
        private bool FeedContainsIdenticalPackage()
        {
            if (string.IsNullOrEmpty(PassIfIdenticalV2Feed) ||
                string.IsNullOrEmpty(PackageFile))
            {
                return(false);
            }

            var    packageInfo = new NupkgInfo(PackageFile);
            string packageUrl  =
                $"{PassIfIdenticalV2Feed}/package/{packageInfo.Id}/{packageInfo.Version}";

            byte[] localBytes = File.ReadAllBytes(PackageFile);

            bool identical = false;

            try
            {
                Log.LogMessage(
                    MessageImportance.High,
                    $"Downloading package from '{packageUrl}' " +
                    $"to check if identical to '{PackageFile}'");

                using (var client = new HttpClient
                {
                    Timeout = TimeSpan.FromMinutes(10)
                })
                    using (var response = client.GetAsync(packageUrl).Result)
                    {
                        byte[] remoteBytes = response.Content.ReadAsByteArrayAsync().Result;

                        identical = localBytes.SequenceEqual(remoteBytes);
                    }
            }
            catch (Exception e)
            {
                Log.LogWarningFromException(e, true);
            }

            if (identical)
            {
                Log.LogMessage(
                    MessageImportance.High,
                    $"Package '{PackageFile}' is identical to feed download: ignoring push error.");
            }
            else
            {
                Log.LogMessage(
                    MessageImportance.High,
                    $"Package '{PackageFile}' is different from feed download.");
            }

            return(identical);
        }
Beispiel #3
0
        public PackageArtifactModel CreatePackageArtifactModel(ITaskItem item)
        {
            _log.LogMessage($"Creating NupkgInfo based on '{item.ItemSpec}'");

            NupkgInfo info = _nupkgInfoFactory.CreateNupkgInfo(item.ItemSpec);

            return(new PackageArtifactModel
            {
                Attributes = MSBuildListSplitter.GetNamedProperties(item.GetMetadata("ManifestArtifactData")),
                Id = info.Id,
                Version = info.Version
            });
        }