简体   繁体   中英

How to copy folder along with items inside to output directory?

In c# project file, I can use below ItemGroup to copy all items in Folder1 including sub folders into output directory, but not Folder1 itself. I wonder can I copy Folder1 along with all items inside of it into output directory?

  <ItemGroup>
    <Content Include="$(SolutionDir)\ProjectFolder\Folder1\**\*">
      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
      <Visible>false</Visible>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

I had the same problem and found a solution by modifying <Link></Link> with

      <Link>Folder1\%(RecursiveDir)%(Filename)%(Extension)</Link>

if the folder is called Folder1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM