简体   繁体   English

在 FSX 脚本中动态加载 fsx 文件

[英]Loading fsx files dynamically in an FSX script

We are sharing a build script for FAKE across a set of projects.我们正在跨一组项目共享 FAKE 的构建脚本。 We want to keep this one build script the same but make it possible to extend with other targets.我们希望保持这个构建脚本相同,但可以扩展其他目标。 One way I could think of doing this is by loading .fsx files if they fit a specific naming pattern like al files that matches build-*.fsx however I can't seem to think of a way to load these files dynamically.我能想到的一种方法是加载.fsx文件,如果它们符合特定的命名模式,例如匹配build-*.fsx al 文件,但是我似乎无法想出一种动态加载这些文件的方法。 Any suggestions on how to do this or how to accomplish the desired result are all good as answers关于如何做到这一点或如何实现预期结果的任何建议都是很好的答案

if I could I would have done something like如果可以的话,我会做类似的事情

#load "build-*.fsx"

It's not completely clear to me why you want to do this but maybe this will help.我不完全清楚你为什么要这样做,但也许这会有所帮助。 Refer to a single script in each project:在每个项目中引用一个脚本:

#load "load-build-scripts.fsx"

And then in single load-build-scripts.fsx :然后在单个load-build-scripts.fsx

#load "build-1.fsx"
#load "build-2.fsx"
#load "build-3.fsx"
...

This second file you will need to change whenever you add a new script.每当添加新脚本时,您都需要更改第二个文件。


It's not generally recommended to do this.一般不建议这样做。 Because now if these separate scripts refer to each other then some scripts will be loaded more than once.因为现在如果这些单独的脚本相互引用,那么一些脚本将被加载不止一次。 Scripts aren't really meant to be used for cases this complex.脚本并不是真的要用于这种复杂的情况。

Another option is to use FAKE as a console project instead of using scripts and the fake-cli tool.另一种选择是使用 FAKE 作为控制台项目,而不是使用脚本和 fake-cli 工具。 Then you can use normal .NET project dependencies.然后你可以使用普通的 .NET 项目依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM