2

i am wondering if anyone is successfully using SPFX in Visual Studio?

SPFX as it is is a nice idea, compared to how SharePoint development took place in the pre-2016 and SPO time. But it comes with this downside: Visual Studio Code. I see that Microsoft maybe plans to appeal to the more "hacky" Javascript volks and tied the SPFX development to VS Code, but VS Code is far from where Visual Studio is. Let alone refactoring of class names and files. There is that https://github.com/SharePoint/sp-dev-fx-vs-extension Repo, but it seems to not get much time and love.

Is there any other way to develop SPFX in the grown-up Visual Studio?

Jens Caasen
  • 597
  • 1
  • 6
  • 19

4 Answers4

1

The answer by Xin is not correct... that is CSOM... CSOM !== SPFx.

To be direct, there's zero value in what Visual Studio brings to the table for SPFx dev unless you're talking about Azure DevOps integration.

The reason people focus on VSCode is it reaches more developers and all you need is an editor. You don't NEED a full-blown IDE as there are no designers / wizards / etc to help you along the way.

A SPFx project is simply a Node.js project. If you get the Node.js tools for VS, you can use that. There is absolutely nothing special with a SPFx project. Treat it as a Node.js project in VS and you're good to go.

The reason that community addin doesn't get much love is that there isn't much demand for it. But all it does is simply run the Yeoman generator for SharePoint. IOW, it automates running the same command-line tools for you. From that point forward, you have a Node.js project and the above applies.

Andrew Connell
  • 4,939
  • 5
  • 30
  • 42
1

SPFX projects are written in JavaScript or TypeScript and they generate JavaScript client-side code. With that in mind and in terms of editor experience, VS Code has everything you need to develop great SPFX solutions - I wouldn't write it off on account of your positive experience with Visual Studio and the server-side C# solutions of the past. There are a lot of great tweaks you can make to your VS Code experience, from the theme to the bevvy of extensions that can enhance your experience depending on what it is you want to do. GitLens, Microsoft Teams Toolkit, etc. And more silly stuff like Power Mode

Speaking as someone who used to develop web parts and solutions in C#, there are things I miss being able to do - sure - when you have server-side control, you're basically operating in God-Mode -- BUT -- there are a tonne of benefits in the approach Microsoft has taken here. Node compile times are blazing fast compared to the build times of older C# solutions, they have improved their APIs massively over the years - meaning server-side interventions are not needed anywhere near as much. I haven't encountered any problem (yet) that I haven't been able to solve through the means on offer.

VS Code does have refactoring options - renaming a class, interface or variable is as simple as pressing F2 on your keyboard, and when you do so it renames all references in the open-workspace. You can then save all amended files using Ctrl+K S or the File Menu. and there are commands like Ctrl+Shift+R for refactoring methods. I would strongly encourage you to approach VS Code with an open mind - what the development team aren't providing, the open source community often are. It's a great IDE.

t0mgerman
  • 186
  • 2
  • 8
0

I tried creating a SPFx project once using VS2019 and community project template for SPFX. New Project hung VS forever.

VS Code is best for SPFx because it's lightweight, fast and has tons of extensions.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 13 '22 at 21:27
-2

I think you can use the community version to do the SPFx.

Just remember to add Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll in the NuGet.

Use the following code to get the SharePoint context

ClientContext context = new ClientContext(‘URL’) 

Get the SharePoint web at the URL:

Web web = context.Web; 

Thanks

Xin Ning
  • 51
  • 6