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> 
相關問題