Last active
July 15, 2024 21:01
-
-
Save roozbehid/65719edd867690ce5191c244e41e63c5 to your computer and use it in GitHub Desktop.
MSBuild hack to copy output of a reference project into output. Reference project can be from other language like c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- | |
| I find myself using this a lot to coordinate incompatible reference types. but still project dependencies. | |
| Example 1. CSProj project referencing a C++ project which also brings some other native dependencies | |
| Example 2. .net core project running another project as .net48 executable, but referencing directly causes so much dll hell due to incompatibility of frameworks. | |
| This way you can put them in correct folder location | |
| --> | |
| <Target Name="CopyPublishedFiles" AfterTargets="BeforeBuild"> | |
| <MSBuild Projects="..\..\..\your_non_assembly_dependency.vcxproj" Targets="Publish;PublishItemsOutputGroup" RebaseOutputs="true" Properties="Configuration=$(Configuration)"> | |
| <Output TaskParameter="TargetOutputs" ItemName="_PublishOutputs" /> | |
| </MSBuild> | |
| <Copy SourceFiles="@(_PublishOutputs)" DestinationFolder="$(OutDir)\Native\MyDLLs\%(RecursiveDir)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" /> | |
| </Target> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment