MSBuild与目标。我怎样才能做到这一点?

时间:2013-11-27 08:58:50

标签: msbuild msbuild-task msbuild-4.0 msbuild-propertygroup

我在msbuild文件中有以下代码。

<?xml version='1.0' encoding='ISO-8859-1' ?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
    <ExtensionImportPath Condition="Exists('$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks') AND '$(DOTNETFRAMEWORK)'!='3.5'">$(MSBuildExtensionsPath)\ExtensionPack\4.0\</ExtensionImportPath>
    <ExtensionImportPath Condition="'$(ExtensionImportPath)' == ''">$(MSBuildExtensionsPath)\ExtensionPack\</ExtensionImportPath>
</PropertyGroup>
    <Import Project="$(ExtensionImportPath)\MSBuild.ExtensionPack.tasks"/>

<PropertyGroup>
    <CommonTop Condition="'$(CommonTop)'==''">.</CommonTop>
    <Root>$(MSBuildProjectDirectory)</Root> 
    <SourceRoot>$(Root)</SourceRoot> 
    <OutputRoot>$(CommonTop)\bin</OutputRoot> 
    <OutputDebug>$(Root)\bin\Debug</OutputDebug>
</PropertyGroup>

    <Target Name="compile">
    <Message Condition="'$(verbose)'=='true'" Text="$(MSBuildProjectFullPath) - empty compile target"/>
    </Target>
</Project>

用于所有项目。在每个项目中,我然后有另一个msbuild项目,但我真的不能让它工作正常。这是我的代码

<?xml version='1.0' encoding='ISO-8859-1' ?>
<Project DefaultTargets="Start" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<CommonTop>.</CommonTop>
<!-- Importera top msbuild-->
<Import Project="..\\ms_top.proj"/>


<Target Name="Start">
  <ItemGroup>
     <ProjectsToBuild Include="$(CommonTop)\bulidmyHelloProject\hello.csproj" />
  </ItemGroup>
  <PropertyGroup>
        <PackageSubDir>myoutput\hello\Bin</PackageSubDir>
  </PropertyGroup>
  <Message Text="StartTest" />
</Target>
</Project>

我用这个参数调用它:/ t:compile / p:verbose = true / t:target = Start

但我收到错误:

CoreCompile:
  ProjectsToBuild.Properties=
  ProjectsToBuild.AdditionalProperties=
  ProjectsToBuild=
C:\Build\hello_labb_\src\w32\msbuild.proj : error MSB4057: Target target=Start does not exist in project 

我理解它所谓的第一个错误,但没有目标开始,但我怎样才能使它工作?我不想在顶级的msbuild文件中添加任何内容。

1 个答案:

答案 0 :(得分:1)

您在第二个代码段中的<PropertyGroup>周围缺少<CommonTop>.</CommonTop>。修复它并尝试 - 它是LGTM