元素选择中所需的属性include为空或缺失

时间:2018-03-20 21:52:31

标签: c# .net csproj

添加了对csproj文件的条件引用

<Choose>
  <When Condition="'$(Configuration)' == 'Debug With Project References'">
    <ItemGroup>
      <Reference Include="System.Windows.Forms" />
    </ItemGroup>
  </When>
</Choose>

现在有错误:

The required attribute include is empty or missing from the element choose

1 个答案:

答案 0 :(得分:0)

请勿尝试在<Choose>内插入<ItemGroup>标记,然后将其放置在下方:

  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Xml.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
  </ItemGroup>
  <Choose>
    <When Condition="'$(Configuration)' == 'Debug With Project References'">
      <ItemGroup>
      <Reference Include="System.Windows.Forms" />
      </ItemGroup>
    </When>
  </Choose>