예제 #1
0
        public bool TryPrepareForPublish()
        {
            if (Framework != null)
            {
                NugetFramework = NuGetFramework.Parse(Framework);

                if (NugetFramework.IsUnsupported)
                {
                    Reporter.Output.WriteLine($"Unsupported framework {Framework}.".Red());
                    return(false);
                }
            }

            ProjectContexts = SelectContexts(ProjectPath, NugetFramework, Runtime);
            if (!ProjectContexts.Any())
            {
                string errMsg = $"'{ProjectPath}' cannot be published  for '{Framework ?? "<no framework provided>"}' '{Runtime ?? "<no runtime provided>"}'";
                Reporter.Output.WriteLine(errMsg.Red());
                return(false);
            }

            return(true);
        }
        public async Task MultipleDocumentsReturnsMultipleContexts()
        {
            var workspaceXml =
                @"<Workspace>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""CSProj1"">
        <Document FilePath=""C:\C.cs"">{|caret:|}</Document>
    </Project>
    <Project Language=""C#"" CommonReferences=""true"" AssemblyName=""CSProj2"">
        <Document IsLinkFile=""true"" LinkFilePath=""C:\C.cs"" LinkAssemblyName=""CSProj1"">{|caret:|}</Document>
    </Project>
</Workspace>";

            using var testLspServer = await CreateXmlTestLspServerAsync(workspaceXml);

            var documentUri = testLspServer.GetLocations("caret").Single().Uri;
            var result      = await RunGetProjectContext(testLspServer, documentUri);

            Assert.NotNull(result);

            Assert.Collection(result !.ProjectContexts.OrderBy(c => c.Label),
                              c => Assert.Equal("CSProj1", c.Label),
                              c => Assert.Equal("CSProj2", c.Label));
        }