locked
Using wildcards with Link RRS feed

  • Question

  • The following snippet works as desired:

       <EmbeddedResource Include="c:\path-outside-project\MyResources.es.resx">
    <Link>subfolder\MyResources.es.resx</Link>
    </EmbeddedResource>
    However, I'd like to do this instead:
        <EmbeddedResource Include="c:\path-outside-project\*.resx">
    <Link>subfolder\*.resx</Link>
    </EmbeddedResource>
    However, I get an error from using * in Link.

    Does anyone know a good trick for adding resources under a specific project subfolder?

    Thanks!
    Friday, September 25, 2009 9:14 PM

Answers

  • Mike, your suggestion got me headed in the right direction. Here's a solution that worked for me:

    <Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <Target Name="Default">
            <ItemGroup>
                <Parent Include="c:\path-outside-project\*.resx"/>
                <EmbeddedResource Include="@(Parent)">
                    <Link>project-subfolder\%(Parent.Filename).resx</Link>
                </EmbeddedResource>
            </ItemGroup>
            <Message Text="%(EmbeddedResource.Identity) - %(EmbeddedResource.Link)"/>
        </Target>
    </Project>
    Thanks!
    • Marked as answer by E. Alex Davis Monday, September 28, 2009 10:47 PM
    Monday, September 28, 2009 10:47 PM

All replies

  • how about a two staged approach:

    <Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <Target Name="Default">
            <ItemGroup>
                <Parent Include="c:\a\MyResources.es.resx"/>
                <Links Include="c:\a\subfolder\*.resx"/>
                <EmbeddedResource Include="@(Parent)">
                    <Link>@(Links)</Link>
                </EmbeddedResource>
            </ItemGroup>
            <Message Text="%(EmbeddedResource.Identity) - %(EmbeddedResource.Link)"/>
        </Target>
    </Project>
    Sunday, September 27, 2009 9:07 AM
  • Thanks for the suggestion, Mike. However, it does not appear to produce the desired result.

    I am seeing Parent expanded as expected, but not Links.

    Each EmbeddedResource gets a Link with the entire list of "Links".

    Is there a brute force way to construct the EmbeddedResource elements one at a time in a loop?

    I've been browsing the MSBuild docs, but haven't seen it yet...

    Thanks!

    Alex
    Monday, September 28, 2009 5:45 PM
  • Mike, your suggestion got me headed in the right direction. Here's a solution that worked for me:

    <Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <Target Name="Default">
            <ItemGroup>
                <Parent Include="c:\path-outside-project\*.resx"/>
                <EmbeddedResource Include="@(Parent)">
                    <Link>project-subfolder\%(Parent.Filename).resx</Link>
                </EmbeddedResource>
            </ItemGroup>
            <Message Text="%(EmbeddedResource.Identity) - %(EmbeddedResource.Link)"/>
        </Target>
    </Project>
    Thanks!
    • Marked as answer by E. Alex Davis Monday, September 28, 2009 10:47 PM
    Monday, September 28, 2009 10:47 PM