Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net Core Support #144

ryanlin1986 opened this issue Jun 28, 2016 · 1 comment

.Net Core Support #144

ryanlin1986 opened this issue Jun 28, 2016 · 1 comment


Copy link

@ryanlin1986 ryanlin1986 commented Jun 28, 2016

Nuget error when installing for .Net Core console app:
Errors in c:\users\ryanl\documents\visual studio 2015\Projects\ConsoleApp2\src\ConsoleApp2\ConsoleApp2.xproj
Package Antlr4.Runtime 4.5.3-rc1 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Antlr4.Runtime 4.5.3-rc1 supports:
- net20 (.NETFramework,Version=v2.0)
- net30 (.NETFramework,Version=v3.0)
- net35-cf (.NETFramework,Version=v3.5,Profile=CompactFramework)
- net35-client (.NETFramework,Version=v3.5,Profile=Client)
- net40-client (.NETFramework,Version=v4.0,Profile=Client)
- net45 (.NETFramework,Version=v4.5)
- netcore45 (.NETCore,Version=v4.5)
- portable-net40+sl5+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile328)

Copy link

@ph1ll ph1ll commented Jul 5, 2016

The Antlr4.Runtime package can already be used with .NET Core projects, try a project file such as the following. The important part is adding an import that is supported by the Antlr4.Runtime package, such as "imports": "net45"

  "version": "1.0.0-*",

  "dependencies": {
    "Antlr4.Runtime": "4.5.3-rc1",
    "NETStandard.Library": "1.6.0"

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [

Obviously, I haven't been able to get the compile tools running in the Antlr4 package nicely, but as a workaround, I simply downloaded the antlr4.runtime.4.5.3-rc1.nupkg package from nuget and extracted the file antlr4-csharp-4.5.3-SNAPSHOT-complete.jar to my project root. I then added a batch script that would run the generator.

DEL /Q /S Generated
java -jar antlr4-csharp-4.5.3-SNAPSHOT-complete.jar *.g4 -o Generated -Dlanguage=CSharp_v4_5 -package "MyNamespace" -visitor

So, whenever I make changes to my .g4 files, I just run the script, which deletes and re-generates the .cs files for me.

Note, I had to use the jar file from the nuget package as I wasnt able to use this method with the antlr-4.3-complete.jar download from the website, due to subtle differences between the code generated by that version and the Antlr4.Runtime package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.