[英]Build .net core project by postbuild event in visual studio 2017
我有项目A
依赖于项目B
但没有从B
到A
引用。 我想构建和复制组件bin folder
项目的B
到bin 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 task和copy 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.