예제 #1
0
        public void TestMergeBuildManifests()
        {
            var orchestratedModel = new OrchestratedBuildModel(new BuildIdentity("Orchestrated", "123"))
            {
                Endpoints = new List <EndpointModel>
                {
                    EndpointModel.CreateOrchestratedBlobFeed("http://example.org")
                }
            };

            orchestratedModel.AddParticipantBuild(CreatePackageOnlyBuildManifestModel());
            orchestratedModel.AddParticipantBuild(BuildModel.Parse(XElement.Parse(ExampleBuildString)));

            XElement modelXml = orchestratedModel.ToXml();
            XElement xml      = XElement.Parse(@"
<OrchestratedBuild Name=""Orchestrated"" BuildId=""123"">
  <Endpoint Id=""Orchestrated"" Type=""BlobFeed"" Url=""http://example.org"">
    <Package Id=""Foo"" Version=""1.2.3-example"" />
    <Package Id=""runtime.rhel.6-x64.Microsoft.Private.CoreFx.NETCoreApp"" Version=""4.5.0-preview1-25929-04"" Category=""noship"" />
    <Package Id=""System.Memory"" Version=""4.5.0-preview1-25927-01"" />
    <Blob Id=""symbols/inner/blank-dir-nonshipping"" NonShipping=""false"" />
    <Blob Id=""symbols/runtime.rhel.6-x64.Microsoft.Private.CoreFx.NETCoreApp.4.5.0-preview1-25929-04.symbols.nupkg"" />
    <Blob Id=""symbols/System.ValueTuple.4.5.0-preview1-25929-04.symbols.nupkg"" NonShipping=""true"" />
  </Endpoint>
  <Build Name=""SimpleBuildManifest"" BuildId=""123"" />
  <Build Name=""corefx"" BuildId=""20171129-04"" Branch=""master"" Commit=""defb6d52047cc3d6b5f5d0853b0afdb1512dfbf4"" />
</OrchestratedBuild>");

            Assert.True(XNode.DeepEquals(xml, modelXml));
        }
        public override bool Execute()
        {
            // Leave out attributes if they would just have empty string values.
            if (ManifestBranch == string.Empty)
            {
                ManifestBranch = null;
            }
            if (ManifestCommit == string.Empty)
            {
                ManifestCommit = null;
            }

            var identity = new BuildIdentity
            {
                Name         = ManifestName,
                BuildId      = ManifestBuildId,
                Branch       = ManifestBranch,
                Commit       = ManifestCommit,
                IsStable     = IsStable,
                VersionStamp = VersionStamp
            };

            var orchestratedBuild = new OrchestratedBuildModel(identity)
            {
                Endpoints = new List <EndpointModel>
                {
                    EndpointModel.CreateOrchestratedBlobFeed(BlobFeedUrl)
                }
            };

            foreach (ITaskItem buildManifestFile in BuildManifestFiles)
            {
                string contents = System.IO.File.ReadAllText(buildManifestFile.ItemSpec);

                BuildModel build = BuildModel.Parse(XElement.Parse(contents));

                foreach (PackageArtifactModel package in build.Artifacts.Packages)
                {
                    package.OriginBuildName = build.Identity.Name;
                }

                orchestratedBuild.AddParticipantBuild(build);
            }

            System.IO.File.WriteAllText(File, orchestratedBuild.ToXml().ToString());

            return(!Log.HasLoggedErrors);
        }
        public override bool Execute()
        {
            // Leave out attributes if they would just have empty string values.
            if (ManifestBranch == string.Empty)
            {
                ManifestBranch = null;
            }
            if (ManifestCommit == string.Empty)
            {
                ManifestCommit = null;
            }

            var orchestratedBuild = new OrchestratedBuildModel(new BuildIdentity(
                                                                   ManifestName,
                                                                   ManifestBuildId,
                                                                   ManifestBranch,
                                                                   ManifestCommit))
            {
                Endpoints = new List <EndpointModel>
                {
                    EndpointModel.CreateOrchestratedBlobFeed(BlobFeedUrl)
                }
            };

            foreach (ITaskItem buildManifestFile in BuildManifestFiles)
            {
                string contents = System.IO.File.ReadAllText(buildManifestFile.ItemSpec);

                BuildModel build = BuildModel.Parse(XElement.Parse(contents));
                orchestratedBuild.AddParticipantBuild(build);
            }

            System.IO.File.WriteAllText(File, orchestratedBuild.ToXml().ToString());

            return(!Log.HasLoggedErrors);
        }