Reputation: 11544
I have project A
which has dependency on project B
but there is no reference from B
to A
. I want build and copy assemblies in bin folder
of project B
to bin folder
of project A
. how can I do this with post build event and dotnet msbuild
.
I found this link but it works for VS 2015 and below and MS-Build:
Build another project by prebuild event without adding reference
Upvotes: 2
Views: 7894
Reputation: 548
Here is what worked for me. It comes from: https://github.com/dotnet/sdk/issues/677
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="if not exist $(OutDir)..\..\..\..\build mkdir $(OutDir)..\..\..\..\build" />
<Exec Command="copy $(OutDir)$(TargetName).dll $(OutDir)..\..\..\..\build\$(TargetName).dll /Y" />
<Exec Command="copy $(OutDir)$(TargetName).pdb $(OutDir)..\..\..\..\build\$(TargetName).pdb /Y" />
</Target>
Upvotes: 9
Reputation: 76760
how can I do this with post build event and dotnet msbuild
You can add Build task and copy task in the post build event in project A to achieve your request:
"$(MSBuildBinPath)\MSBuild.exe" "$(SolutionDir)ProjectB\ProjectB.csproj"
xcopy.exe "$(SolutionDir)ProjectB\bin\Debug\netcoreapp1.1\ProjectB.dll" "$(SolutionDir)ProjectA\bin\Debug\netcoreapp1.1"
If you have multiple assemblies in the bin folder of project B, you can also use the Wildcard to copy the assemblies, like
xcopy.exe "$(SolutionDir)ProjectB\bin\Debug\netcoreapp1.1\*.dll
Hope this can help you.
Upvotes: 4