PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Docs.Site/Docs/Walkthrough/Getting-Started-with-NuGet.markdown

https://gitlab.com/yenny.prathivi/MyGetDocs
Markdown | 126 lines | 73 code | 53 blank | 0 comment | 0 complexity | 75302381269c656eb08f9c9b7204106b MD5 | raw file
  1. # Walkthrough - Getting Started Creating Your Own NuGet Feed
  2. Setting up your own NuGet repository has never been easier. MyGet allows you to create your own public or private NuGet feeds in just a few clicks. This section will guide you through it.
  3. ## Creating a new MyGet feed
  4. 1. **Browse to [MyGet.org][1] and log in** using your preferred identity provider. We currently support Microsoft Account, Google, GitHub, Facebook, StackExchange and OpenID.
  5. ![Use an existing identity or create a MyGet account from scratch.](Images/authenticate.png)
  6. 2. **Complete your new MyGet profile** by providing a username and password. These are your *MyGet credentials*, which you'll need to authenticate against private feeds on MyGet.org. From now on, you can also use these to log in on the MyGet.org web site.
  7. 3. **Create a new feed** and select the desired security template: *public, private or community*
  8. * public: everyone has read access, only feed owners/managers can write
  9. * private: only users with explicitly granted permissions can read or write (depending on permissions)
  10. * community: everyone can read all packages + anyone can manage the packages they pushed to the feed
  11. ## Setting up collaboration
  12. 1. **Invite collaborators** through the *[feed security][2]* settings.
  13. 2. **Register the feed** in your NuGet client: add the package source in Visual Studio, or store it in your NuGet.config for instance.
  14. You can register a MyGet feed the same way you register any NuGet package source by using the _Package Manager Settings_ dialog.
  15. You can find it under _Tools > Library Package Manager > Package Manager Settings_ in the Visual Studio menu.
  16. ![Register MyGet Feed](Images/faq_register_myget_feed.png)
  17. To store your MyGet feed credentials in your account's roaming profile, you can use the latest NuGet Commandline tool (<a href="https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" title="Click here to download the latest NuGet commandline tool">NuGet.exe</a>).
  18. Execute the following script using your MyGet [feedUrl] and MyGet [username] , [password] and [apikey].
  19. Run this from a commandline where you have access to nuget.exe (or set the path to your nuget.exe in a system environment variable).
  20. a. **Option A: Store credentials in machine-level nuget.config (non-transferable)**
  21. Register credentials for new package source:
  22. nuget setapikey [apikey] -source [url]
  23. nuget sources add -name [name] -source [url] -user [username] -pass [pwd]
  24. or update an already registered package source:
  25. nuget setapikey [apikey] -source [url]
  26. nuget sources update -name [name] -source [url] -user [username] -pass [pwd]
  27. b. **Option B: Store credentials in specific nuget.config (non-transferable)**
  28. Register credentials for new package source:
  29. nuget setapikey [apikey] -source [url] -configFile [configFilePath]
  30. nuget sources add -name [name] -source [url] -user [username] -pass [pwd] -configFile [path]
  31. or update an already registered package source:
  32. nuget setapikey [apikey] -source [url] -configFile [configFilePath]
  33. nuget sources update -name [name] -source [url] -user [username] -pass [pwd] -configFile [path]
  34. c. **Option C: Store credentials in specific nuget.config (transferable)**
  35. Don't bother putting the above nuget.config files into source control as they'll only work on the machine and the account that created the configs.
  36. To be able to share credentials, use the -StorePasswordInClearText option.
  37. Register credentials for new package source:
  38. nuget setapikey [apikey] -source [url] -configFile [configFilePath]
  39. nuget sources add -name [name] -source [url] -user [username] -pass [pwd] -configFile [path] -StorePasswordInClearText
  40. or update an already registered package source:
  41. nuget setapikey [apikey] -source [url] -configFile [configFilePath]
  42. nuget sources update -name [name] -source [url] -user [username] -pass [pwd] -configFile [path] -StorePasswordInClearText
  43. Also check out our blog post dedicated to this topic: <a href="http://blog.myget.org/post/2012/12/12/NuGet-package-restore-from-a-secured-feed.aspx" target="_blank">NuGet package restore from a secured feed</a>.
  44. 3. **Add packages** to the feed by either uploading them through the web site, referencing/mirroring them from nuget.org, or pushing them using your preferred NuGet client tools.
  45. ## Configure a build source
  46. MyGet supports many ways of integrating with hosted VCS or CI infrastructure, including built-in support for Visual Studio Online, GitHub and BitBucket, as well as any other hosted Git repository. For a full reference of MyGet Build Services, please take a look [here][3].
  47. For the purpose of demonstration, this walkthrough will guide you through setting up a GitHub build source and link it to your MyGet feed. We have a sample GitHub repository that shows you how to make use of MyGet's smart conventions specifically designed to easily produce NuGet packages and serve them to your package consumers.
  48. You'll notice we don't like you to be bound to a specific, single CI tool, so we explicitly try to stay clear of any MyGet-specific conventions or infrastructure.
  49. The **sample repository** can be found on [GitHub][4].
  50. If you don't want to hook up MyGet Build Services with your version control system, you can easily skip this section and continue reading the next one.
  51. The easiest way to add our samples repository to your feed as a build source is by [forking the GitHub repository][5], and simply select **Add Build Source > from GitHub**.
  52. ![Adding a MyGet build source](Images/build-svc-add.png)
  53. ![Add your GitHub fork as a MyGet build source](Images/build-svc-addFromGitHub.png)
  54. Alternatively, you can manually link the samples repository to your feed by copying the Git endpoint URL in the dialog presented by MyGet when you select **Add Build Source > Manually add build source...**
  55. ![Manually register a Git repository as a MyGet build source](Images/build-svc-addManually.png)
  56. ## Building sources and producing NuGet packages
  57. Once the build source is configured, you can manually hit the **Build** button for this build source. The build agent will follow [these conventions][6] and automatically detect anything that should be packaged and push them to your feed. We also allow you to override some conventions, or even [completely take over the build process and customize it][7] to your needs.
  58. Our sample repository only makes use of the tokenized NuGet manifest files that accompany the project files, which Just Works&trade;.
  59. Now, try pushing some changes to your fork and watch what happens with your build source in just an instance.
  60. ![A build got queued](Images/build-queued.png)
  61. ![Building...](Images/build-building.png)
  62. ![Successful!](Images/build-success.png)
  63. When creating the build source, we **automatically configured a service hook on GitHub** to trigger a build on your MyGet build source.
  64. ![GitHub service hook to trigger a MyGet build source](Images/mygetdocs-github-deployhook.png)
  65. You also want that shiny build status badge in your readme file? Or anywhere else? Simply copy-paste the HTML or Markdown by clicking the links in your build source details.
  66. ![A readme file containing the MyGet build status badge](Images/build-badge.png)
  67. [1]: http://www.myget.org
  68. [2]: http://docs.myget.org/docs/reference/feed-security
  69. [3]: http://docs.myget.org/docs/reference/build-services
  70. [4]: https://github.com/myget/MyGetDocs-Samples
  71. [5]: https://github.com/myget/MyGetDocs-Samples/fork
  72. [6]: http://docs.myget.org/docs/reference/build-services#The_Build_Process
  73. [7]: http://docs.myget.org/docs/reference/custom-build-scripts