Hime.Build.Task 0.1.6

dotnet add package Hime.Build.Task --version 0.1.6
NuGet\Install-Package Hime.Build.Task -Version 0.1.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hime.Build.Task" Version="0.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hime.Build.Task --version 0.1.6
#r "nuget: Hime.Build.Task, 0.1.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hime.Build.Task as a Cake Addin
#addin nuget:?package=Hime.Build.Task&version=0.1.6

// Install Hime.Build.Task as a Cake Tool
#tool nuget:?package=Hime.Build.Task&version=0.1.6

What is it about?

MSBuild Task to compile Hime's grammar files

Hime is grammar compile provided under LGPL license by Cénotélie

The default option to compile grammar files is to use their console compiler which is somehow integrated into your build process.

This solution is an alternative offering "native" MSBuild task to compile grammars.

How to use?

  1. Add task package to your csproj file:
    <ItemGroup>
      ...
      <PackageReference Include="Hime.Build.Task" Version="0.1.6" IncludeAssets="build" />
    </ItemGroup>
  1. Add the target to compile grammar before source code compilation
    <Target Name="CompileGrammar" BeforeTargets="BeforeCompile">
     <CompileGrammar GrammarName="MyGrammar" 
                     GrammarFile="MyGrammar.gram" 
                     Namespace="MyParser.Grammar" 
                     OutputMode="Source" 
                     CodeAccess="Internal" 
                     OutputPath="." />
    </Target>
  1. Add the target to clean up the compilation result (optional)
    <Target Name="CleanGrammar" BeforeTargets="Clean">
      <Delete Files="MyGrammarLexer.bin" />
      <Delete Files="MyGrammarParser.bin" />
      <Delete Files="MyGrammarParser.cs" />
      <Delete Files="MyGrammarLexer.cs" />
    </Target>
  1. Switch your project to explicit compilation
    <PropertyGroup>
      ...
      <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
    </PropertyGroup>
  1. Add your files including auto-generated files to compilation
    <ItemGroup>
      
      <EmbeddedResource Include="MyGrammarLexer.bin" />
      <EmbeddedResource Include="MyGrammarParser.bin" />
      <Compile Include="MyGrammarLexer.cs" />
      <Compile Include="MyGrammarParser.cs" />
      
      <Compile Include="MyCompiler.cs" />
    </ItemGroup>
  1. That's all, it should work both in MSBuild console compilator as well as under Visual Studio 2017+
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.6 555 8/4/2020

Initial Release