简体   繁体   English

MSBuild-构建后捕获二进制文件,而不考虑构建配置或框架?

[英]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. 项目A(一个Web应用程序)取决于项目B(一个exe文件)-我需要使用项目A的构建后事件将exe复制到项目A的bin到项目A的wwwroot中。

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. 我想从丢弃的任何位置(bin / debug或bin / release或bin / debug / netcoreapp2.0等)复制二进制文件,而无需了解构建配置或目标框架。 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. 它在本地运行良好,但是当使用Release配置在其他地方构建时,它会失败。 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. 我可以使用一些if / then检查,但是我宁愿有一个宏来替换路径的$(ProjectDir)bin\\debug\\netcoreapp2.0块,所以我总是在没有任何配置/框架知识的情况下抓住我需要的东西。

I've tried to use $(OutDir) and $(TargetDir) with no luck - these just give me the non- bin path. 我尝试使用$(OutDir)$(TargetDir)时没有运气-这些只是给我的非bin路径。

Which macro should I be using? 我应该使用哪个宏?

$(TargetPath) should be the complete path to your output executable. $(TargetPath)应该是输出可执行文件的完整路径。 Not sure what you mean about $(TargetDir) giving you the 'non-bin' path. 不确定$(TargetDir)给您“非bin”路径的含义。 Not really a C# question BTW. 其实不是C#问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM