I got a problem with a project using language parser tool antlr. First when i created project and installed antlr4, then it had succesfully integrated with a grammar file ECMAScript.g4, but once i added antlr3 framework and under this yet one grammar file JSDeobfucs.g and after that i tried to integrate this in the existing project, then project stopped building and files of lexer, parser, listener e.t.c. also are not created anymore, what outputs the compilation errors:
[Error] File
'C:\Users\Dima\Desktop\Projects\C#\JsAstVisitor\JsAstVisitor\obj\Debug\ECMAScriptBaseListener.cs'
not found. [Error] File
'C:\Users\Dima\Desktop\Projects\C#\JsAstVisitor\JsAstVisitor\obj\Debug\ECMAScriptLexer.cs'
not found. [Error] File
'C:\Users\Dima\Desktop\Projects\C#\JsAstVisitor\JsAstVisitor\obj\Debug\ECMAScriptListener.cs'
not found. [Error] File
'C:\Users\Dima\Desktop\Projects\C#\JsAstVisitor\JsAstVisitor\obj\Debug\ECMAScriptParser.cs'
not found.
For integration antlr3 in the Visual Studio 2017 i followed next instruction.
Althought it is strangely what similar instruction isn't created for Visual Studio 2017, so as project antlr build by target differs not only from depending on the antlr framework version
, but on the Visual Studio version. As well as, what in latest version of Visual Studio antlr 3 and 4 not suppored over graphical nuget package manager, but only over nuget manager console i can install them. Here is link to my project( i can't attach archive with a project here because stackoverflow are not supported all file types as i think ).
Therefore please say me:
What is problem can be here in ?
How to resolve it ?
Is it really that in Visual Studio in one C#
project two different versions of antlr conflict and will conflict
with each other ???
If two version of antlr conflicts in single
project, then how to do now that antlr4 again works in my current
project at least and in the same time i wouldn't do project
initially, if this is possibly of course ???
p.s. I found the similar problem with antlr source code generation in C# target here:
Use ANTLR to parse C++ with C#
As i understand what i can use IKVM, but i don't understand: how it helps me in my common problem with antlr integration in C# project. Anyway help me, please.
I was facing the same issue, and this fixed it-
"You will need to right click the grammar file in Solution Explorer and select Properties. In the properties window, configure the following items.
Build Action: Antlr4
Custom Tool: MSBuild:Compile
Custom Tool Namespace: The complete name of the namespace you want the generated classes to be located within. The ANTLR Language Support extension configures this field according to the root namespace configured for the C# project combined with the subfolder within the project where the grammar is located."
Refer - https://github.com/tunnelvisionlabs/antlr4cs
Related
I was reading through the documentation on the .NET foundation's GitHub repository for the .NET project-system and saw that the latest system used to run C# projects on Visual Studio is the new Project System by default; however, as the older system, Common Project System (CPS), is being phased out what are some signs to help me discern which version of the Project System my project is using?
Is this determined by Visual Studio or will I be able to look at the .csproj file and know which system is being utilized to manage my projects?
I am not looking for the version of the .NET SDK but rather which project system is running my solution's file organization and project manifest.
Thanks to concise and enlightening comments from Jonathan Tyson and Ian Mercer there are a few ways to tell which version of Project System a solution is using.
1. As according to the Project System Documentation (link provided by Jonathan), you can tell based on the formatting of the project file.
In the project file, when the Target Framework is formatted like this:
net45
the project is using the new Project System. When formatted like this: v4.6.1
The project is utilizing the legacy Common Project System.
2. A quick way to tell without opening the project file is to right-click on the file and if you can select Edit .csproj without having to unload the project it is using the new Project System (provided by Ian).
Thank you guys for your insights!
I am referencing Gtk# and building using Mono, writing my code in VS Code (code.visualstudio.com). I'd like intellisense for C#. By "intellisense" I mean the correct functions, members, etc. come up with "." - this is separate from predictive suggestions based on other code in the file.
I have tried both the current Microsoft C# extension (https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) as well as the Legacy Microsoft C# extension (https://marketplace.visualstudio.com/items?itemName=ms-vscode.omnisharp).
Both of these appear to use OmniSharp as the means for providing intellisense, and both either load MS Build files and/or "project.json" files.
The current Microsoft C# extension seems to use "project.json" files which appear to follow a schema specifically for .NET Core. I tried to leverage this anyway by creating a local GtkSharp NuGet package out of the Mono DLLs, but I could not then "dotnet restore" because these NuGet packages were incompatible with .NET Core. I followed: https://docs.nuget.org/ndocs/hosting-packages/local-feeds and https://docs.nuget.org/ndocs/create-packages/creating-a-package
The Legacy Microsoft C# extension works if I use Visual Studio to generate solution (.sln) and project (.csproj) files. VS Code then recognizes these files and uses intellisense properly. Trying to hand-roll solution and project files failed because there seem to be a lot of entries OmniSharp is looking for when setting up using this method.
Fundamentally, I want to provide a simple lightweight configuration which says: "Here is my code (.cs files), and here are the assemblies I reference (.dlls) as well as their comment files (.xml)" - and then have VS Code provide intellisense for those files and referenced assemblies. The .NET Core "project.json" files are simple enough, but are incompatible. The MS Build files are significantly more complicated than what I am looking for and require Visual Studio (or maybe a much deeper knowledge of MS Build) to generate OmniSharp compatible files. I'm looking for a separation between build configuration and intellisense configuration.
How can I configure VS code to support intellisense for C# without the use of .NET Core or MSBuild?
This has nothing to do with build systems, and strictly relates to providing intellisense support using one of the OmniSharp-based C# VS Code extensions provided by Microsoft without the use of "project.json" or MS Build configuration files.
I'm trying to build my solution using TeamCity / MSBuild.
It's a WebAPI project which shares some entities in a PCL with a mobile client.
I see there are a few caveats around getting the PCL reference libraries installed on a buildserver, which I think I've sorted
(Building Portable Class Library Project in build server fails)
However, I'm getting an error during the build of the portable class library as follows:
[11:20:49][Doctrina.Pcl.Entities\Doctrina.Pcl.Entities.csproj] _GetSdkToolPaths
[11:20:49][_GetSdkToolPaths] GetSdkPropertyValue
*[11:20:49][GetSdkPropertyValue] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(975, 5): error APPX3212: SDK root folder for 'Portable 7.0' cannot be located. See http://go.microsoft.com/fwlink/?prd=12560&pver=1.0&plcid=0x409&ar=MSDN&sar=PlatformMultiTargeting&o1=Portable&o2=7.0 for more information.*
The "help" link doesn't go anywhere useful and it seems to be very google-resistant in terms of finding any resolution.
I don't have Visual Studio 2015 installed on the build-server at all, but I have installed PortableClassLibrary tools, copied the reference directory from my local PC over, etc, as per the other related SO question.
Help please?
I encountered this error when attempting to build portable projects targeting .NET Standard.
I managed to resolve it without installing Visual Studio on my build server, by copying from a machine that does have Visual Studio installed:
C:\Program Files (x86)\Microsoft SDKs\Portable\v14.0
C:\Program Files (x86)\MSBuild\Microsoft\Portable
C:\Program Files (x86)\ReferenceAssemblies\Microsoft\Framework.NETPortable
I later attempted to build a WebApi project targeting .NET Core (this was an xproj file) and as soon as I added the XProj file to my solution, I had to also copy:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet.Web
That got me a bit further but it also caused other projects to stop building properly (that were working fine without the XProj file in the solution). One thing I noticed, the NuGet tooling for .NET Core does not support authenticated NuGet feeds, so I had to enable anonymous access on my feed. But now my .NET Standard project now fails with error MSB4057: The target "_GenerateDependencyFragmentJson" does not exist in the project.
I've yet to get around to diagnosing this, but I hope the above information helps someone. If you're not using xproj files and just trying to use .NET Standard projects, the above should be all you need to build without installing Visual Studio.
Just a side note, I tried really hard to avoid having to copy these files by first trying to install Microsoft Build Tools 2015 Update 3, hoping it would put the required files in place, but it did not sadly. I'm pinning my hopes on the next version of MSBuild that is being used in VS15, and hoping that it's build tools package will have everything required to build this stuff when it comes out, as it doesn't seem like they are updating the 2015 Build Tools with this support.
When I include JetBrains-ReSharper my project using NuGet Package Manager, and then I try to rebuild the project, it shows an error.
Error 14 The type 'System.Threading.LazyInitializer' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll' and 'Project\packages\JetBrains.ReSharper.SDK.8.2.1158\bin\System.Threading.dll' Project\Filters\InitializeSimpleMembershipAttribute.cs
Can anybody can help me to solve the problem ?
Sadly, because ReSharper is a .net 3.5 application, and due to the way the SDK is set up, it includes references to the .net 3.5 compatible System.Threading.Tasks.dll back port Microsoft initially released with RX. The unfortunate part is that this file is referenced even if your plugin is a .net 4 project, and so you get conflicts with the real System.Threading.Tasks.
You can change your project to be .net 3.5, but then (again, due to the way the SDK is set up) you'll get other warnings about .net 4 assemblies that are referenced, but shouldn't be. Essentially, you just have to ignore those warnings. We're working on fixing all of this for 9.0.
However, as #derigel mentions in the comments - adding the ReSharper SDK to an MVC project is a little weird, and frankly, won't work. The ReSharper SDK is for building ReSharper plugin extensions. If you want to install ReSharper, download it from here: http://www.jetbrains.com/resharper/download/
I'm trying to get Antlr working using NuGet.
The current version of the Antlr.Runtime.dll that I'm trying to reference is 3.1.3.42154.
The issue is that when I try and build my Lexer and Parser .cs files I get a lot of build errors about missing types.
e.g. The class GrammarRuleAttribute cannot be found. I've looking in the Antlr.Runtime.dll and the class isn't there. However if you look at the Antlr project on GitHub then your can see the GrammarRuleAttribute should indeed be in the Antlr.Runtime.dll.
Is this a bug or am I missing something?
This is a somewhat time-sensitive Q/A because the C# targets for ANTLR (CSharp2 by Johannes Luber and CSharp3 by myself) change over time. I know the CSharp2 target has had some issues recently that are being worked on. As of this writing, the current version of the CSharp3 target is 3.3.1.
Here is a link to the CSharp3 target documentation, which includes several download links to the C# port of the ANTLR tool, the CSharp3 runtime, MSBuild support, and some tools for Visual Studio. I update this document periodically as new versions are released.
Edit: If you are experiencing display problems or exception messages when opening a grammar file, you should uninstall the ANTLR 3, StringTemplate, and Extensibility Framework extensions from the Extension Manager and reinstall them per the instructions in the linked documentation. I've updated the extensions to resolve the problem.
I had this problem when using CSharp2 or CSharp3. I'm building in ANTLRWorks 1.5rc1.
It turned out to be related to the ANTLR version. I installed the official package using NuGet, which was 3.1.x. After removing that and installing the unoffical 3.4.1 package, it worked.
There was still a minor issue relating to the HIDDEN channel in my test grammar. Changing it to Hidden (as defined in Antlr3.Runtime) resolved the issue