templating
templating copied to clipboard
MSBuild conditional processing skips to write remaining content after the condition evaluated to be false if XML comment is inside the element
When the evaluation result of msbuild condition expression is false and inside the element there is xml comment mark(for example as below), MSBuild conditional processing couldn’t find the correct end of the condition and remaining content after the condition will be skipped to write.
<ItemGroup Condition="'$(AddToolkitPackage)' == 'True' OR '$(AddMarkupPackage)' =='True'"
<!---->
</ItemGroup>
Referring to the attached template.json and template file MauiClassLib.csproj in Repro.zip, use dotnet new repromauiclasslib -o MauiLib to instantiate the template for reproducing. Symbols AddToolkitPackage and AddMarkupPackage will computed to be false. Attached MauiClassLib - Ouput.csproj is the output file.
There are following 4 cases. Case 4 results in skipping to write remaining content.
- MSBuild conditional is nested in XML conditional(true)
- MSBuild conditional is nested in XML conditional(false)
- XML conditional is nested in MSBuild conditional(true)
- XML comment syntax is nested in MSBuild conditional(false)