You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

installing.md 4.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. ---
  2. title: Installing Discord.Net
  3. ---
  4. Discord.Net is distributed through the NuGet package manager, and it is
  5. recommended to use NuGet to get started.
  6. Optionally, you may compile from source and install yourself.
  7. # Supported Platforms
  8. Currently, Discord.Net targets [.NET Standard] 1.3, and offers support for
  9. .NET Standard 1.1. If your application will be targeting .NET Standard 1.1,
  10. please see the [additional steps](#installing-on-net-standard-11).
  11. Since Discord.Net is built on the .NET Standard, it is also recommended to
  12. create applications using [.NET Core], though you are not required to. When
  13. using .NET Framework, it is suggested to target `.NET 4.6.1` or higher.
  14. [.NET Standard]: https://docs.microsoft.com/en-us/dotnet/articles/standard/library
  15. [.NET Core]: https://docs.microsoft.com/en-us/dotnet/articles/core/
  16. # Installing with NuGet
  17. Release builds of Discord.Net 1.0 will be published to the
  18. [official NuGet feed].
  19. Development builds of Discord.Net 1.0, as well as [addons](TODO) are published
  20. to our development [MyGet feed].
  21. Direct feed link: `https://www.myget.org/F/discord-net/api/v3/index.json`
  22. Not sure how to add a direct feed? See how [with Visual Studio]
  23. or [without Visual Studio](#configuring-nuget-without-visual-studio)
  24. [official NuGet feed]: https://nuget.org
  25. [MyGet feed]: https://www.myget.org/feed/Packages/discord-net
  26. [with Visual Studio]: https://docs.microsoft.com/en-us/nuget/tools/package-manager-ui#package-sources
  27. ## Using Visual Studio
  28. 1. Create a solution for your bot
  29. 2. In Solution Explorer, find the 'Dependencies' element under your bot's
  30. project
  31. 3. Right click on 'Dependencies', and select 'Manage NuGet packages'
  32. ![Step 3](images/install-vs-deps.png)
  33. 4. In the 'browse' tab, search for 'Discord.Net'
  34. > [!TIP]
  35. Don't forget to change your package source if you're installing from the
  36. developer feed.
  37. Also make sure to check 'Enable Prereleases' if installing a dev build!
  38. 5. Install the 'Discord.Net' package
  39. ![Step 5](images/install-vs-nuget.png)
  40. ## Using JetBrains Rider
  41. 1. Create a new solution for your bot
  42. 2. Open the NuGet window (Tools > NuGet > Manage NuGet packages for Solution)
  43. ![Step 2](images/install-rider-nuget-manager.png)
  44. 3. In the 'Packages' tab, search for 'Discord.Net'
  45. ![Step 3](images/install-rider-search.png)
  46. > [!TIP]
  47. Make sure to check the 'Prerelease' box if installing a dev build!
  48. 4. Install by adding the package to your project
  49. ![Step 4](images/install-rider-add.png)
  50. ## Using Visual Studio Code
  51. 1. Create a new project for your bot
  52. 2. Add Discord.Net to your .csproj
  53. [!code-xml[Sample .csproj](samples/project.csproj)]
  54. > [!TIP]
  55. Don't forget to add the package source to a [NuGet.Config file](#configuring-nuget-without-visual-studio) if you're installing from the
  56. developer feed.
  57. # Compiling from Source
  58. In order to compile Discord.Net, you require the following:
  59. ### Using Visual Studio
  60. - [Visual Studio 2017](https://www.visualstudio.com/)
  61. - [.NET Core SDK 1.0](https://www.microsoft.com/net/download/core#/sdk)
  62. The .NET Core and Docker (Preview) workload is required during Visual Studio
  63. installation.
  64. ### Using Command Line
  65. - [.NET Core SDK 1.0](https://www.microsoft.com/net/download/core#/sdk)
  66. # Additional Information
  67. ## Installing on .NET Standard 1.1
  68. For applications targeting a runtime corresponding with .NET Standard 1.1 or 1.2,
  69. the builtin WebSocket and UDP provider will not work. For applications which
  70. utilize a WebSocket connection to Discord (WebSocket or RPC), third-party
  71. provider packages will need to be installed and configured.
  72. First, install the following packages through NuGet, or compile yourself, if
  73. you prefer:
  74. - Discord.Net.Providers.WS4Net
  75. - Discord.Net.Providers.UDPClient
  76. Note that `Discord.Net.Providers.UDPClient` is _only_ required if your bot will
  77. be utilizing voice chat.
  78. Next, you will need to configure your [DiscordSocketClient] to use these custom
  79. providers over the default ones.
  80. To do this, set the `WebSocketProvider` and optionally `UdpSocketProvider`
  81. properties on the [DiscordSocketConfig] that you are passing into your
  82. client.
  83. [!code-csharp[NET Standard 1.1 Example](samples/netstd11.cs)]
  84. [DiscordSocketClient]: xref:Discord.WebSocket.DiscordSocketClient
  85. [DiscordSocketConfig]: xref:Discord.WebSocket.DiscordSocketConfig
  86. ## Configuring NuGet without Visual Studio
  87. If you plan on deploying your bot or developing outside of Visual Studio, you
  88. will need to create a local NuGet configuration file for your project.
  89. To do this, create a file named `nuget.config` alongside the root of your
  90. application, where the project solution is located.
  91. Paste the following snippets into this configuration file, adding any additional
  92. feeds as necessary.
  93. [!code-xml[NuGet Configuration](samples/nuget.config)]