Include files with a wildcard in a folder in Visual Studio

I use

<ItemGroup>
  <EmbeddedResource Include="..\..\resources\hbm\*.hbm.xml" />
</ItemGroup>

include a bunch of xml files in my c # project. It works great.

But I do not want them at the "root level" of my project, I would rather see them in a subfolder in my project.

For example, this file is included in a folder Mappingin Visual Studio:

<ItemGroup>
  <EmbeddedResource Include="Mapping\User.hbm.xml" />
</ItemGroup>

What I want for my files *.hbm.xml.

I can’t figure out how to do this, and still keep my wildcard *.hbm.xmlpart, and also save the actual files in another directory.

I looked at the MSDN document on MSBUILD and the elements, but no luck.

+3
source share
2 answers

, .

, User.hbm.xml Mapping Visual Studio:

<ItemGroup>
  <EmbeddedResource Include="..\..\resources\hbm\User.hbm.xml">
    <Link>Mapping\User.hbm.xml</Link>
  </EmbeddedResource>
</ItemGroup>

<ItemGroup>
  <EmbeddedResource Include="..\..\resources\hbm\**\*.hbm.xml">
    <Link>%(RecursiveDir)\%(Filename)%(Extension)</Link>
  </EmbeddedResource>
</ItemGroup>
+5

, MSBuild, , , . , # .

  <ItemGroup>
    <None Include="..\SOMENAME.Tests\data\**\*.*">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Link>data\%(RecursiveDir)%(Filename)%(Extension)</Link>
    </None>
  </ItemGroup>

, , , MSBuild (.. $(ProjectPath)\data\somesubfolder), , .

OP , , : dotPeek , .

  <ItemGroup>
    <EmbeddedResource  Include="..\SOMENAME.Tests\data\**\*.*">
      <Link>resources\%(RecursiveDir)%(Filename)%(Extension)</Link>
    </EmbeddedResource>
  </ItemGroup>

( Visual Studio 2013)

+13

Source: https://habr.com/ru/post/1716629/


All Articles