I've worked out that in my C#/F# code I can load information about any .NET project using
collection.LoadProject(path_to_my_proj_file)
where collection is of type ProjectCollection. I can then get the access to all the properties and items defined in the project and all of its dependencies. As an example I can get an access to all the files included via Compile in the following way
project.GetItems "Compile"
Let's assume I want to define a custom ItemGroup in my fsproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<ItemGroup>
<MyGroup Include="Test.txt" />
<MyGroup Include="TestFiles\**\*" />
</ItemGroup>
</Project>
Some comments:
MyGroupis my custom collection identifier. I've found out things like this are allowed- The "TestFiles" folder contains 4 files all together that exist in some subfolders, but they all match the pattern "TestFiles\**\*"
When I load the project using the method I had mentioned at the beginning and run
project.GetItems "MyGroup"
I get only one item, that is "Test.txt". The other files don't get discovered, unless I define them explicitly (i.e. without the wildcard) in the fsproj.
Is there a way for me to discover the files included using wildcards as well ? I'm even happy to get them in the unresolved form. So getting "TestFiles\**\*" instead of specific files that match the pattern is fine as well.