sharpliner / sharpliner

Use C# instead of YAML to define your Azure DevOps pipelines
https://www.nuget.org/packages/Sharpliner/
MIT License
285 stars 21 forks source link

Parameters are using Compile-Time Expressions in Conditions but should be using Runtime Expressions #230

Closed thomhurst closed 1 year ago

thomhurst commented 1 year ago

Take this C# code:

If.Equal(parameters["restore"], "true")

This produces the following YAML:

 ${{ if eq('${{ parameters.restore }}', 'true') }}:

This is incorrect. A valid syntax would be:

 ${{ if eq(parameters['restore'], 'true') }}:
premun commented 1 year ago

Thanks for reporting!

Also sort of related to this: https://github.com/sharpliner/sharpliner/issues/125

premun commented 1 year ago

I see the problem. This is not about having ${{ inside of another one. I think we're actually stripping that somewhere but might have got broken with the apostrophe we've added in the last version.

premun commented 1 year ago

Yeah, I think we broke this piece of logic with the apostrophes: https://github.com/sharpliner/sharpliner/blob/4c3a5f736c4759bc76dd7ef026cd86e813bb58d6/src/Sharpliner/AzureDevOps/ConditionedExpressions/Condition.cs#L59

premun commented 1 year ago

@thomhurst can you please confirm that it works with 1.4.1?

thomhurst commented 1 year ago

Yes that worked!