解决方案构建后运行MsBuild任务(目标?)? [英] run MsBuild tasks (targets?) after the solution is built?

查看:167
本文介绍了解决方案构建后运行MsBuild任务(目标?)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为这个问题似乎感到困惑/不知所措,所以我将用我自己的部分构想来重新表述它.

Since this question seems to have baffled / underwhelmed SO I will rephrase it with a partially formed idea of my own.

我能以某种方式设置一个批处理文件或在整个解决方案构建后在运行的某些东西,并且该批处理文件将调用 msbuild 在特定内部构建特定目标项目?为了使其正常工作,我不得不以某种方式强制 msbuild 构建目标,而不必考虑它是否认为它是最新的" ,因为这是核心问题我反对.

Could I somehow set up a batch file or something that runs after the whole solution is built, and this batch file would call msbuild to build specific targets inside a certain project? In order for it to work, I would have to somehow force msbuild build the target without regard to whether it thinks it's "up to date", because that is the core issue I'm butting up against.

推荐答案

由于您要专门处理构建,因此您可能希望用MSBuild文件替换批处理文件.例如:

Since you are dealing with building specifically you may want to replace your batch file with an MSBuild file. For example:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <ItemGroup>
    <SolutionsToBuild Include="MySolution.sln"/>

    <Projects Include="Proj1.csproj"/>
    <Projects Include="Proj2.csproj"/>
    <Projects Include="Proj3.csproj"/>
  </ItemGroup>

  <Target Name="BuildAll">

    <!-- Just executes the DefaultTargets (Build) -->
    <MSBuild Projects="@(SolutionsToBuild)"/>

    <!-- Call Rebuild if you think its not building correctly -->
    <MSBuild Projects="@(Projects)"
             Targets="Rebuild"/>

  </Target>
</Project>

然后,您只需使用以下命令在此文件上调用msbuild.exe:

Then you just invoke msbuild.exe on this file with:

msbuild.exe Build.proj /t:BuildAll

由于您说过要在构建解决方案后构建特定项目,因此只需将其放入如图所示的Projects ItemGroup中,并在构建解决方案后使用MSBuild任务来构建它们.我已经指定了Rebuild目标,以确保您获得一个干净的版本.

Since you said that you want to build specific projects after the solution is built just put those into the Projects ItemGroup as shown and use the MSBuild task to build them after the solution has been built. I've specified the Rebuild target to make sure you get a clean build.

这篇关于解决方案构建后运行MsBuild任务(目标?)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆