Visual studio 在MSBuild下模拟Devenv/Runexit

Visual studio 在MSBuild下模拟Devenv/Runexit,visual-studio,msbuild,build-automation,Visual Studio,Msbuild,Build Automation,我不熟悉MSBuild,正忙于自动化VisualStudio解决方案的测试 我以前使用过命令行Devenv,它提供了一种方便的/Runexit操作模式。从手册中: /Runexit (devenv.exe) Compiles and runs the specified solution, minimizes the IDE when the solution is run, and closes the IDE after the solution has finished running

我不熟悉MSBuild,正忙于自动化VisualStudio解决方案的测试

我以前使用过命令行
Devenv
,它提供了一种方便的
/Runexit
操作模式。从手册中:

/Runexit (devenv.exe)  
Compiles and runs the specified solution, minimizes the IDE when the solution is run,
and closes the IDE after the solution has finished running. 
这正是我需要的功能。我现在正在迁移到MSBuild。我发现解决方案中的项目文件可以直接用于构建,因为默认目标正是构建


如何处理与
/Runexit
具有相同效果的不同目标?你能帮我走过迷宫吗?

这是运行项目输出文件的最基本目标:

<Target Name="RunTarget">
  <Exec Command="$(TargetPath)" />
</Target>

到底有什么不同的目标?假设您运行测试的目标是
Test
,那么您将运行
msbuild/t:Rebuild;Test
先重建然后测试..@stijn我的问题正是如何创建一个将执行生成结果的目标,即
Test.exe
。默认情况下,项目文件中没有这样的目标。Works now。你让我开心,谢谢。我必须添加一个
WorkingDirectory
属性,拼写与
<?xml version="1.0" encoding="utf-8"?> 
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <ItemDefinitionGroup />
  <ItemGroup />
  <!--Used to be AfterTargets="AfterBuild", but that is unusable since a failing test marks the build as unsuccessful,
      but in a way that VS will always try to build again. As a consequence debugging in VS is impossible since
      VS will build the project before starting the debugger but building fails time and time again.-->
  <Target Name="RunUnitTests" AfterTargets="FinalizeBuildStatus">
    <Exec Condition="$(UnitTestExtraPath)!=''" Command="(set PATH=&quot;%PATH%&quot;;$(UnitTestExtraPath)) &amp; $(TargetPath)" />
    <Exec Condition="$(UnitTestExtraPath)==''" Command="$(TargetPath)" />
  </Target>
</Project>