hey24sheep / azure-flutter-tasks

Easily build and deploy with latest Flutter build tasks for Azure DevOps Pipelines Tasks
https://marketplace.visualstudio.com/items?itemName=Hey24sheep.flutter
MIT License
89 stars 22 forks source link

Command arguments containing spaces treated differently to ones without #129

Open Adam-Langley opened 5 days ago

Adam-Langley commented 5 days ago

I am using the "FlutterCommand" task to create an MSIX file for deployment on Microsoft Windows. Because I will be producing two different MSIX outputs, one for Microsoft Store distribution, and one for "side loading" (direct file installation on Windows) - I will be using two different "publisher" argument values. One of them is a publisher matching my own digital certification, and it contains spaces. The other one is assigned by the Microsoft Partner Center for use in the Microsoft Store - it's a guid, and doesnt contain spaces.

Here is an example of how the task is used in my yaml.

- task: FlutterCommand@0
  displayName: "Create '${{ parameters.taskName }}' MSIX Content (Step 1)"
  inputs:
    projectDirectory: '$(projectDirectory)'
    arguments: 'pub run msix:build --publisher ${{ parameters.publisher }}'

When "publisher" contains spaces (e.g, MY PUBLISHER), arguments: 'pub run msix:build --publisher MY PUBLISHER' FlutterCommand expands the arguments string to

pub
run
msix:build
--publisher
MY
PUBLISHER

So, I need to wrap it in quotes, arguments: 'pub run msix:build --publisher "MY PUBLISHER"' which results in this

pub
run
msix:build
--publisher
MY PUBLISHER

Which is great, but now let's switch to the "Microsoft Store" task... arguments: 'pub run msix:build --publisher "00000000-0000-0000-0000-000000000000"' which results in this

pub
run
msix:build
--publisher
"00000000-0000-0000-0000-000000000000"

So, see how when an argument contains spaces, then quoting is required, and they will be stripped when passed to the final command. However, if the argument doesnt contain a space, surrounding quotes are NOT stripped, and hence will be passed into the final command.

This causes my finam AppxManifest to contain quotes in xml values that it shouldn't causing makeappx compilation errors.

I think the fix is as simple as always stripping quotes from arguments.