SB2055
SB2055

Reputation: 12912

MSBuild - Post-Build capture binaries regardless of build configuration or framework?

Project A (a web app) depends on Project B (an exe) - I need to copy the exe using Project A's post-build event from bin of Project A to wwwroot of Project A.

I want to copy a binary from wherever it's dropped (bin/debug or bin/release or bin/debug/netcoreapp2.0 etc) without knowing the build configuration or target framework. Right now I'm doing this:

copy /Y $(ProjectDir)bin\debug\netcoreapp2.0\app.exe $(ProjectDir)wwwroot\exe\app.exe

Which works great locally, but when it builds somewhere else with a Release configuration, it fails. I could use some if/then checks but I'd rather have a macro that replaces the $(ProjectDir)bin\debug\netcoreapp2.0 chunk of the path so I'm always grabbing what I need without any knowledge of configuration/framework.

I've tried to use $(OutDir) and $(TargetDir) with no luck - these just give me the non-bin path.

Which macro should I be using?

Upvotes: 0

Views: 135

Answers (1)

Dylan Nicholson
Dylan Nicholson

Reputation: 1378

$(TargetPath) should be the complete path to your output executable. Not sure what you mean about $(TargetDir) giving you the 'non-bin' path. Not really a C# question BTW.

Upvotes: 2

Related Questions