0
votes

I'm looking at VSTS Build with the eyes of a Teamcity user. I'd like to set up multiple builds that each have the same set of parameters for MSBuild to use. For example, I'd like all my builds to share the CreateHardLinksForCopyFilesToOutputDirectoryIfPossible parameter.

I know I can manually write out /p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=true in each build configuration I set up, but I'd prefer to set this once using the variable system. However, when I set my variables using the variable editor, the VSTS agent converts variable names to upper case (as well as converting "." to "_" and other transforms), which means msbuild doesn't look at them (it was expecting the correct PascalCased version). I have verified this by echo-ing out all current environment variables, during build. I can't see any documentation on why this happens.

Is there a pattern to pass MSBuild parameters in via the variable system?

1
Am I missing something, can't you just do something like this? /p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)raterus
@raterus you're right, I certainly could. However, this means I can't configure a variable group in VSTS to set some common properties for all my builds. This seems like a surprising amount of redundancy vs what I'm used to in Teamcity. I can of course refactor most of my msbuild scripts to have their parameters be upper case; but this is a hack, and still doesn't work for predefined parameters.pattermeister
I still don't really understand what problem you are having. I understand how VSTS renames variable names though, but I'm not sure how that is affecting you in this case. If you wanted common parameters for all builds you could define a variable, aka SharedBuildValues with the value say "/p:Prop1=abc /p:Prop2=xyz /p:Prop=123". Then in your build definition/MSBuild arguments, you'd just put $(SharedVariables) alongside the "hardcoded" parameters.raterus
Can you attach a screenshot of what you have configured and/or the issue you are having? I was able to set this up without issue in my VSTS instance.tj-cappelletti
@pattermeister Since what you actually use is the value of the value, even the variable name is case-insensitive, you just need to make sure the value is what you need. I added the details in the answer, and you can have a try.Marina Liu

1 Answers

1
votes

For VSTS variable name, it’s case-insensitive. You just need to focus on the variable’s value.

Such as if you have the variable tHisIsMixEdCase with the value /p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=true.

enter image description here

Then no matter to use $(THISISMIXEDCASE) or $(tHisIsMixEdCase) in MSBuild arguments option, both of them work same as using /p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=true directly.

enter image description here enter image description here