我正在使用WiX来创建Windows安装程序.不幸的是,我的安装程序会在每次更新时覆盖配置文件.我真正想要的是,如果找不到,安装程序只会创建该文件.
谢谢和问候,forki
F#3.0 beta包含一个查询{}计算表达式,包含大量新关键字.
如何在计算构建器中定义自己的关键字?
我想重写F#中的(/)运算符以获取字符串并保留数字的含义.
/// Combines to path strings
let (/) path1 path2 = Path.Combine(path1,path2)
let x = 3 / 4 // doesn't compile
Run Code Online (Sandbox Code Playgroud)
如果我尝试以下操作,我会得到"警告29扩展成员无法提供操作员重载.请考虑将操作符定义为类型定义的一部分."
/// Combines to path strings
type System.String with
static member (/) (path1,path2) = Path.Combine(path1,path2)
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
此致,forki
当我在Visual Studio中创建一个新项目时,它在fsproj文件中包含以下行:
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
Run Code Online (Sandbox Code Playgroud)
在CI服务器上,由于FSharpTargetsPath仍为空,因此无法构建.我们在CI服务器上使用F#3.1.1的新独立安装程序,并且没有安装Visual Studio.我需要添加什么才能使其工作?
我可以Expr<'a -> 'b>通过以下代码段将类型的引用转换为Linq表达式:
/// Converts a F# Expression to a LINQ Lambda
let toLambda (exp:Expr) =
let linq = exp.ToLinqExpression() :?> MethodCallExpression
linq.Arguments.[0] :?> LambdaExpression
/// Converts a Lambda quotation into a Linq Lamba Expression with 1 parameter
let ToLinq (exp : Expr<'a -> 'b>) =
let lambda = toLambda exp
Expression.Lambda<Func<'a, 'b>>(lambda.Body, lambda.Parameters)
Run Code Online (Sandbox Code Playgroud)
现在我想转换类型的引用,Expr<'a * 'b -> 'c>甚至可能转换为类型Expr<'a -> 'b -> 'c>的Linq Lambda表达式Expression<Func<'a,'b'c>>.
我怎样才能做到这一点?
此致,forki
我在我的构建工具(" FAKE - F#Make ")中托管FSI.exe,我需要从我的fsx脚本中设置FSI.exe的ExitCode.这可能吗?
目前我在F#构建脚本中引发错误,这会设置退出代码,但它也会在构建日志中显示讨厌的异常和stackstraces.
谢谢,提前和最诚挚的问候,Steffen
我希望NLog目标停止收听日志.该RemoveTarget方法似乎并没有工作.这是一个失败的测试.
public class when_stopping_to_listen
{
static Logger Logger;
static MemoryTarget target;
Establish context = () =>
{
var config = new LoggingConfiguration();
Logger = LogManager.GetLogger("TestLogger");
target = new MemoryTarget {Layout = "${message}", Name = "TestTarget"};
config.AddTarget(target.Name, target);
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, target));
LogManager.Configuration = config;
};
Because of = () =>
{
var config = LogManager.Configuration;
config.RemoveTarget(target.Name);
LogManager.Configuration = config;
Logger.Info("Test");
};
It should_be_empty = () => target.Logs.ShouldBeEmpty();
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
在Fake构建自动化工具中执行Powershell脚本的最佳方法是什么?
我觉得这个问题应该有一个明显的答案,但是通过搜索找不到任何东西.
我们正在尝试从F#中的http://www.haskell.org/all_about_monads/html/maybemonad.html构建Haskell-MaybeMonad示例.
这个想法是在两个词典中搜索一个mailaddress.如果两个查找中的一个返回结果,我们将查看第三个查找.
let bindM x k =
match x with
| Some value -> k value
| None -> None
let returnM x = Some x
type MaybeBuilder() =
member this.Bind(x, k) = bindM x k
member this.Return(x) = returnM x
member this.ReturnFrom(x) = x
member this.Delay(f) = f()
let maybe = MaybeBuilder()
//Sample dictionaries
let fullNamesDb =
[("Bill Gates", "billg@microsoft.com")
("Bill Clinton", "bill@hope.ar.us")
("Michael Jackson", "mj@wonderland.org")
("No Pref Guy", "guy@nopref.org")]
|> Map.ofList
let nickNamesDb =
[("billy", "billg@microsoft.com") …Run Code Online (Sandbox Code Playgroud)