How can I get MSBUILD to evaluate and print the full path when given a relative path?

前端 未结 5 848
情话喂你
情话喂你 2020-12-13 17:05

How can I get MSBuild to evaluate and print in a task an absolute path given a relative path?

Property Group

5条回答
  •  甜味超标
    2020-12-13 17:53

    MSBuild 4.0 added Property Functions which allow you to call into static functions in some of the .net system dlls. A really nice thing about Property Functions is that they will evaluate out side of a target.

    To evaluate a full path you can use System.IO.Path.GetFullPath when defining a property like so:

    
      $([System.IO.Path]::GetFullPath('..\..\..\Public\Server\'))
    
    

    The syntax is a little ugly but very powerful.

提交回复
热议问题