How to interpolate strings in appveyor.yml
If I have set the configuration as suggested in reference yml file as so
build Configuration, i.e. Debug, Release, etc.
configuration: Release
I would then like to create an env variable available to my scripts like so
environment:
MSBUILD_CONFIGURATION: $(configuration)
which I would expect to work because it's the same as in the "artifacts" section of the reference yaml
#---------------------------------#
# artifacts configuration #
#---------------------------------#
artifacts:
# pushing a single file with environment variable in path and "Deployment name" specified
- path: MyProject\bin\$(configuration)
name: myapp
but the interpolation does not work. I get
onfiguration : The term 'configuration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
5+ [System.Environment]::SetEnvironmentVariable("MSBUILD_CONFIGURATION", "$(configu ...
6+ ~~~~~~~
7 + CategoryInfo : ObjectNotFound: (configuration:String) [], CommandNotFoundException
8 + FullyQualifiedErrorId : CommandNotFoundException
9
Is there a general string interpolation process happening with appveyor to allow DRY configuration setup. The reference yml is a bit vauge on this.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 24 Apr, 2014 03:38 PM
Hi Brad,
Interpolation doesn't work in environment variables section, but you can use $(msbuild_configuration) directly in artifact path.
- Feodor
2 Posted by bradphelan on 24 Apr, 2014 04:36 PM
That explains my confusion. Your documentation says to interpolate
$(configuration) instead of $(msbuild_configuration). With the wrong var
there is no error or warning, the artifact just fails to build.
You also write 'environment variable' when you mean yaml string
interpolation which confused me.
Hopefully I'll get it working tomorrow.
However I'm generally impressed and I like it more than microsofts visual
studio online product.
Thanks for the help
Brad.
Support Staff 3 Posted by Feodor Fitsner on 24 Apr, 2014 05:05 PM
I'm glad you like the service!
Sure, let me know if you have any questions!
4 Posted by bradphelan on 25 Apr, 2014 05:16 AM
The documentation still says as of this morning
# pushing a single file with environment variable in path and "Deployment name" specified - path: MyProject\bin\$(configuration) name: myapp
rather than
# pushing a single file with environment variable in path and "Deployment name" specified - path: MyProject\bin\$(msbuild_configuration) name: myapp
Support Staff 5 Posted by Feodor Fitsner on 25 Apr, 2014 06:19 AM
But I thought
msbuild_configuration
is your custom variable, no?configuration
in docs is just an example - you can replace any valid environment variable.6 Posted by bradphelan on 25 Apr, 2014 06:39 AM
Now you have me confused. I now have in my appveyor.yml
and I do not define msbuild_configuration anywhere. However my artifact was correctly built.
https://ci.appveyor.com/project/BradPhelan/weincad-net/build/0.0.24...
I also note more inconsistent string interpolation syntax. Below you use "{}" to interpolate the build and version whereas in the artifacts section you use "$()".
Support Staff 7 Posted by Feodor Fitsner on 25 Apr, 2014 06:57 AM
Try to output this variable to see its value, something like:
That {version} syntax was left for assembly patching only for compatibility with AppVeyor V1.
8 Posted by bradphelan on 25 Apr, 2014 07:11 AM
Sorry for wasting your time. My bad! I had from the begining in upper case
Perhapps it would be better if the information
is by default made available as environment variables for custom build_scripts. If I make my own custom build script do you do anything with the above settings such as generate a configuration file that msbuild automagically picks up from the build directory?
Support Staff 9 Posted by Feodor Fitsner on 25 Apr, 2014 05:15 PM
Both "platform" and "configuration" are set as environment variables with the same names, but only for "MSBuild" build mode. Do you think it makes sense to set them for custom scripts too?
10 Posted by bradphelan on 25 Apr, 2014 05:27 PM
The reason I need them is you don't seem to provide a way to produce a
oneclick build for exe distribution. I have to patch the csproj file
myself to get the versioning correct and supply different flags to the
build.
A well thought out oneclick builder for appveyor would help me a great
deal. Once I get it working you can have my scripts and figure out how to
integrate it. Some people are still delivering desktop apps these days :)
Support Staff 11 Posted by Feodor Fitsner on 25 Apr, 2014 05:34 PM
Desktop apps are cool - AppVeyor was started as a "deployment tool" written in WPF :)
OK, I'll change build worker service to always set these env variables for all build modes, but only if they are explicitly set on UI on in appveyor.yml.
Setting them to AnyCPU/Release may cause "configuration not found" on many projects - I'd prefer developers decide themselves which configuration is default in solution/project files.
bradphelan closed this discussion on 30 Apr, 2014 05:24 AM.