C#C
C#11mo ago
Cyclomatic

Conditional ItemGroup in .csproj (SDK style)

I'm trying to add this conditional ItemGroup

    <ItemGroup Condition="'$(IsPacking)' != 'true' OR '$(MSBuildProjectBuild)' == 'true'">
        <PackageReference Include="Microsoft.XmlSerializer.Generator" Version="9.0.1" />
        <DotNetCliToolReference Include="Microsoft.XmlSerializer.Generator" Version="9.0.1" />
    </ItemGroup>


Basically, want to use the ItemGroup if I have not run dotnet pack OR I have run dotnet build.

Any ideas why this isn't working? Even just using MSBuildProjectBuild check doesn't work for me.
Was this page helpful?