繁体   English   中英

在 Visual Studio 2017 中通过 postbuild 事件构建 .net 核心项目

[英]Build .net core project by postbuild event in visual studio 2017

我有项目A依赖于项目B但没有从BA引用。 我想构建和复制组件bin folder项目的Bbin folder项目的A 我如何使用后期构建事件和dotnet msbuild来做到这一点。

我找到了这个链接,但它适用于 VS 2015 及以下版本和 MS-Build:

在不添加引用的情况下通过预构建事件构建另一个项目

这对我有用。 它来自: 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>

我如何使用后期构建事件和 dotnet msbuild 来做到这一点

您可以在项目 A 的 post build 事件中添加Build taskcopy task来实现您的要求:

"$(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

希望这可以帮到你。

暂无
暂无

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

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