我们应该如何在 VSTS 中声明构建变量?

How should we declare build variables in VSTS?

我们应该如何在 VSTS 中声明构建变量?

$(Build.SourcesDirectory)/SomeFolder

$(Build.SourcesDirectory)\SomeFolder

我们应该使用什么,正斜杠还是反斜杠?

例如$(Build.SourcesDirectory)等于C:\agent\_work\

据此我们应该这样使用:$(Build.SourcesDirectory)\SomeFolder

但我不确定。什么是正确的?

您可以在 VSTS 中声明 $(Build.SourcesDirectory)/SomeFolder$(Build.SourcesDirectory)\SomeFolder 构建变量。它们是相同的,并且会自动扩展为 C:\agent\_work\SomeFolder

与VSTS中的构建变量无关;它应该与文件系统更相关。例如,在 Windows 10 中,当您同时键入 C:\Users\patrick\Pictures\ScreenshotC:\Users\patrick\Pictures/Screenshot 时。两者都可以进入截图文件夹

有关VSTS中构建变量的更多详细信息,请参阅this official tutorial