Skip to content

Instantly share code, notes, and snippets.

@RhysC
Last active May 19, 2016 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RhysC/63c0b80182ec65f8517eeb95067ffb2c to your computer and use it in GitHub Desktop.
Save RhysC/63c0b80182ec65f8517eeb95067ffb2c to your computer and use it in GitHub Desktop.
Getting pesky linked DLLs in to the bin dir without subfolders (MSBUILD in csproj files)
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- pervious msbuild project cruft clipped this is just a .csproj-->
<ItemGroup>
<Content Include="..\OtherProject\libs\**\*.dll">
<Link>libs\%(RecursiveDir)%(Filename)%(Extension)</Link>
<!-- copy after the build so i can have the dlls in a linked lib folder in the project bt in the root in bin -->
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="BeforeBuild">
<!-- this copies the linked files over to your project pre build -->
<Copy SourceFiles="%(Content.Identity)" DestinationFiles="%(Content.Link)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" Condition="'%(Content.Link)' != ''" />
</Target>
<Target Name="AfterBuild">
<!-- this copies the dlls to your bin without having an added /lib/ folder (that wont be picked up at run time) -->
<Copy SourceFiles="$(ProjectDir)\libs\mybinary1.dll" DestinationFolder="$(OutputPath)" ContinueOnError="false" />
<Copy SourceFiles="$(ProjectDir)\libs\mybinary2.dll" DestinationFolder="$(OutputPath)" ContinueOnError="false" />
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment