0

我有项目A,它依赖于项目B,但没有参考BA。我想要构建和复制项目Bbin folder中的程序集到项目Abin folder。我怎么能这样做后建立事件和dotnet msbuild在visual studio中通过postbuild事件构建.net核心项目2017

我发现这个链接,但它适用于VS 2015年及以下,MS-体形:

Build another project by prebuild event without adding reference

+0

这个问题呢?您能否让我知道关于这个问题的最新信息? –

+0

@Leo-MSFT您的解决方案非常完美,谢谢。 –

回答

2

我怎么能做到这一点与后生成事件和DOTNET的MSBuild

您可以在项目A的后期构建事件中添加构建任务复制任务以实现您的请求:

"$(MSBuildBinPath)\MSBuild.exe" "$(SolutionDir)ProjectB\ProjectB.csproj" 
xcopy.exe "$(SolutionDir)ProjectB\bin\Debug\netcoreapp1.1\ProjectB.dll" "$(SolutionDir)ProjectA\bin\Debug\netcoreapp1.1" 

如果您在项目B的bin文件夹中有多个组件,您还可以使用通配符复制组件,像

xcopy.exe "$(SolutionDir)ProjectB\bin\Debug\netcoreapp1.1\*.dll

希望这可以帮助你。

4

这是什么为我工作。它来自: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> 
相关问题