• 使用MSBuild编译FsLex项目


    FsLex FsYacc微软本身也提供了一个项目模板。但是这个项目模板是lex和yacc文件均包含。我想只适用lex,但是如果每次使用命令行也觉得不够方便,于是还是研究了一番MsBuild的使用。

    使用msbuild hellp.fsproj /v:d 可以查看整个msbuild的流程,非常白盒。

    hello.fsproj文件:

    <?xml version="1.0" encoding="utf-8"?>

    <Project
    ToolsVersion="4.0"
    DefaultTargets="MyBuild"
    xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

     

    <UsingTask TaskName="FsLex" AssemblyFile="E:\Program Files (x86)\FSharpPowerPack-2.0.0.0\bin\FSharp.PowerPack.Build.Tasks.dll"/>
    <UsingTask TaskName="Fsc" AssemblyFile="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\FSharp.Build.dll"/>

    <PropertyGroup>

    <AssemblyName>hello</AssemblyName>
    <OutputPath>Bin\</OutputPath>

    </PropertyGroup>

    <ItemGroup>

    <Compile Include="*.fs"/>

    <Reference Include="FSharp.PowerPack"/>
    <Reference Include="System" />
    <Reference Include="System.Core" />

        以下不需要写,写了编译器会提示需要 -noframework  直接简化掉干脆不写

        <Reference Include="mscorlib" />

        <Reference Include="FSharp.Core" />

    </ItemGroup>


    <Target Name="MyBuild" >

    <MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')" />

    具体还有那些属性等,使用对象浏览器查看即可

          两个比较有用的路径:能找DLL 和targets文件,targets在不知道怎么写的时候很有用,模仿微软写法。

         C:\Program Files (x86)\Microsoft F#\v4.0 

         E:\Program Files (x86)\FSharpPowerPack-2.0.0.0\bin


    <FsLex
        InputFile="Lexer.fsl"
        OutputFile="Lexer.fs" <!-- 直接在proj文件目录生成Lexer.fs-->
        OtherFlags="--unicode"
    />
    <Fsc
        Sources="@(Compile)"
        OutputAssembly="$(OutputPath)$(AssemblyName).exe"
        References ="@(Reference)"
    />

    </Target>
    <Target Name="Clean" >
        <Delete Files="$(OutputPath)$(AssemblyName).exe" />
    </Target>
    <Target Name="Rebuild" DependsOnTargets="Clean;Build" />


    </Project>

  • 相关阅读:
    C++基础--if/else和switch/case的区别
    条件概率,联合概率,边缘概率及独立事件,古典概型
    Maven中的Archetype概念及作用用途
    Unable to execute 'doFinal' with cipher instance
    查看是否存在tomcat进程和关闭方法
    python中的‘’的作用
    sklearn中predict_proba()的用法例子(转)
    pandas.DataFrame.sample随机抽样
    最全的MonkeyRunner自动化测试从入门到精通(1)
    阿里创新自动化测试工具平台--Doom
  • 原文地址:https://www.cnblogs.com/jiangzhen/p/2321662.html
Copyright © 2020-2023  润新知