How to pass variables to MSBuild with VSTS

时间:2018-02-05 12:54:12

标签: msbuild azure-devops azure-pipelines azure-pipelines-build-task

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 个答案:

答案 0 :(得分:1)

对于VSTS变量名,它不区分大小写。你只需要关注变量的值。

例如,如果变量tHisIsMixEdCase的值为/p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=true

enter image description here

然后,无论在MSBuild参数选项中使用$(THISISMIXEDCASE)还是$(tHisIsMixEdCase),它们都与直接使用/p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=true的工作方式相同。

enter image description here enter image description here