I have a situation where I want to copy the output assembly from one project into the output directory of my target application using MSBuild, without hard-coding paths in m
I have made this work, though I would love to find a cleaner solution that takes advanctage of the built-in parameters within MSBuild (like $(TargetDir), etc but to point at the project I want to grab the output for). Anyway, here is what I've done:
<Target Name="AfterBuild">
<Copy SourceFiles="$(SolutionDir)MyProject.Dal.Linq\bin\$(Configuration)\MyProject.Dal.Linq.dll" DestinationFolder="$(TargetDir)"/>
</Target>
I would love to see a cleaner solution, but this should do for now.
So, you want to have a reference, but not have it visible in VS. So you want it built if needed, and copied to output like any other Content
file. Here's how you'd do it:
<Target Name="IncludeDALImplementation" BeforeTargets="AfterBuild">
<MSBuild Projects="..\DalImplementation\DAL.csproj" BuildInParallel="$(BuildInParallel)" Targets="Build">
<Output TaskParameter="TargetOutputs" ItemName="DalImplementationOutput" />
</MSBuild>
<ItemGroup>
<Content Include="@(DalImplementationOutput)" />
</ItemGroup>
</Target>