该fsproj文件实际上是一个MS Build脚本,因此您可以使用标准MS Build功能来定义变量(例如包含路径)并在项目文件中使用它们.这不像#I在F#脚本文件中使用指令那么简单,但它应该为您提供类似的功能.
例如,您可以创建一个Includes.proj定义包含路径的文件,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludePath>C:\MyIncludePath</IncludePath>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
然后,您可以修改该fsproj文件以引用上述文件并$(IncludePath)在引用中使用.遗憾的是,这必须在文本编辑器中完成(即卸载项目,修改它然后重新加载它):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Includes.proj" />
<!-- lots of other stuff -->
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="FSharp.Core" />
<Reference Include="MyAssembly">
<HintPath>$(IncludePath)\MyAssembly.dll</HintPath>
</Reference>
</ItemGroup>
<!-- lots of other stuff -->
</Project>
Run Code Online (Sandbox Code Playgroud)