Not sure how to publish to (the official) nuget server?

Pure Krome's Avatar

Pure Krome

05 Jul, 2015 12:54 PM

Hi hi :)

I'm trying to package and publish a pretty simple nuspec file to the official NuGet servers.

I have a nuspec file created.

I've thought I've added the correct settings to my yml file:

build:
  publish_nuget: true

deploy:
  provider: NuGet
  api_key:
    secure: jfcUvHZhgnUboplqTBDWr8mG5PIlrgBv5TA2fhhop4ZSiDxskyy+RtYyeHoduJFR

and all I get is this...

=== TEST EXECUTION SUMMARY ===
   Tests.DLL  Total: 35, Errors: 0, Failed: 0, Skipped: 0, Time: 13.172s
Deploying using NuGet provider
No packages were pushed.
Updating build cache
All cache items are up to date.
Build success

1) Is there some trick with how it discovers my nuspec file?
2) what happens if i have multiple nuspec files (which I wish to push some or all?)

  1. Support Staff 1 Posted by Feodor Fitsner on 05 Jul, 2015 06:51 PM

    Feodor Fitsner's Avatar

    Automatic NuGet packaging works with VS projects only (.nuspec file should have the same name as .*proj file and be in the same directory).

    You should use your own command to build the package and push it to artifacts.

    Take a look at this project for example: https://github.com/appveyor/secure-file/blob/master/appveyor.yml

  2. 2 Posted by Pure Krome on 07 Jul, 2015 09:51 AM

    Pure Krome's Avatar

    AH! ok - that starts to make more sense.

    1. I couldn't find any documentation about Automatic NuGet packaging and the requirement that the .nuspec and proj file need to be the same. Does that exist? If not, want me to make an issue about it?

    2. That gist is great! Also - this should be in some doc's again .. if it's not, i can add it to the same issue (or make a new one, etc).

    top stuff Feodor!

  3. Support Staff 3 Posted by Feodor Fitsner on 07 Jul, 2015 05:20 PM

    Feodor Fitsner's Avatar

    There is a short mentioning of that: http://www.appveyor.com/docs/nuget#automatic-publishing-of-nuget-pr...

    Regarding the versioning approach based on AssemblyInfo - I'm going to blog about that.

  4. 4 Posted by Pure Krome on 08 Jul, 2015 12:30 AM

    Pure Krome's Avatar

    Ah - yeah .. I've read that before and totally misunderstood the explanation.

    For context:

    You can enable automatic publishing of NuGet packages during the build on the project settings Build tab. When it is enabled AppVeyor calls nuget pack for every project in the solution that has a .nuspec file in its root and then publishes NuGet package artifacts in both project and account feeds.

    I would probably suggest this be re-written. In fact, this entire page is really (IMO) confusing. When I first landed here, I was hoping to read up about how to publish to NuGet.org. But it starts out talking about a private nuget feed (waa??) and how to access it, etc. IMO, i think this entire page should be split into two parts => publishing to NuGet.org and publishing to private.

    Of course - publishing to a nuget feed is identical for either one - official or private ... so there might be double up code-examples in both docs .. but I really think there needs to be a split of the two. Also, some real-life examples for the private feed would be so helpful - why use it? how to use it in an example project, etc... I feel that this functionality is underrated because of lack of understanding (my gut feeling - you would have the stats, though).

    Anyways - as to the automatic publishing:

    AppVeyor can automatically pack and publish .nuspec files if the following conventions are followed:

    1. .nuspec files need to be in the root folder.
    2. Each .nuspec file has to have the same name as it's corresponding .csproj file.

    for example:

    \
    |- `MyAwesomeLibrary.nuspec`
    |- `MyAwesomeLibrary.csproj`
    

    If you have multiple .nuspec files you wish to publish or they are located/named differently, then you will have to manually pack them all and then manually copy them into the build-artifact's during the build process.

    Manual publishing of NuGet project Manual publishing is required when you cannot follow the conventions of Automatic NuGet publishing or you need some custom logic during the packaging process. The key to manual publishing is to (generally) follow two steps:

    1. pack all of your the .nuspec files you want to publish
    2. copy each .nupkg to the build processes Artifacts storage so the deployment stage can then get access to these files. example: ... example powershell code ...

    ... anyways, i think i've blabbed on enough here :blush:

  5. Support Staff 5 Posted by Feodor Fitsner on 08 Jul, 2015 12:50 AM

    Feodor Fitsner's Avatar

    Alright, I see what you mean. Thanks for pointing that out. Btw, did you know that anyone can contribute to docs: https://github.com/appveyor/website/blob/master/NJekyll/site/docs/n... :)

  6. 6 Posted by Pure Krome on 08 Jul, 2015 01:01 AM

    Pure Krome's Avatar

    ah kewl! (nope, i didn't know they were forkable)

  7. 7 Posted by Pure Krome on 14 Jul, 2015 07:19 AM

    Pure Krome's Avatar

    Heya Feodor,

    as suggested above - I'm trying to manually do my own packing of my nuspecs.

    I've been using a powershell script (locally) on all my OSS repo's that does this for me. It basically, looks for all nuspec's, pack's them, then optionally pushes em up to nuget if an api key was given.

    I'm trying to do this in a yml file with no luck.

    here's what i'm trying to do

    after_build:
      - ps: `NuGet Package Specifications\NuGet Deployment.ps1 -Version %appveyor_build_version% -NuGet NuGet`
      - appveyor PushArtifact **\*.nupkg"
    

    The ps script is failing. i'm not sure i'm calling it right.

    this is what i usually do if i'm in the correct folder, locally on my own dev machine:

    .\NuGet Deployment.ps1 -Version 1.2.3-alpha -NuGet c:\temp\NuGet.exe

    that will create a nupkg for every nuspec file it finds, in the current directory.

    Any suggestions?

    Here's the full file in some OSS repo i have.

  8. Support Staff 8 Posted by Feodor Fitsner on 14 Jul, 2015 02:55 PM

    Feodor Fitsner's Avatar

    I'd use this to push all nuget packages to artifacts:

    artifacts:
      - path: '**\*.nupkg'
    

    Not sure I understand this line:

    .\NuGet Deployment.ps1 -Version 1.2.3-alpha -NuGet c:\temp\NuGet.exe
    

    Are you calling deployment.ps1 to package or it's NuGet Deployment.ps1 with space in it?

  9. 9 Posted by Pure Krome on 15 Jul, 2015 12:11 AM

    Pure Krome's Avatar

    Not sure I understand this line...

    I have a powershell script called NuGet Deployment.ps1. It exists in <root folder>\NuGet Package Specifications\ folder.

    it has a few args:

    - Version <version string>
    - NuGet <full path to nuget.exe. eg. c:\temp\nuget.exe>
    

    (and some other args that aren't used for a release deployment in AV.

    I'm not sure how to 'run' that ps file using the AV yml syntax.

  10. Support Staff 10 Posted by Feodor Fitsner on 15 Jul, 2015 12:27 AM

    Feodor Fitsner's Avatar

    Got it.

    Try this:

    - ps: & '.\NuGet Package Specifications\NuGet Deployment.ps1' -Version $env:appveyor_build_version -NuGet 'C:\Tools\NuGet\nuget.exe'
    
  11. 11 Posted by Pure Krome on 15 Jul, 2015 12:47 AM

    Pure Krome's Avatar

    Nope, not working.

    error message:

    Error parsing appveyor.yml: (Line: 19, Col: 9, Idx: 337) - (Line: 19, Col: 10, Idx: 338): While scanning an anchor or alias, did not find expected alphabetic or numeric character.

    it's def the PS line... It's like the parser doesn't like the & char?

    here's my file...

    version: '1.0.0-alpha-{build}-test'
    configuration: Release
    
    branches:
      only:
        - master-test
    
    assembly_info:
      patch: true
      file: AssemblyInfo.*
      assembly_version: '{version}'
      assembly_file_version: '{version}'
      assembly_informational_version: '{version}'
    
    before_build:
      - nuget restore
    
    after_build:
      - ps: & '.\NuGet Package Specifications\NuGet Deployment.ps1' -Version $env:appveyor_build_version -NuGet 'C:\Tools\NuGet\nuget.exe'
    
    artifacts:
      - path: '**\*.nupkg'
    
    build:
      parallel: true
      verbosity: minimal
      publish_nuget: true
    
    cache:
      - packages -> **\packages.config
    
    # build NuGet package and upload it to artifacts
    
    deploy:
      provider: NuGet
      api_key:
        secure: <snipped>
    
  12. Support Staff 12 Posted by Feodor Fitsner on 15 Jul, 2015 01:32 AM

    Feodor Fitsner's Avatar

    OK, this one passes validation:

    - ps: '& ".\NuGet Package Specifications\NuGet Deployment.ps1" -Version $env:appveyor_build_version -NuGet "C:\Tools\NuGet\nuget.exe"'
    
  13. 13 Posted by Pure Krome on 15 Jul, 2015 05:21 AM

    Pure Krome's Avatar

    yep - passes!

    but errors :(

    is that error suggesting that I can't ouput my script stuff to the AV console?

    Exception calling "SetBufferContents" with "2" argument(s): "The method or operation is not implemented." <-- no idea what that means :(

  14. Support Staff 14 Posted by Feodor Fitsner on 15 Jul, 2015 05:24 AM

    Feodor Fitsner's Avatar

    Most probably it's requesting input and this exception comes from AppVeyor custom PowerShell host.

    - Feodor

  15. 15 Posted by Pure Krome on 15 Jul, 2015 06:01 AM

    Pure Krome's Avatar

    So there's no way to get the "inner exception" stuff?

    btw, running this on my localhost works fine :/

  16. Support Staff 16 Posted by Feodor Fitsner on 15 Jul, 2015 05:44 PM

    Feodor Fitsner's Avatar

    This error could be caused by calling a cmdlet with missing parameter or by calling Read-Host. You can try seeing what's going on via RDP: http://www.appveyor.com/docs/how-to/rdp-to-build-worker

  17. 17 Posted by Pure Krome on 01 Sep, 2015 12:06 AM

    Pure Krome's Avatar

    I'm back onto this issue - trying to see if I can resolve it.

    Funnily enough, I asked this (similar) question nearly a year ago and created a GitHub issue back then too!

  18. 18 Posted by Pure Krome on 01 Sep, 2015 05:04 AM

    Pure Krome's Avatar

    Another question @feodor - how do I use a custom secure environmental variable in a powershell script?

    give this script (from above..)

    - ps: '& ".\NuGet Package Specifications\NuGet Deployment.ps1" -Version $env:appveyor_build_version -NuGet "C:\Tools\NuGet\nuget.exe"'

    i wish to add the following powershell cli argument : -apiKey <my secure variable>

  19. 19 Posted by Pure Krome on 01 Sep, 2015 06:53 AM

    Pure Krome's Avatar

    Damn - no luck. So I've RD'd into the VM and fixed my PS bugs. sweet.

    Go back to AV and run the script and still get that weird error.

    here's proof...

    (note: i'll change my API key later once this works) (note 2: i'm hardcoding things right now to get this to work).

    after_build:
      - ps: Write-Host $env:appveyor_build_version
      - ps: '& ".\NuGet\NuGet Package and Package.ps1" -Version 1.0.0-sr20 -NuGet "C:\Tools\NuGet\nuget.exe" -feedSource https://www.myget.org/F/openrealestate/api/v2 -apiKey 93b1057e-57a4-4971-95e9-7078eb1f45a0'
    

    and here's 2 screenies showing you that it works when i RD in ....

    Any help Feodor?

  20. Support Staff 20 Posted by Feodor Fitsner on 01 Sep, 2015 06:58 AM

    Feodor Fitsner's Avatar

    I think it should be like "-apiKey $env:my_secure_variable". Also note that secure variables are not set on PR builds.

    - Feodor

  21. 21 Posted by Pure Krome on 01 Sep, 2015 09:05 AM

    Pure Krome's Avatar

    In my example above, I hardcoded the variables just to get this working. And it's still not.

    The code is all OSS so you should be able see the build history and even try it yourself (by adding the RD lines to the yml script) (take note the code above is for a specific branch).

    it's really confusing/frustrating :(

  22. Support Staff 22 Posted by Feodor Fitsner on 01 Sep, 2015 09:20 AM

    Feodor Fitsner's Avatar

    Sure, will take a look. What AV project URL is that?

  23. 23 Posted by Pure Krome on 01 Sep, 2015 10:57 AM

    Pure Krome's Avatar
  24. Support Staff 24 Posted by Feodor Fitsner on 01 Sep, 2015 11:08 AM

    Feodor Fitsner's Avatar

    Yeah, right.

    - Feodor

  25. Support Staff 25 Posted by Feodor Fitsner on 01 Sep, 2015 04:30 PM

    Feodor Fitsner's Avatar
  26. 26 Posted by Pure Krome on 02 Sep, 2015 01:40 AM

    Pure Krome's Avatar

    Oh wow! works! that was it. You're awesome Feodor! thank you so much!

  27. Pure Krome closed this discussion on 02 Sep, 2015 01:40 AM.

  28. Pure Krome re-opened this discussion on 02 Sep, 2015 01:41 AM

  29. 27 Posted by ThanksFeodor on 19 Dec, 2016 08:26 PM

    ThanksFeodor's Avatar

    Thanks Feodor!
    Found this via the searching the "2" argument(s) exception message in a not directly related context and you saved me lots of time.

  30. Pure Krome closed this discussion on 19 Dec, 2016 11:43 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac