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.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. **todo**
  42. ## Using Visual Studio Code
  43. 1. Create a new project for your bot
  44. 2. Add Discord.Net to your .csproj
  45. [!code-xml[Sample .csproj](samples/project.csproj)]
  46. > [!TIP]
  47. Don't forget to add the package source to a [NuGet.Config file](#configuring-nuget-without-visual-studio) if you're installing from the
  48. developer feed.
  49. # Compiling from Source
  50. In order to compile Discord.Net, you require the following:
  51. ### Using Visual Studio
  52. - [Visual Studio 2017](https://www.visualstudio.com/)
  53. - [.NET Core SDK 1.0](https://www.microsoft.com/net/download/core#/sdk)
  54. The .NET Core and Docker (Preview) workload is required during Visual Studio
  55. installation.
  56. ### Using Command Line
  57. - [.NET Core SDK 1.0](https://www.microsoft.com/net/download/core#/sdk)
  58. # Additional Information
  59. ## Installing on .NET Standard 1.1
  60. For applications targeting a runtime corresponding with .NET Standard 1.1 or 1.2,
  61. the builtin WebSocket and UDP provider will not work. For applications which
  62. utilize a WebSocket connection to Discord (WebSocket or RPC), third-party
  63. provider packages will need to be installed and configured.
  64. First, install the following packages through NuGet, or compile yourself, if
  65. you prefer:
  66. - Discord.Net.Providers.WS4Net
  67. - Discord.Net.Providers.UDPClient
  68. Note that `Discord.Net.Providers.UDPClient` is _only_ required if your bot will
  69. be utilizing voice chat.
  70. Next, you will need to configure your [DiscordSocketClient] to use these custom
  71. providers over the default ones.
  72. To do this, set the `WebSocketProvider` and optionally `UdpSocketProvider`
  73. properties on the [DiscordSocketConfig] that you are passing into your
  74. client.
  75. [!code-csharp[NET Standard 1.1 Example](samples/netstd11.cs)]
  76. [DiscordSocketClient]: xref:Discord.WebSocket.DiscordSocketClient
  77. [DiscordSocketConfig]: xref:Discord.WebSocket.DiscordSocketConfig
  78. ## Configuring NuGet without Visual Studio
  79. If you plan on deploying your bot or developing outside of Visual Studio, you
  80. will need to create a local NuGet configuration file for your project.
  81. To do this, create a file named `nuget.config` alongside the root of your
  82. application, where the project solution is located.
  83. Paste the following snippets into this configuration file, adding any additional
  84. feeds as necessary.
  85. [!code-xml[NuGet Configuration](samples/nuget.config)]