visual studio - I'm trying to get my Nuget packages from Team Services but i get an error -
unable load service index source -my source-. key not valid use in specified state.
error package manager console:
install-package : nuget packages missing solution. packages need restored in order build dependency graph. restore packages before performing operations. @ line:1 char:1 + install-package owasp.esapi -source source ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidoperation: (:) [install-package], invalidoperationexception + fullyqualifiederrorid : nugetmissingpackages,nuget.packagemanagement.powershellcmdlets.installpackagecommand
steps add vsts package feed , install package
producing nuget packages
the process quite simple. first need package feed send nuget package to. create clicking package link inside project , click "new feed", giving name "default" (we unlikely create more 1 in each project). leave options , choose create.
this creates feed url looks this: https://example.pkgs.visualstudio.com/_packaging/example/nuget/v3/index.json copy , add 2 nuget build steps ci build:
notice different steps. 1 packager, other publisher. publish multiple times need package once.
in settings packager, set automatic package versioning "use build number" otherwise not overwrite older versions.
in settings publisher, set "feed type" "internal nuget feed" , paste feed url url box.
under general tab, set build number format $(builddefinitionname)_$(year:yyyy).$(month).$(dayofmonth)$(rev:.r)
click save , queue build ensure has worked correctly.
go package tab , ensure feed has package displayed. click "connect feed" near top show dialog , click personal access tokens:
note warning. cannot re-show password record somewhere ideally keepass. copy entire string including nuget bit @ start. need after setting nuget in dependent project.
this completes creation side of nuget package, can consumed other projects.
consuming pixelpin nuget packages
now have project producing nuget package , library needs consume it, need few things. need modify local nuget config build project in visual studio need configure nuget run correctly on vsts won't using local feeds file.
local setup right-click project , choose manage nuget packages, should use vs 2015. when page comes up, click cog on right-hand side bring feed settings. under package sources, if don't have it, add new source suitable name , paste in url used earlier creating package. when click ok, ask enter credentials. use username (usually "support") , password got earlier. should allow browse feed , select library want.
selecting library want should install per normal nuget package , local project should build (assuming don't have other errors of course).
setup vsts vsts online not see or use nuget configuration, need add files, set them , configure vsts build use them.
1) create nuget.config file in root of solution, can copy 1 project. 2) copy nuget.exe project , put in root. reference both of these files in solution can add them source control. 3) run command prompt, change directory root of solution , run command copied earlier connect feed dialog. this: nuget sources add -name feedname -source https://example.pkgs.visualstudio.com/_packaging/test/nuget/v3/index.json -username support -password 324oui25b3bi1235ob -configfile .\nuget.config 4) note last bit points solution copy of nuget.config rather default local machine copy. if works ok, open config file check have entry under packagesources name specified , entry packagesourcecredentials username , encrypted password. 5) if somehow wrong, can delete credentials , package source manually , run command again careful not remove other entries there. can use nuget sources update instead of add, should update there. 6) once have done this, check in nuget.config , nuget.exe copied vsts project. if check in, next ci build fail don't worry. 7) edit build again , click on nuget restore step. edit "path nuget.config" , navigate nuget.config uploaded. (you won't use nuget.exe on vsts it's there in case need use locally again).
queue build , make sure package restore step works ok , dependent package pulled in part of normal build!
Comments
Post a Comment