The official language extension sample for Visual Studio 2010 was the Iron Python Integration sample.
You can download it from here: IronPython Integration. There is a related documentation here: Visual Studio IronPython Integration Deep Dive
Unfortunately this sample was not updated for Visual Studio 2012 to my knowledge. However here are the steps to convert it to Visual Studio 2012.
- install the Visual Studio 2012 SDK from here: Microsoft Visual Studio 2012 SDK
- download the Iron Python integration sample, extract somewhere on your disk
- open
IronPython.sln
, and accept all upgrade conversions
- change the projects' platform target from
AnyCpu
to x86
- some projects have incorrect (auto hinted) references to Visual Studio 11 assemblies (built against .NET 4.5), so they won't compile as is. Change them back to Visual Studio 10 assemblies. Example, Microsoft.VisualStudio.ExtensibilityHosting.dll in the IronPython.Console projet needs to point to the equivalent file in
C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEPrivateAssemblies
.
- define the
IronPython.Project
project as the start up project, and update it's Debug parameters: the start action needs to start the C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDEdevenv.exe
(VS 2012 shell) external program instead of the C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEdevenv.exe
(VS 2010 shell) one that was set by default. Command line arguments should be set to /RootSuffix Exp
- update all base templates to use VS 2012 directories instead of only VS 2010 ones: search for the
IronPython.targets
string in all .pyproj file and add the VS 2012 case, like this:
before:
<PropertyGroup>
<!-- Set the IronPythonPath property by proving in different locations where Iron Python could be installed -->
<!-- Regular LocalAppData -->
<IronPythonPath Condition=" '$(IronPythonPath)' == '' AND Exists('$(LocalAppData)MicrosoftVisualStudio10.0ExtensionsMicrosoftIronPython1.0IronPython.targets')">$(LocalAppData)MicrosoftVisualStudio10.0ExtensionsMicrosoftIronPython1.0</IronPythonPath>
<!-- Experimental LocalAppData -->
<IronPythonPath Condition=" '$(IronPythonPath)' == '' AND Exists('$(LocalAppData)MicrosoftVisualStudio10.0ExpExtensionsMicrosoftIronPython1.0IronPython.targets')">$(LocalAppData)MicrosoftVisualStudio10.0ExpExtensionsMicrosoftIronPython1.0</IronPythonPath>
<!-- Integrated Shell -->
<IronPythonPath Condition=" '$(IronPythonPath)' == '' AND Exists('$(MSBuildExtensionsPath)MicrosoftIronPython Studio 20101.0IronPython.targets')">$(MSBuildExtensionsPath)MicrosoftIronPython Studio 20101.0</IronPythonPath>
</PropertyGroup>
after:
<PropertyGroup>
<!-- Set the IronPythonPath property by proving in different locations where Iron Python could be installed -->
<!-- Regular LocalAppData -->
<IronPythonPath Condition=" '$(IronPythonPath)' == '' AND Exists('$(LocalAppData)MicrosoftVisualStudio10.0ExtensionsMicrosoftIronPython1.0IronPython.targets')">$(LocalAppData)MicrosoftVisualStudio10.0ExtensionsMicrosoftIronPython1.0</IronPythonPath>
<!-- Experimental LocalAppData -->
<IronPythonPath Condition=" '$(IronPythonPath)' == '' AND Exists('$(LocalAppData)MicrosoftVisualStudio10.0ExpExtensionsMicrosoftIronPython1.0IronPython.targets')">$(LocalAppData)MicrosoftVisualStudio10.0ExpExtensionsMicrosoftIronPython1.0</IronPythonPath>
<!-- Regular LocalAppData VS10212 -->
<IronPythonPath Condition=" '$(IronPythonPath)' == '' AND Exists('$(LocalAppData)MicrosoftVisualStudio11.0ExtensionsMicrosoftIronPython1.0IronPython.targets')">$(LocalAppData)MicrosoftVisualStudio11.0ExtensionsMicrosoftIronPython1.0</IronPythonPath>
<!-- Experimental LocalAppData VS2012-->
<IronPythonPath Condition=" '$(IronPythonPath)' == '' AND Exists('$(LocalAppData)MicrosoftVisualStudio11.0ExpExtensionsMicrosoftIronPython1.0IronPython.targets')">$(LocalAppData)MicrosoftVisualStudio11.0ExpExtensionsMicrosoftIronPython1.0</IronPythonPath>
<!-- Integrated Shell -->
<IronPythonPath Condition=" '$(IronPythonPath)' == '' AND Exists('$(MSBuildExtensionsPath)MicrosoftIronPython Studio 20101.0IronPython.targets')">$(MSBuildExtensionsPath)MicrosoftIronPython Studio 20101.0</IronPythonPath>
</PropertyGroup>
That's it. Compile and run (both can take a while the first time due to registration mysteries).
Here is the result when starting a new Iron Python project from Visual Studio 2012:
and when building:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…