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.9 kB

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