MSBuild:使用 ReadLinesFromFile 评估保留属性
我正在使用 MSBuild 自定义 Visual Studio、WiX、SandCastle 等项目的构建过程。 为了使其尽可能通用,我想使用定义一些“项目特定”设置的文本文件,例如应从何处加载文件、要运行哪些自定义可执行文件等等。
文本文件可能如下所示: $(MSBuildProjectDirectory)....\Projects\Project1\bin\Release obj\$(Configuration)\Project1.Files.wxi -in *.dll -id TEST
每一行代表一个命令或文件。
在我的目标中,我使用 ReadLinesFromFile 来获取这些文件的内容。 到目前为止,一切都很好!
问题是,这样做时不会评估“$(Configuration)、$(MSBuildProjectDirectory)”等保留属性,它们只是作为常规文本进行处理。
关于如何在不创建自定义任务的情况下评估这些 $ 占位符的任何想法?
提前致谢!
问候, 罗伯特哦。
I'm using MSBuild to customize the build process of Visual Studio, WiX, SandCastle, ... projects.
To keep it as generic as possible I'd like to use text files defining some 'project specific' settings, like where the files should be loaded from, which custom executables to run and so on.
A text file could look like this:
$(MSBuildProjectDirectory)....\Projects\Project1\bin\Release obj\$(Configuration)\Project1.Files.wxi -in *.dll -id TEST
Each line represents one command or file.
Inside my targets I'm using ReadLinesFromFile to get the contents of these files.
So far so good!
The problem is that the reserved properties like '$(Configuration), $(MSBuildProjectDirectory)' are not evaluated when doing so, they are just processed as regular text.
Any ideas on how I could evaluate these $-placeholders without creating a custom task?
Thanks in advance!
Regards,
robert.oh.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与其自己阅读这些行并解析所有内容,不如创建一个包含
文件中信息的单独文件(例如,命名为“local.build.config”),然后在实际项目中导入该文件在构建的顶部添加这样一行:
通过让 MSBuild 引擎做它最擅长的事情来防止重新发明轮子。
Rather than reading the lines and parsing everything yourself, why not create a separate file (named, for example, "local.build.config") that has the
information in the file, and then in your actual project do an import of the file with a line such as this at the top of your build:
Prevents reinventing the wheel by letting the MSBuild engine do what it does best.