Reputation: 1640
I have an MSBuild project using the new .Net SDK project format.
I'm trying to include files from outside the solution, which have their own folder structures and flatten that structure upon going to the build directory.
I.e.
Solution\
Lib\
lib1\
file1.dll
file2.dll
lib2\
file3.dll
file3.dll
Project\
project.csproj
I want the entire structure under \Lib
to be represented in my project in Visual Studio. I can do that with the following:
<ItemGroup>
<None Include="$(SolutionDir)\Lib\**\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
The problem is, the output directory contains the same folder structure. I would like all the files flattened to simply exist in my \bin
directory instead of \bin\lib1\file1.dll
, \bin\lib2\file3.dll
, etc.
Is there a way to handle this in the project file?
Upvotes: 1
Views: 825
Reputation: 100661
You should be able to change it to
<None Include="$(SolutionDir)\Lib\**\*" TargetPath="%(Filename)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
The updated target path will then no longer contain the subdirectories.
Upvotes: 2