在FAKE MSBuild任务中定义预处理程序符号

Eri*_*and 2 c# msbuild build c-preprocessor f#-fake

有没有办法MSBuild在FAKE 中的任务中定义预处理器符号?

例如,如果我的代码中包含类似的内容:

#if LOCAL
private static string databaseUrl = "http://localhost/myDbFile.sqlite";
#else
private static string databaseUrl = "http://www.website.com/myPublicDbFile.sqlite";
#endif
Run Code Online (Sandbox Code Playgroud)

然后我想LOCAL在我的F#构建脚本中在构建时定义符号.

Eri*_*and 5

感谢Ron Beyer(见评论)指出我正确的方向.答案确实是使用DefineConstants项目属性.在典型的FAKE MSBuild任务中,这将如下所示:

// Build a special version with the "SPECIAL" directive defined.
MSBuild
    null 
    "publish" 
    ([
        ("Configuration", "Release"); 
        ("Verbosity", "minimal");
        ("ProductName", "My Project (Special)");
        ("InstallUrl", "http://www.example.com/software/MyProjectSpecial/");
        ("DefineConstants", "SPECIAL")
    ])
    ["../MyProject/MyProject/MyProject.csproj"] 
        |> ignore
Run Code Online (Sandbox Code Playgroud)