error MSB4067: The element beneath element

2020-07-05 05:56发布

问题:

I have the following code:

<Import Project="C:\Program%20Files%20(x86)\MSBuild\ExtensionPack\4.0.13.0\x64\MSBuild.ExtensionPack.tasks" />

<PropertyGroup>
    <Workspace></Workspace>
    <SolutionName></SolutionName>
    <TargetEnv></TargetEnv>
    <DeployPath></DeployPath>
    <TargetBranch></TargetBranch>
    <BuildNumber></BuildNumber>
    <Revision></Revision>
</PropertyGroup>

<Target Name="assinfo">

<Choose>
    <When Condition=" '$(TargetEnv)'=='development' "> 
            <PropertyGroup>
                <Revision>1</Revision>
            </PropertyGroup>
        </When>
</Choose>

Msbuild shows this error:

C:\workspace\BuildScripts\buildTEST.proj(20,3): error MSB4067: The element "When" beneath element "Choose" is unrecognized.

I need to understand what's wrong.

回答1:

It looks like you tried to use <Choose> inside a <Target> element. This is currently not supported by MSBuild.