能否将VSCode扩展移植到Visual Studio 2017中使用?
Hey there! Let's break down your questions about VS Code, Visual Studio 2017, and porting that handy Excel viewer extension:
Are VS Code and Visual Studio Platforms Fully Independent?
Short answer: Yes, they are completely separate products with distinct architectures and extension ecosystems.
- VS Code is built on Electron (a Node.js/Chromium framework) and uses its own
VS Code Extension APIfor extensions. Most extensions are written in TypeScript/JavaScript, packaged for the Electron runtime, and focus on lightweight, web-integrated workflows. - Visual Studio 2017 (Professional/Enterprise) is a .NET-based IDE, and its extensions rely on the Visual Studio SDK (VSPackage/MEF). These extensions are typically written in C#/VB.NET, target the .NET Framework, and integrate deeply with Visual Studio's native UI and core services.
The two platforms don't share extension compatibility—you can't install a VS Code extension directly in Visual Studio, and vice versa.
Is It Possible to Modify the VS Code Extension to Port It to Visual Studio 2017?
It’s technically doable, but it’s not a quick "tweak and deploy" task. Here’s what you need to consider:
1. Check for an Official Visual Studio Alternative First
Before diving into porting, browse the Visual Studio Marketplace for a GrapeCity-developed Excel viewer. GrapeCity often builds tools for both VS Code and Visual Studio, so there might already be an official version tailored for VS 2017—this would save you a ton of work.
2. If You Need to Port It Yourself
Porting requires rewriting significant parts of the extension to fit Visual Studio’s extension model:
- You’ll need to learn the basics of Visual Studio 2017 extension development: setting up a VSPackage project, working with tool windows or document tabs, and using the VS SDK APIs.
- The core Excel rendering logic might rely on GrapeCity’s GcExcel components—this part could potentially be reused, but you’ll need to wrap it in a UI that integrates with Visual Studio’s native interface (replacing VS Code’s web-based UI with a WPF/WinForms control compatible with VS).
- You’ll have to replace all VS Code-specific API calls (like document handling, panel management) with equivalent Visual Studio SDK tools (e.g.,
IVsUIShell,IVsDocumentManager). - Testing is critical: you’ll need to validate the extension works correctly in both VS 2017 Professional and Enterprise editions, as there are minor SDK differences between them.
Final Recommendation
If you’re not already familiar with Visual Studio extension development, porting this extension will be a steep learning curve. It’s far more efficient to use an existing official or community-built Excel viewer for Visual Studio 2017 if one exists.
内容的提问来源于stack exchange,提问作者kmote

