Changes

m
Added a note saying that this page is outdated, and that .NET 6.0 is the correct framework for the latest version.
Line 32: Line 32:  
# Filter by "C#" and "Library", then choose ''Class Library'' and click ''Next''. Make sure you '''don't''' choose ''Class Library (.NET Framework)'' which won't work.<br />[[File:Modding - IDE reference - create project (Visual Studio 2).png| 589px]]
 
# Filter by "C#" and "Library", then choose ''Class Library'' and click ''Next''. Make sure you '''don't''' choose ''Class Library (.NET Framework)'' which won't work.<br />[[File:Modding - IDE reference - create project (Visual Studio 2).png| 589px]]
 
# In the ''configure your new project'' window: <ol><li>Enter a descriptive mod name. By convention, the name should be one word with mixed caps (like "PineapplesEverywhere").</li><li>Make sure "Place solution and project in the same directory" is ''not'' checked.</li><li>Click "Create" to to create the project.</li></ol>[[File:Modding - IDE reference - create project (Visual Studio 3).png|800px]]
 
# In the ''configure your new project'' window: <ol><li>Enter a descriptive mod name. By convention, the name should be one word with mixed caps (like "PineapplesEverywhere").</li><li>Make sure "Place solution and project in the same directory" is ''not'' checked.</li><li>Click "Create" to to create the project.</li></ol>[[File:Modding - IDE reference - create project (Visual Studio 3).png|800px]]
# Next, select NET 5.0 and click "Create" to create the project. For VS 2022, this will be on the next page. <br/>[[File:Screenshot 2021-12-16 140835.png]]
+
# Next, select NET 6.0 and click "Create" to create the project. For VS 2022, this will be on the next page. <br />[[File:Screenshot 2021-12-16 140835.png]]
    
===Linux (MonoDevelop)===
 
===Linux (MonoDevelop)===
Line 47: Line 47:  
# Click ''File » New Solution'' from the menu bar:<br />[[File:VS Mac 1 newsolution.png|600px]]
 
# Click ''File » New Solution'' from the menu bar:<br />[[File:VS Mac 1 newsolution.png|600px]]
 
# Select the correct type of class library:<br />[[File:VS Mac 2 createlibrary.png|600px]]
 
# Select the correct type of class library:<br />[[File:VS Mac 2 createlibrary.png|600px]]
# Set it to target <b>.NET 5.0.</b>:<br />[[File:VS Mac 3 setframework.png|600px]]
+
# Set it to target '''.NET 5.0.''':<br />[[File:VS Mac 3 setframework.png|600px]]
 
# Enter a descriptive mod name for the project. By convention, the name should be one word with mixed caps (like "PineapplesEverywhere"):<br />[[File:VS Mac 4 nameproject.png|600px]]
 
# Enter a descriptive mod name for the project. By convention, the name should be one word with mixed caps (like "PineapplesEverywhere"):<br />[[File:VS Mac 4 nameproject.png|600px]]
   Line 59: Line 59:  
==Set the target framework==
 
==Set the target framework==
 
<span id="set-target-framework"></span>
 
<span id="set-target-framework"></span>
The 'target framework' is the version of .NET your code uses, which affects the version needed to run your mod. The recommended target framework is .NET 5.0, which is the version SMAPI itself targets.
+
The 'target framework' is the version of .NET your code uses, which affects the version needed to run your mod. The recommended target framework is .NET 5.0, which is the version SMAPI itself targets. '''Please find the subsection below for your OS''' (Windows/Mac). '''You cannot use .NET 6.0'''.
   −
===In Visual Studio 2019/2022===
+
(yes, we know .NET 5.0 is past EOL.)
 +
 
 +
* '''''.NET 6.0 is actually the correct framework here, this page is just outdated.'''''
 +
 
 +
===In Windows Visual Studio 2019/2022===
 
'''NOTE: Visual Studio 2017 MAY no longer be compatible with creating mods!''' If you followed [[Modding:Modder_Guide/Get_Started]] and receive errors, from the code that page instructed be copy and pasted, with regards to helper. Events in the Entry(IModhelper helper) method and ButtonPressedEventArgs from the Entry(IModHelper helper) method, try the project-creation and code-copy/paste process again with Visual Studio 2019/2022 instead.
 
'''NOTE: Visual Studio 2017 MAY no longer be compatible with creating mods!''' If you followed [[Modding:Modder_Guide/Get_Started]] and receive errors, from the code that page instructed be copy and pasted, with regards to helper. Events in the Entry(IModhelper helper) method and ButtonPressedEventArgs from the Entry(IModHelper helper) method, try the project-creation and code-copy/paste process again with Visual Studio 2019/2022 instead.
   Line 69: Line 73:  
# On the ''Application'' tab, change the ''Target Framework'' dropdown to ''.NET 5.0'':<br />[[File:Modding - IDE reference - change target framework (Visual Studio 2).png|800px]]
 
# On the ''Application'' tab, change the ''Target Framework'' dropdown to ''.NET 5.0'':<br />[[File:Modding - IDE reference - change target framework (Visual Studio 2).png|800px]]
 
# A dialogue may appear asking you to confirm the change. Click 'Yes' to confirm:<br />[[File:Modding - IDE reference - change target framework (Visual Studio 3).png]]
 
# A dialogue may appear asking you to confirm the change. Click 'Yes' to confirm:<br />[[File:Modding - IDE reference - change target framework (Visual Studio 3).png]]
 +
 +
===In Visual Studio 2019 for Mac===
 +
 +
If you followed the instructions above to set up your project, your framework should already be set to .NET 5.0. However, if you picked the wrong class library or you just want to check, you can follow these steps to look at the .csproj file, which is basically equivalent to setting it manually. (If you're checking that it worked, don't replace the .csproj, just check it refers to .NET 5.0.)
 +
 +
Unfortunately there doesn't appear to be a way to change the target framework using the GUI. However, it is very easy to follow the 1.5.5 migration guide steps:
 +
# Open the .csproj file for editing:<br />[[File:VS Mac 7 editcsproj.png|600px]]
 +
# Replace your mod's <samp>.csproj</samp> file with this (where <code>EXAMLE_MOD_NAME</code> is your solution's name):
 +
<syntaxhighlight lang="xml">
 +
<Project Sdk="Microsoft.NET.Sdk">
 +
  <PropertyGroup>
 +
    <AssemblyName>EXAMPLE_MOD_NAME</AssemblyName>
 +
    <RootNamespace>EXAMPLE_MOD_NAME</RootNamespace>
 +
    <Version>1.0.0</Version>
 +
    <TargetFramework>net5.0</TargetFramework>
 +
  </PropertyGroup>
 +
 +
  <ItemGroup>
 +
    <PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.0.0" />
 +
  </ItemGroup>
 +
</Project>
 +
</syntaxhighlight>
 +
 +
# If the mod uses [[Modding:Modder Guide/APIs/Harmony|Harmony]], add <code><nowiki><EnableHarmony>true</EnableHarmony></nowiki></code> to the property group.
    
===In MonoDevelop/Visual Studio for Mac===
 
===In MonoDevelop/Visual Studio for Mac===
<b><p style="color:darkred;">This section is out of date for Stardew Valley 1.5.5. It appears you cannot change the .NET framework in this way anymore with Visual Studio 2019 and Stardew Valley 1.5.5.</p><b/>
+
<p style="color:red;">'''This section is out of date for Stardew Valley 1.5.5. It appears you cannot change the .NET framework in this way with Visual Studio 2019 and Stardew Valley 1.5.5.'''</p>
    
# Open the Solution pad. If it's not visible, click ''View » Pads » Solution'' from the menu:<br />[[File:Modding - IDE reference - show solution pane (MonoDevelop).png]]
 
# Open the Solution pad. If it's not visible, click ''View » Pads » Solution'' from the menu:<br />[[File:Modding - IDE reference - show solution pane (MonoDevelop).png]]
Line 106: Line 134:  
<span id="add-nuget"></span>
 
<span id="add-nuget"></span>
   −
===In Visual Studio 2017===
+
===In Visual Studio 2019/2022===
 
# Click ''Tools » NuGet Package Manager » Manage NuGet Packages for Solution'' from the menu:<br />[[File:Modding - IDE reference - add NuGet package (Visual Studio 1).png]]
 
# Click ''Tools » NuGet Package Manager » Manage NuGet Packages for Solution'' from the menu:<br />[[File:Modding - IDE reference - add NuGet package (Visual Studio 1).png]]
 +
# Note: if the nuget package manager is missing, you can add it as a package source with the following steps: https://stackoverflow.com/questions/37293242/nuget-package-manager-no-packages-found-even-though-the-package-exists
 
# On the ''Browse'' tab, search for the package and click on the result to display some options:<br />[[File:Modding - IDE reference - add NuGet package (Visual Studio 2).png]]
 
# On the ''Browse'' tab, search for the package and click on the result to display some options:<br />[[File:Modding - IDE reference - add NuGet package (Visual Studio 2).png]]
 
# In the options, check the box next to your project and click ''Install'':<br />[[File:Modding - IDE reference - add NuGet package (Visual Studio 3).png]]
 
# In the options, check the box next to your project and click ''Install'':<br />[[File:Modding - IDE reference - add NuGet package (Visual Studio 3).png]]
Line 160: Line 189:  
# Find the DLL you want to reference, select it, and click ''Add'':<br />[[File:Modding - IDE reference - add reference (Visual Studio 3).png]]
 
# Find the DLL you want to reference, select it, and click ''Add'':<br />[[File:Modding - IDE reference - add reference (Visual Studio 3).png]]
 
# From the 'Reference Manager' window, click ''OK'':<br />[[File:Modding - IDE reference - add reference (Visual Studio 4).png]]
 
# From the 'Reference Manager' window, click ''OK'':<br />[[File:Modding - IDE reference - add reference (Visual Studio 4).png]]
 +
 +
===In Rider===
 +
When opening a project for the first time, you must add a reference to StardewModdingAPI.dll for code completion to work.
 +
# In the Explorer panel, select the ''Solution'' view
 +
# Under the project, right-click on ''Dependencies'' and choose ''Reference...''
 +
# In the Add Reference window, click ''Add From...'' at the bottom
 +
# Find the DLL you want to reference, select it, and click ''OK''
 +
    
[[Category:Modding]]
 
[[Category:Modding]]
    +
[[es:Modding:Referencia IDE]]
 
[[ru:Модификации:Настройка среды разработки]]
 
[[ru:Модификации:Настройка среды разработки]]
 
[[zh:模组:IDE 参考]]
 
[[zh:模组:IDE 参考]]