What is equivalent to #I for a .fsproj file?

I want to convert a script to a project. In the script, I set the path to the referenced .dlls using #I. Is there a way to specify this path directly in the .fsproj file?

thanks

+6
source share
2 answers

The fsproj file is actually an MS Build script, so you can use the standard MS Build functions to define variables (such as your inclusion path) and use them in the project file. It is not as simple as using the #I directive in F # script files, but it should give you similar functions.

For example, you can create an Includes.proj file that defines your include path as follows:

 <?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> 

You can then modify the fsproj file to link to the above file and use $(IncludePath) in your links. Unfortunately, this must be done in a text editor (i.e. unload the project, change it and then reload):

 <?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> 
+7
source

You can set the help folders in Project PropertiesReference PathsAdd Folder .

If you want to do this programmatically, set the reference paths to <Project><PropertyGroup><ReferencePath>... and set the relative paths to the dll to <Project><ItemGroup><Reference><HintPath>... Here is a script in the reverse order (from the fsproj file to the fsx file), but it can give you some hints.

+5
source

Source: https://habr.com/ru/post/916449/


All Articles