我正在尝试在我的蛋糕脚本中使用 Linq 扩展方法,但我无法让它找到扩展方法。
这是我的脚本:
#r System.Linq
Task("Default").Does(() =>
{
var test = new List<string>() {"a", "b", "c"};
test.OrderByDesc(x => x);
});
RunTarget(target);
我尝试了很多不同的引用方式System.Link
——例如.dll
在引号上添加或包装它。所有这些似乎都有效。如果我将其设为不正确的引用,例如System.Link
,在执行带有“Assembly Not Found”的脚本时安装插件时会出错。
这是我得到的完整输出:
PS C:\git\CakeEFTest\CakeTest> ./build.ps1 --experimental
Preparing to run build script...
Running build script...
Analyzing build script...
Processing build script...
Compiling build script...
Error: C:/git/CakeEFTest/CakeTest/build.cake(6,7): error CS1061:
'List<string>' does not contain a definition for 'OrderByDesc'
and no extension method 'OrderByDesc' accepting a first argument
of type 'List<string>' could be found (are you missing a using
directive or an assembly reference?)
如果我在没有--experimental
.
根据 Cake 存储库中的问题,这应该可以按预期工作:https ://github.com/cake-build/cake/issues/1331