-
Notifications
You must be signed in to change notification settings - Fork 387
Issue: XML Conditional Processing Not Working in .slnx Files #8784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This seems entirely reasonable to me - would you be willing to make a contribution? |
Yes I am willing. Will give it a try on the weekend to see if I can find it. Then report back. |
A fix for this has been merged to main but for a work around until the fix is released you can use this SpecialCustomOperation in your template. {
"$schema": "http://json.schemastore.org/template",
"SpecialCustomOperations": {
"**.slnx": {
"operations": [
{
"type": "conditional",
"configuration": {
"actionableIf": [ "<!--#if" ],
"actionableElse": [ "#else", "<!--#else" ],
"actionableElseif": [ "#elseif", "<!--#elseif", "#elif", "<!--#elif" ],
"endif": [ "#endif", "<!--#endif" ],
"trim" : "true",
"wholeLine": "true",
"evaluator": "C++"
}
},
{
"type": "balancednesting",
"configuration": {
"startToken": "<!--",
"realEndToken": "-->",
"pseudoEndToken": "-- >",
"id": "fixPseudoNestedComments",
"resetFlag": "_TestResetFlag_"
}
}
]
}
}
} |
Is your feature request related to a problem? Please describe.
Issue: XML Conditional Processing Not Working in .slnx Files
Problem Description
I'm trying to use XML conditional processing format in a .slnx file within a .NET template, but it doesn't work as expected. Since .slnx files are XML-based, I expected the standard XML conditional processing syntax to work, but it seems the templating engine doesn't recognize .slnx files as XML for conditional processing purposes.
Steps to Reproduce
--api false
)Expected Behavior
When generating a project with
--api false
, the entire section (including the conditional directives and the content between them) should be excluded from the generated .slnx file.Actual Behavior
The conditional directives (
<!--#if (api)-->
and<!--#endif-->
) are included in the output file as literal text, and the content between them is also included regardless of the condition value.Environment
Additional Context
The .slnx file format is relatively new and appears to be an XML-based solution file format. Since it's XML-based, I expected it to work with the standard XML conditional processing syntax as described in the documentation: https://github.com/dotnet/templating/wiki/Conditional-processing-and-comment-syntax#xml-based-formats
I believe this issue occurs because the .slnx extension is not mapped to XML for conditional processing purposes in the templating engine.
Possible Solution
The templating engine could be updated to recognize .slnx files as XML-based files for conditional processing purposes, similar to how it handles .csproj, .vbproj, and other XML-based files.
Alternatively, if there's a different recommended approach for handling conditional content in .slnx files, documentation on this would be helpful.
Describe the solution you'd like.
The templating engine could be updated to recognize .slnx files as XML-based files for conditional processing purposes, similar to how it handles .csproj, .vbproj, and other XML-based files.
Additional context
No response
The text was updated successfully, but these errors were encountered: