I am using
<ItemGroup>
<EmbeddedResource Include="..\..\resources\hbm\*.hbm.xml" />
</ItemGroup>
to include a bunch of xml files into my C# project. Works fine.
But, I don't want them in the "root level" of my project, I would rather see them in a subfolder in my project.
For example, this file is included into a Mapping
folder in Visual Studio:
<ItemGroup>
<EmbeddedResource Include="Mapping\User.hbm.xml" />
</ItemGroup>
That's what I want for my *.hbm.xml
files.
I can't figure out how to do it and still keep my wildcard *.hbm.xml
part and also keep the actual files in a different directory.
I've looked at MSDN's doc on MSBUILD and items, but no luck.
Best Answer
Perhaps this has changed in MSBuild since the original answer was posted, but it is possible to use both wildcards and links at the same time. For example, I use the following block in a C# project to import data files into a test library.
The only disadvantage I've seen so far is that MSBuild recreates the folder names on the file system (ie
$(ProjectPath)\data\somesubfolder
) which is a little annoying but not a huge issue.As a test, I also tried the OP's request of embedding resources, using the following snippet, and again this seemed to work fine - dotPeek showed the resources were present in the compiled assembly in addition to being present in the Solution Explorer.
(This was using Visual Studio 2013 and still works as of VS2019)
Update 08Jun2021: The above syntax works is fine for old style csproj files, but if you are using the new SDK format, the syntax is a little different, albeit simpler.
The OP's original question of wildcard embedding can be accomplished with the following
And to have wildcard file copies for changed or missing files.