error MSB4067: The element <When> beneath element <Choose> is unrecognized
Asked Answered
A

2

16

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.

Absorb answered 20/7, 2017 at 13:9 Comment(0)
H
30

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

Hinshaw answered 25/7, 2017 at 7:3 Comment(0)
P
0

How to add more than one condition in a propertygroup?

<PropertyGroup Condition=" '$(TargetEnv)'=='development' ">
    <Revision>1</Revision>
</PropertyGroup>
Peter answered 30/4 at 14:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.