在.props文件中包含未知属性

时间:2015-08-10 21:14:44

标签: msbuild

我正在准备一个项目解决方案,因为我计划发布一些nuget项目。为了避免将来的麻烦,我考虑共享所有csproj文件中相同的构建属性。

奇怪的是,我收到一条消息,指出内容元素中的include属性未知。

我做错了什么/不寻常吗?

project.v400.csproj

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
    <Import Project="..\..\CommonBuildTargets.props"/>
    <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProjectGuid>{AA7888A1-E7B4-477F-924E-BF97964B17FA}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>project</RootNamespace>
        <AssemblyName>project</AssemblyName>
        <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
    </PropertyGroup>
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>$(CommonBuildPathDebug)</OutputPath>
        <DefineConstants>TRACE;DEBUG;NET400</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
    </PropertyGroup>
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>$(CommonBuildPathRelease)</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
    </PropertyGroup>
    <ItemGroup>
        <Reference Include="System" />
        <Reference Include="System.Core" />
        <Reference Include="System.Xml.Linq" />
        <Reference Include="System.Data.DataSetExtensions" />
        <Reference Include="Microsoft.CSharp" />
        <Reference Include="System.Data" />
        <Reference Include="System.Xml" />
    </ItemGroup>
    <ItemGroup>
    </ItemGroup>
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

CommonBuildTargets.props

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <CommonBuildPathDebug>..\Build\$(AssemblyName)\$(Configuration)\$(TargetFrameworkVersion)\</CommonBuildPathDebug>
        <CommonBuildPathRelease>..\Build\$(AssemblyName)\$(Configuration)\$(TargetFrameworkVersion)\</CommonBuildPathRelease>
        <CommonRecursionRoot>.\src\project.v460\**\*.cs</CommonRecursionRoot>
        <CommonContentExclusion>.\src\project.v460\obj\**</CommonContentExclusion>
    </PropertyGroup>

    <PropertyGroup>
        <Content Include="$(CommonRecursionRoot)" Exclude="$(CommonContentExclusion)">
            <Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
        </Content>
    </PropertyGroup>
</Project>

我已经单独测试了递归内容包含,但效果很好。一旦我将它提取到一个共享的道具文件(加载也很好,也测试了它),它就不再起作用了。

1 个答案:

答案 0 :(得分:0)

我通常会删除这个问题,但因为我没有偶然发现其他问题:

它不起作用的原因是因为我将我的Content元素放在属性组而不是itemgroup