开发者

How do I set a property to the output of a command in msbuild/xbuild

开发者 https://www.devze.com 2022-12-27 09:53 出处:网络
In msbuild/xbuild I\'d like to have a \"libPath\" property which can be ovveridden on the commandlin开发者_JS百科e using /p:libpath=\"/path/to/all/libs\". But when this property is undefined I want to

In msbuild/xbuild I'd like to have a "libPath" property which can be ovveridden on the commandlin开发者_JS百科e using /p:libpath="/path/to/all/libs". But when this property is undefined I want to call pkg-config --retrieve-Path somePackage to get the current systems path.

I thought like here I need the output of a command to be stored in a Property.

The command always returns one line of output.

I have tryied something like

<PropertyGroup>
  <LibPath />
</PropertyGroup>

<Task ....>
  <Exec Command="pkg-config --retrieve-Path somePackage"
        Condition="$(LibPath)' == ''">
   <OutputTaskParameter="output"
          PropertyName="LibPath" />
  </Exec>
</Task>

But that didn't work.


You can't do that using exec because the Exec task cannot gather output from the tool or command that it runs.

You'll have to write a custom msbuild task that calls pkg-config and gather this output in a property.

0

精彩评论

暂无评论...
验证码 换一张
取 消