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

Intermittent build error in MSBuild or NCrunch or other possible tools #39

Closed
lextm opened this issue Sep 29, 2015 · 0 comments
Closed
Assignees

Comments

@lextm
Copy link

lextm commented Sep 29, 2015

Can find a similar report and detailed analysis in http://forum.ncrunch.net/yaf_postst921_Intermittent-build-error-with-ANTLR-3.aspx

..\Reference\Antlr\Antlr3.targets (126)#0: Unknown build error: : error 10 : internal error: {my grammar file}.g3 : System.InvalidCastException: Unable to cast object of type 'Antlr3.Targets.CSharp3Target' to type 'Antlr3.Codegen.Target'. at Antlr3.Codegen.CodeGenerator.LoadLanguageTarget(String language, String targetsDirectory) in j:\dev\github\sharwell\antlrcs\Antlr3\Codegen\CodeGenerator.cs:line 358 at Antlr3.Tool.Grammar..ctor(AntlrTool tool, String fileName, CompositeGrammar composite) in j:\dev\github\sharwell\antlrcs\Antlr3\Tool\Grammar.cs:line 585 at Antlr3.AntlrTool.GetRootGrammar(String grammarFileName) in j:\dev\github\sharwell\antlrcs\Antlr3\AntlrTool.cs:line 776 at Antlr3.AntlrTool.Process() in j:\dev\github\sharwell\antlrcs\Antlr3\AntlrTool.cs:line 624 LoadLanguageTarget at offset 344 in file:line:column j:\dev\github\sharwell\antlrcs\Antlr3\Codegen\CodeGenerator.cs:358:21 .ctor at offset 932 in file:line:column j:\dev\github\sharwell\antlrcs\Antlr3\Tool\Grammar.cs:585:13 GetRootGrammar at offset 59 in file:line:column j:\dev\github\sharwell\antlrcs\Antlr3\AntlrTool.cs:776:13 Process at offset 398 in file:line:column j:\dev\github\sharwell\antlrcs\Antlr3\AntlrTool.cs:624:21

If a solution contains multiple projects that contain ANTLR grammars, then compiling the two at the same time (at VS command prompt or via NCrunch) can lead to such exceptions. There would be no exception when compiling in VS, as VS seems to use another way to build solution.

In CI systems, it is usually only MSBuild that builds the solutions. Thus, this issue is really annoying.

A workaround is to manually build the ANTLR projects one by one, and later the solution.

MSBuild project1.csproj
MSBuild project2.csproj
MSBuild solution.sln
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants