My question is similar to Visual studio project build dependencies with no references? :
I have a Web API project that references some services from other projects in the same .sln file. I want their output (DependencyA.dll, DependencyB.dll) to be copied to my Web API output folder, but I don't want to add a project reference because I'm using dependency injection, so I don't want anything but the service interfaces to be available to the Web API project.
How can I make sure:
- Hitting F5 in VS 2022 will build the dependencies if necessary and copy them to the startup project's output folder
- This will also work with
dotnet build
since that is what we use in TeamCity (an additional PowerShell script for copying the files would be fine) - I guess it should always work, as long as we rundotnet build
for the .sln file?
Is there a better solution than adding .sln-level project dependencies and using a post-build task for the Web API project to copy the dependencies over?