How to create a F# based Visual Studio Add-In?

。_饼干妹妹 提交于 2019-12-30 06:58:05

问题


Even with F# installed, Visual Studio 2008 (and probably 2010) only provides Add-In project templates for C#, VB.NET and C++.

So, how to create a F# based Add-In?

I have tried to create a F# class library project with a new class implementing IDTExtensibility2, setting the correct references (EnvDTE, Extensibility, ...), copying a few project attributes from the C# Add-In (mainly the command line for debugging), and creating the .AddIn manifest file by hand, but no success. When VS is launched, my Add-In is not listed in the available ones.

What are the missing steps? Some kind of COM registration somewhere?


回答1:


I've not tried this exact scenario, but the general strategy I've had the best luck with is: start with the C# template, rename the .csproj to .fsproj and change the <Import>s for F# and replace the <Compile> of C# code with F# code, and go from there.

The templates often have various important logic in them for build/deployment, so start with a working template for C# and tweak it for F#.




回答2:


I finally found what went wrong: I simply forgot to put the .AddIn file in the AddIn directory (the C# wizard is doing this automatically).

So, to create a F# based Add-In for Visual Studio:

  • Create a new F# class library project
  • Add a few reference assemblies to the project (mainly EnvDTE, EnvDTE80, EnvDTE90, Extensibility)
  • Create a new class implementing IDTExtensibility2
  • Copy the debugging properties of a C# based Add-In project into your F# project
  • Copy the .AddIn manifest file, and modify it according to your F# project *.. and don't forget to copy that new file in the AddIn directory for the user session
  • enjoy!


来源:https://stackoverflow.com/questions/3399637/how-to-create-a-f-based-visual-studio-add-in

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!