如何将 fslexyacc 输出重定向到 .fsproj 中的特定文件夹?
How to redirect fslexyacc output to a specific folder in .fsproj?
我有以下 .fsproj
设置:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<FsLexToolExe>fslex.dll</FsLexToolExe>
<FsYaccToolExe>fsyacc.dll</FsYaccToolExe>
</PropertyGroup>
<ItemGroup>
<Compile Include="AST.fs" />
<FsYacc Include="Parser.fsp">
<OtherFlags>--module Parser</OtherFlags>
</FsYacc>
<FsLex Include="Lexer.fsl">
<OtherFlags>--module Lexer --unicode</OtherFlags>
</FsLex>
<Compile Include="Parser.fsi" />
<Compile Include="Parser.fs" />
<Compile Include="Lexer.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FsLexYacc" Version="10.2.0" />
</ItemGroup>
</Project>
我想要一个包含解析器模块的目录,以便它包含所有与解析器相关的文件。我尝试将文件夹路径添加到自动生成的文件中,如下面的代码片段所示,但这不起作用。
...
<ItemGroup>
<Compile Include="Parser/AST.fs" />
<FsYacc Include="Parser/Parser.fsp">
<OtherFlags>--module Parser</OtherFlags>
</FsYacc>
<FsLex Include="Parser/Lexer.fsl">
<OtherFlags>--module Lexer --unicode</OtherFlags>
</FsLex>
<Compile Include="Parser/Parser.fsi" />
<Compile Include="Parser/Parser.fs" />
<Compile Include="Parser/Lexer.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FsLexYacc" Version="10.2.0" />
</ItemGroup>
</Project>
有什么方法可以实现我在这里想要做的事情吗?
如果你look atFsLexYacc.targets
,你会发现它使用一个名为FsLexOutputFolder
的属性来决定输出路径。
<Target
Name="CallFsLex"
Inputs="@(FsLex)"
Outputs="@(FsLex->'$(FsLexOutputFolder)%(Filename).fs')" <-- Outpath
Condition="'@(FsLex)'!=''"
BeforeTargets="CoreCompile">
...
同样,FsYacc 有 FsYaccOutputFolder
。
相应的,我们在我们的项目文件中声明这个属性来设置目标路径。在这里,我们将所有生成的文件推送到 <Project>/Parser
.
<PropertyGroup>
<FsYaccOutputFolder>$(IntermediateOutputPath)Parser/</FsYaccOutputFolder>
<FsLexOutputFolder>$(IntermediateOutputPath)Parser/</FsLexOutputFolder>
</PropertyGroup>
如果您从 CLI 使用它,输出路径有一个 -o
选项。
我有以下 .fsproj
设置:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<FsLexToolExe>fslex.dll</FsLexToolExe>
<FsYaccToolExe>fsyacc.dll</FsYaccToolExe>
</PropertyGroup>
<ItemGroup>
<Compile Include="AST.fs" />
<FsYacc Include="Parser.fsp">
<OtherFlags>--module Parser</OtherFlags>
</FsYacc>
<FsLex Include="Lexer.fsl">
<OtherFlags>--module Lexer --unicode</OtherFlags>
</FsLex>
<Compile Include="Parser.fsi" />
<Compile Include="Parser.fs" />
<Compile Include="Lexer.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FsLexYacc" Version="10.2.0" />
</ItemGroup>
</Project>
我想要一个包含解析器模块的目录,以便它包含所有与解析器相关的文件。我尝试将文件夹路径添加到自动生成的文件中,如下面的代码片段所示,但这不起作用。
...
<ItemGroup>
<Compile Include="Parser/AST.fs" />
<FsYacc Include="Parser/Parser.fsp">
<OtherFlags>--module Parser</OtherFlags>
</FsYacc>
<FsLex Include="Parser/Lexer.fsl">
<OtherFlags>--module Lexer --unicode</OtherFlags>
</FsLex>
<Compile Include="Parser/Parser.fsi" />
<Compile Include="Parser/Parser.fs" />
<Compile Include="Parser/Lexer.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FsLexYacc" Version="10.2.0" />
</ItemGroup>
</Project>
有什么方法可以实现我在这里想要做的事情吗?
如果你look atFsLexYacc.targets
,你会发现它使用一个名为FsLexOutputFolder
的属性来决定输出路径。
<Target
Name="CallFsLex"
Inputs="@(FsLex)"
Outputs="@(FsLex->'$(FsLexOutputFolder)%(Filename).fs')" <-- Outpath
Condition="'@(FsLex)'!=''"
BeforeTargets="CoreCompile">
...
同样,FsYacc 有 FsYaccOutputFolder
。
相应的,我们在我们的项目文件中声明这个属性来设置目标路径。在这里,我们将所有生成的文件推送到 <Project>/Parser
.
<PropertyGroup>
<FsYaccOutputFolder>$(IntermediateOutputPath)Parser/</FsYaccOutputFolder>
<FsLexOutputFolder>$(IntermediateOutputPath)Parser/</FsLexOutputFolder>
</PropertyGroup>
如果您从 CLI 使用它,输出路径有一个 -o
选项。