MSBuildWorkspace Get Embedded Resource Files

I'm trying to get out all embedded resource files from a solution using Roslyn and MSBuild Api.

private async Task<Document> CheckConstForLocalization(Document document, LocalDeclarationStatementSyntax localDeclaration,
    CancellationToken cancellationToken)
{
    foreach (var project in document.Project.Solution.Projects)
    {
        foreach (var sourceDoc in project.AdditionalDocuments)
        {
            if (false == sourceDoc.Name.EndsWith(".cs"))
            {
                Debug.WriteLine(sourceDoc.Name);
            }
        }

        foreach (var sourceDoc in project.Documents)
        {
            if (false == sourceDoc.Name.EndsWith(".cs"))
            {
                Debug.WriteLine(sourceDoc.Name);
            }
        }
    }

    var newRoot = await document.GetSyntaxRootAsync(cancellationToken);
    // Return document with transformed tree.
    return document.WithSyntaxRoot(newRoot);
}

When I modify my resource files to be AdditionFiles, I can get them through the project AdditionalDocuments. However I would like to be able to grab these with out doing so. The file does not appear in Documents or Additional Documents

How can I find Resx files without modifying their attributes?

Jon Skeet
people
quotationmark

You can't, at the moment. It isn't supported by the API. (I was researching this just yesterday.)

There's a feature request to support it which you might like to support and subscribe to, but I don't believe there's any way of doing this at the moment.

My understanding is that Visual Studio hooks into MSBuild more tightly than Roslyn's support does at the moment. (See the issue I raised about <Deterministic> for another example.)

people

See more on this question at Stackoverflow