A bit more on IronPython
[Update 04.02.2007: Added note about running under the debugger]
[Update 03.14.2007: Updated content for Visual Studio 2005 SDK Version 4.0]
[Update 01.23.2007: Added note about needing VC++]
[Update 09.15.2006: Updated content for Visual Studio 2005 SDK Version 3.0]
[Update 07.26.2006: Soma linked to my blog :). Because of this, I've made some minor edits to bring this post a bit more up to date.]
Since there have been several mentions of this blog on the IronPython discussion alias, I thought I should mention some more about the IronPython sample in the latest release of the Visual Studio SDK.
How do I get IronPython Integration in Visual Studio 2005?
First, you'll need to go download the latest release of the Visual Studio SDK (Version 4.0). Note that the IronPythonIntegration sample will only work with Visual Studio 2005 (and higher). It is not possible to get it to work with .Net 1.1 and Visual Studio 2003.
What version of Visual Studio do I need? Can I use this with an Express edition?
Unfortunately, no. The Visual Studio Express editions do not support extensibility (addins & packages). This is a limitation of the Express products and not a limitation we are placing on the sample. You will need Visual Studio Standard or higher to build and use the sample.
Also, you will need to have Visual C++ installed in order to compile the sample. This is a current prerequisite for building any Visual Studio integration project since the C++ preprocessor is used to compile the CTC files in the sample. (CTC is the format that is used to statically describe the menu structure that a package provides in Visual Studio.)
OK, I've got this thing downloaded...now how do I get IronPython working inside Visual Studio?!?
Open Visual Studio 2005 and (assuming you installed the SDK to the default location) open the solution at "C:\Program Files\Visual Studio 2005 SDK\2007.02\VisualStudioIntegration\Samples\IronPythonIntegration". Then, it should simply be a matter of hitting CTRL+F5 for Build & Run. This will launch Visual Studio using the "Experimental hive". (Alternatively, you could run "devenv /rootsuffix Exp" or use the shortcut that is placed under VS SDK in the Start Menu.)
Note that if you run the sample via F5 (under the debugger), you may see some exceptions and MDA (managed debugging assistant) errors. These can be safely ignored.
I think I have it built and running...now what?
You can create a new IronPython project just like you would a C#/VB/J#/C++ project, from the new project command. My suggestion would be to create a console application and play around with that for a while. If you open any file with a .py extension, you'll notice that Visual Studio will do syntax coloring for you.
One other cool little item this sample includes is a tool window (like Output Window, Solution Explorer, etc...) called the IronPython Console Window. You can launch this from View-Other Windows.
Another thing to note with the console window is a variable defined in it called "dte". This is a pointer to the same DTE object that is used to automate Visual Studio via the Macros IDE. Translation: you can write mini-macros for VS with IronPython instead of Visual Basic. :-)
How does this compiler thing work anyway? I haven't been able to 'compile' IronPython binaries before...
Over the past few months, the IronPython team added some compiler interfaces to IronPython.dll which the IP project system uses to compile when you select "Build". One thing to realize about how the compiler works is that the binaries produced have a heavy dependency on the IronPython runtime (IronPython.dll). After all, it is a dynamic language. When you execute your IronPython binary, each statement is being evaluated and type-checked as you execute it.
What this means for you is that the MSIL in the binaries produced will not look like a standard .NET library you build in C#/VB. In fact, you probably won't be able to consume it from another project.
What other features are there?
This sample is primarly meant as a sample to demonstrate integrating a language into Visual Studio 2005. As such, some of the features may be incomplete or unstable. Nevertheless, the sample has limited support for the following features:
- Windows Forms Designer
- WebSite Projects (e.g. "New Website")
- Web Application Projects
- Intellisense (Both as inline in a aspx page and in normal code files)
- Demonstrates use of MPF features
I have multiple modules (.py files) that need to interact with each other. How does that work?
Simple. In your project, just import the module like you would if you had a bunch of .py files on disk together in the same folder. For example, if I have program.py as my main file and I need to import myModule.py, I would put the following statement in program.py:
Which version of IronPython is included in this sample?
The Visual Studio 2005 SDK Version 4.0 uses a pre-beta version of IronPython 1.1.
Is there any way to get IronPython running in Visual Studio without downloading the Visual Studio 2005 SDK?
At the present, the only method we are using for shipping the IronPython/VS integration is as a sample in the VSSDK.
However, the IronPython team has released an IronPython for ASP.NET CTP which includes a subset of the functionality included in this sample. Note that the IronPython for ASP.NET CTP is shipped in binary form only, and it does not require the Visual Studio SDK.
OK, I think I found a bug...
Please send us feedback with any problems/questions/suggestions you may have!