Open JohnGalt1717 opened 10 months ago
What shell is being used to launch the publish
command in your CI pipeline?
runs-on: ubuntu-latest
(i.e. this is just the Visual Studio auto-generation modified to use Tags instead of Tag and add latest.)
This also fails with PowerShell 7. Both windows and linux should be documented of there is indeed a work around because I would argue that the baseline that visual studio should be generating should have latest;{github tag} in it and what everyone would naturally do.
Based on the experiments in https://github.com/dotnet/docs/issues/30417, I'd expect -p:ContainerImageTags='"latest;1234"'
to work on Ubuntu. That is, the single quote '
is consumed by the shell, and the double quote "
is consumed by MSBuild.
@KalleOlaviNiemitalo would the triple-quotes method that was documented here work as well?
@baronfel, the triple-quotes syntax worked in cmd.exe, I don't think it would work in Bash.
As for documenting the required syntax, @JohnGalt1717 we can definitely add to the existing XML-based samples we have in the docs in this repo to be very clear about how values should be passed on the various shells - we'll have that done for .NET 8 GA for sure now that you've shown me it's a problem. Once we have the content here we will work with the Docs team to get it flowed to any content on learn.microsoft.com that uses the SDK Containers tech.
'" doesn't work on ubuntu from Github actions. Triple quote (-p:ContainerImageTags="""latest;{{ github.sha }}""") also doesn't work.
Of special note is the documentation anywhere with ContainerImageTags on it. And in general the documentation for -p, --property should have this explicitly mentioned directly on that page.
This is an incredibly difficult topic to find anything in search for command line escaping because you get enormous noise.
For bash in GitHub Actions on Ubuntu I was able to pass multiple tags and GitHub Actions variable substitutions like this:
dotnet publish --os linux --arch x64 --configuration Release -p:PublishProfile=${{ inputs.profile }} --self-contained false -p ContainerImageTags='"${{ inputs.variant }}-fdd-atomic;latest-fdd-atomic"' /bl
because this is bash
I did need to wrap the entire thing in single-quotes to prevent expansion and preserve the double-quotes that the MSBuild property parser expects. I have had a lot more trouble with trying to use pwsh
on Ubuntu in GitHub Actions, though.
For bash in GitHub Actions on Ubuntu I was able to pass multiple tags and GitHub Actions variable substitutions like this:
dotnet publish --os linux --arch x64 --configuration Release -p:PublishProfile=${{ inputs.profile }} --self-contained false -p ContainerImageTags='"${{ inputs.variant }}-fdd-atomic;latest-fdd-atomic"' /bl
because this is
bash
I did need to wrap the entire thing in single-quotes to prevent expansion and preserve the double-quotes that the MSBuild property parser expects. I have had a lot more trouble with trying to usepwsh
on Ubuntu in GitHub Actions, though.
Where is inputs coming from?
'"latest;asdfasd"' definately doesn't work with this:
- name: Build and push image to Azure container registry
run: dotnet publish xxx.csproj -c Release -r linux-x64 -p:PublishProfile=DefaultContainer -p:ContainerImageTags='"latest;{{ github.sha }}"' --no-self-contained -p:ContainerRegistry=${{ env.CONTAINER_REGISTRY_LOGIN_SERVER }} /bl
working-directory: ./Api/Api/
inputs
in my case is actions inputs, but the same would work with any GitHub actions variable source, like env
or github
. Is there any way you can provide more detailed logging about what's going on? You can reference my GitHub actions here where I've got it working correctly.
Without something I can reproduce I'm not sure how I can help here - I'm simply not hitting the same error cases that you are.
run: dotnet publish xxx.csproj -c Release -r linux-x64 -p:PublishProfile=DefaultContainer -p:ContainerImageTags='"latest;{{ github.sha }}"' --no-self-contained -p:ContainerRegistry=${{ env.CONTAINER_REGISTRY_LOGIN_SERVER }} /bl
Is a dollar sign missing from {{ github.sha }}
?
run: dotnet publish xxx.csproj -c Release -r linux-x64 -p:PublishProfile=DefaultContainer -p:ContainerImageTags='"latest;{{ github.sha }}"' --no-self-contained -p:ContainerRegistry=${{ env.CONTAINER_REGISTRY_LOGIN_SERVER }} /bl
Is a dollar sign missing from
{{ github.sha }}
?
Yup ! That did it!
windows equivalent that will work sure would be nice.
Describe the bug
If you use -p=ContainerImageTags=latest;{githubid injected here} the command line doesn't work on github actions nor by putting a random value in locally. None of the escape techniques including %3b works. If you use %3b you get no actual build of the container, just an artifact left on disk. If you use \" it doesn't work. If you use '" it doesn't work. If you use "" it doesn't work.
Either the documentation needs to be updated to explain how to properly escape this, or this needs to be fixed to work correctly.
To Reproduce
dotnet publish proj.csproj -c Release -r linux-x64 -p:PublishProfile=DefaultContainer -p:ContainerImageTags=latest;1234 --no-self-contained -bl
Further technical details
dotnet cli with .net 7.400 sdk.