Difference between revisions of "Setting up Visual Studio"

From Kerbal Space Program Wiki
Jump to: navigation, search
(Prerequisites)
m
 
(24 intermediate revisions by 13 users not shown)
Line 1: Line 1:
Microsoft Visual Studio is a program (more specifically IDE, for Integrated Development Environment) for that makes it easier to code applications for Windows. For KSP, it is used for developing part modules via the C# IDE, although any app that can compile C# is sufficient.
+
Microsoft Visual Studio is a program (more specifically IDE, or Integrated Development Environment) that makes it easier to code applications for Windows. For KSP, it is used for developing plugins (parts, part modules, mono behaviours or scenario modules) via the C# IDE, although any program that can compile C# is sufficient.
  
 
== Prerequisites ==
 
== Prerequisites ==
Line 6: Line 6:
  
 
* Microsoft Windows XP or above
 
* Microsoft Windows XP or above
* Microsoft .NET Framework 3.5 or above
+
* Microsoft .NET Framework 4.0 or above (4.5 is recommended)
* [http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express Microsoft Visual C# Express 2010]
+
** Before KSP 1.8, Microsoft .NET Framework 3.5
** You can also use Visual Studio 2010, which is functionally similar.
+
* For Windows 7 or 8 [http://www.visualstudio.com/en-us/products/visual-studio-community-vs Visual Studio Community 2017] or for Windows XP [http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express Microsoft Visual C# Express 2010]
* Kerbal Space Program 0.14 X1 or above.
+
** You can use any version of Visual Studio from VS2012 (2010 for XP) onwards, which are functionally similar.
 +
* Latest version of Kerbal Space Program.
  
 
== Setting Up ==
 
== Setting Up ==
  
 
# Close any solutions you currently have open by choosing '''File > Close Solution'''.
 
# Close any solutions you currently have open by choosing '''File > Close Solution'''.
# Start a new solution either by selecting New Project from the Home screen, or by using '''File > New... > Project...'''
+
# Start a new solution either by selecting '''New Project''' from the Home screen, or by using '''File > New > Project...'''
# Create a new Class Library project for C#.  Name it whatever you like. (We're using MyKSPProject for this tutorial, so replace MyKSPProject with whatever you're using.) [[Image:VS2010-NewClassLib.jpg|thumb|right|Setting up the class library project]]
+
# Create a new Class Library project for C#: In the "New Project" dialog, on the left choose '''Installed > Templates > Visual C# > Windows'''.  In the middle, choose '''Class Library.''' At the top, if your version of Visual Studio has a dropdown for .NET version, choose '''.NET Framework 4.5''' ('''.NET Framework 3.5''' for KSP versions prior to 1.8).
# In your Solution Explorer (the pane on the top right of the screen), right-click on MyKSPProject and choose Add Reference.[[Image:VS2010-AddRef.jpg|thumb|right|Adding references]]
+
# Name it whatever you like. (We're using MyKSPProject for this tutorial, so replace MyKSPProject with whatever you're using.) [[File:VS2012-NewClassLib.png|thumb|right|Setting up the class library project]] Click '''Ok''' in the New Project dialog.
 +
# In your Solution Explorer (the pane on the top right of the screen), right-click on MyKSPProject (not "Solution 'MyKSPProject' (1 project)") and choose Add Reference.[[File:VS2012-AddRef.png|thumb|right|Adding references]]
 
# Switch to the Browse tab.
 
# Switch to the Browse tab.
# Find and add the following DLLs as references:
+
# Click on the "Browse..." button.
 +
# Go to your KSP_Data\Managed folder and add the following DLLs as references:
 
#* KSP_INSTALL_FOLDER\KSP_Data\Managed\Assembly-CSharp.dll
 
#* KSP_INSTALL_FOLDER\KSP_Data\Managed\Assembly-CSharp.dll
 
#* KSP_INSTALL_FOLDER\KSP_Data\Managed\UnityEngine.dll
 
#* KSP_INSTALL_FOLDER\KSP_Data\Managed\UnityEngine.dll
 +
#* KSP_INSTALL_FOLDER\KSP_Data\Managed\UnityEngine.CoreModule.dll (As of 1.8+)
 +
# Save your solution.
 +
# If you didn't set the .NET Framework earlier, in your Solution Explorer (the pane on the top right of the screen), right-click on MyKSPProject and choose Properties. Change the Target Framework to 4.5 (Visual Studio will default to a newer framework version). Visual Studio will reload the project after you click ok.
  
  
Great, you're all set!  Now continue to [[creating your first module]]!
+
Great, you're all set!  Now continue to [[Tutorial:Creating your first module|creating your first module]]!
  
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]
 
[[Category:Plugin SDK Tutorials]]
 
[[Category:Plugin SDK Tutorials]]

Latest revision as of 03:40, 19 December 2019

Microsoft Visual Studio is a program (more specifically IDE, or Integrated Development Environment) that makes it easier to code applications for Windows. For KSP, it is used for developing plugins (parts, part modules, mono behaviours or scenario modules) via the C# IDE, although any program that can compile C# is sufficient.

Prerequisites

In order to complete this tutorial you must have the following. Plugins may be written in other environments.

  • Microsoft Windows XP or above
  • Microsoft .NET Framework 4.0 or above (4.5 is recommended)
    • Before KSP 1.8, Microsoft .NET Framework 3.5
  • For Windows 7 or 8 Visual Studio Community 2017 or for Windows XP Microsoft Visual C# Express 2010
    • You can use any version of Visual Studio from VS2012 (2010 for XP) onwards, which are functionally similar.
  • Latest version of Kerbal Space Program.

Setting Up

  1. Close any solutions you currently have open by choosing File > Close Solution.
  2. Start a new solution either by selecting New Project from the Home screen, or by using File > New > Project...
  3. Create a new Class Library project for C#: In the "New Project" dialog, on the left choose Installed > Templates > Visual C# > Windows. In the middle, choose Class Library. At the top, if your version of Visual Studio has a dropdown for .NET version, choose .NET Framework 4.5 (.NET Framework 3.5 for KSP versions prior to 1.8).
  4. Name it whatever you like. (We're using MyKSPProject for this tutorial, so replace MyKSPProject with whatever you're using.)
    Setting up the class library project
    Click Ok in the New Project dialog.
  5. In your Solution Explorer (the pane on the top right of the screen), right-click on MyKSPProject (not "Solution 'MyKSPProject' (1 project)") and choose Add Reference.
    Adding references
  6. Switch to the Browse tab.
  7. Click on the "Browse..." button.
  8. Go to your KSP_Data\Managed folder and add the following DLLs as references:
    • KSP_INSTALL_FOLDER\KSP_Data\Managed\Assembly-CSharp.dll
    • KSP_INSTALL_FOLDER\KSP_Data\Managed\UnityEngine.dll
    • KSP_INSTALL_FOLDER\KSP_Data\Managed\UnityEngine.CoreModule.dll (As of 1.8+)
  9. Save your solution.
  10. If you didn't set the .NET Framework earlier, in your Solution Explorer (the pane on the top right of the screen), right-click on MyKSPProject and choose Properties. Change the Target Framework to 4.5 (Visual Studio will default to a newer framework version). Visual Studio will reload the project after you click ok.


Great, you're all set! Now continue to creating your first module!