开发者

Read Config Value in MSBuild Task

开发者 https://www.devze.com 2022-12-15 07:26 出处:网络
Is there a way to read a System.开发者_StackOverflow中文版Config connection string in an MSBuild task?

Is there a way to read a System.开发者_StackOverflow中文版Config connection string in an MSBuild task?

Basically I have my connection string setup in a config file

<add name="MyApp.MyConnectionString" connectionString="..." />

And I would like to reference it in an MSBuild task like so ...

<Target Name="Migrate" DependsOnTargets="Build">
    ...
    <Migrate Connectionstring="$(MyApp.MyConnectionString)" ... />
</Target>


There's an XMLRead task in the MSBuild Community Tasks Project, that uses xpath to pull out a value.

<XmlRead 
  XPath="/add/@connectionString"
  XmlFileName="app.config">
    <Output TaskParameter="Value" PropertyName="MyConnectionString" />
</XmlRead>
<Message Text="MyConnectionString: $(MyConnectionString)"/>

(note: totally untested)

0

精彩评论

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