在visual studio中通过postbuild事件构建.net核心项目2017
问题描述:
我有项目A
,它依赖于项目B
,但没有参考B
到A
。我想要构建和复制项目B
的bin folder
中的程序集到项目A
的bin folder
。我怎么能这样做后建立事件和dotnet msbuild
。在visual studio中通过postbuild事件构建.net核心项目2017
我发现这个链接,但它适用于VS 2015年及以下,MS-体形:
Build another project by prebuild event without adding reference
答
我怎么能做到这一点与后生成事件和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
希望这可以帮助你。
答
这是什么为我工作。它来自: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>
这个问题呢?您能否让我知道关于这个问题的最新信息? –
@Leo-MSFT您的解决方案非常完美,谢谢。 –