Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --prerelease option to dotnet add package #4699

Closed
livarcocc opened this issue Feb 27, 2017 · 35 comments · Fixed by NuGet/NuGet.Client#3480
Closed

Add --prerelease option to dotnet add package #4699

livarcocc opened this issue Feb 27, 2017 · 35 comments · Fixed by NuGet/NuGet.Client#3480
Assignees
Labels

Comments

@livarcocc
Copy link

From @yooakim at https://github.com/dotnet/cli/issues/5752

I'm not sure this is a bug but it would be nice if one could add NuGet packages with the -pre version as used by NuGet.

Steps to reproduce

dotnet add package Swashbuckle --version pre

Expected behavior

<Project Sdk="Microsoft.NET.Sdk.Web">                                                   
                                                                                        
  <PropertyGroup>                                                                       
    <TargetFramework>netcoreapp1.1</TargetFramework>                                    
  </PropertyGroup>                                                                      
                                                                                        
  <ItemGroup>                                                                           
    <Folder Include="wwwroot\" />                                                       
  </ItemGroup>                                                                          
                                                                                        
  <ItemGroup>                                                                           
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />                 
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />             
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />   
    <PackageReference Include="Swashbuckle" Version="6.0.0-beta902" />                  
                                                                                        
  </ItemGroup>                                                                          
                                                                                        
</Project>                                                                              

Actual behavior

C:\Code\Coach\src\Coach.API [master]> dotnet add package Swashbuckle --version pre
Microsoft (R) Build Engine version 15.1.545.13942
Copyright (C) Microsoft Corporation. All rights reserved.

  Writing C:\Users\Joakim\AppData\Local\Temp\tmp2F1A.tmp
error: 'pre' is not a valid version string.

## Environment data
`dotnet --info` output:
@rohit21agrawal
Copy link
Contributor

CC : @mishra14

@rohit21agrawal rohit21agrawal added Product:NuGet.exe NuGet.exe Type:DCR Design Change Request labels Feb 27, 2017
@mishra14
Copy link
Contributor

@livarcocc :

You can do dotnet add package newtonsoft.json -v 10.0.0-* to get the prerelease packages.

log -

log  : Installing Newtonsoft.Json 10.0.1-beta1.
info : Package 'newtonsoft.json' is compatible with all the specified frameworks in project 'E:\NuGet.Client\cli_test\cli_test.csproj'.
info : PackageReference for package 'newtonsoft.json' version '10.0.0-*' added to file 'E:\NuGet.Client\cli_test\cli_test.csproj'.

This will add -

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="newtonsoft.json">
      <Version>10.0.0-*</Version>
    </PackageReference>
  </ItemGroup>
</Project>

The --pre flag was not added because restore does not have an explicit way of request prerelease packages. Maybe @emgarten can chime in here?

@jacek-jaskolski
Copy link

@mishra14 I'm trying to dotnet add package rawrabbit -v 2.0.0-* and it gives me:

Please specify one package reference to add.
.NET Add Package reference Command

Adding <PackageReference Include="rawrabbit" Version="2.0.0-*"> to csproj file and restoring the packages works fine.

Using version 1.0.0-rc3-004530

@mishra14
Copy link
Contributor

mishra14 commented Mar 7, 2017

@jacek-jaskolski : We initially had a problem about placing -v param in the command after the package name. But that was fixed a while ago here: dotnet/cli@04a7fca.

Please try the latest dotnet cli and it should be fine.

@terrajobst
Copy link

terrajobst commented Mar 29, 2017

At the very least the error message needs to change. This is the current experience:

$ dotnet add package Alexa.NET
Microsoft (R) Build Engine version 15.1.523.56541
Copyright (C) Microsoft Corporation. All rights reserved.

  Writing C:\Users\immol\AppData\Local\Temp\tmp9BFC.tmp
info : Adding PackageReference for package 'Alexa.NET' into project 'T:\Test\Test.csproj'.
log  : Restoring packages for T:\Test\Test.csproj...
info :   GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-corefxlab/nuget/v3/flatcontainer/alexa.net/index.json
info :   CACHE https://api.nuget.org/v3-flatcontainer/alexa.net/index.json
info :   GET https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-core/nuget/v3/flatcontainer/alexa.net/index.json
info :   NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-corefxlab/nuget/v3/flatcontainer/alexa.net/index.json 132ms
info :   NotFound https://dotnetmyget.blob.core.windows.net/artifacts/dotnet-core/nuget/v3/flatcontainer/alexa.net/index.json 135ms
error: Unable to resolve 'Alexa.NET' for '.NETCoreApp,Version=v2.0'.
error: Package 'Alexa.NET' is incompatible with 'all' frameworks in project 'T:\Test\Test.csproj'.

The message implies that the package isn't compatible, not that it cannot be found. FWIW I'm not a fan of the -v <version> number as the sole way to install pre-release packages. The whole point of using the CLI to install the package is so that I don't have to look up the version number on NuGet org. I want to be able to quickly add a package in a sensible version (latest stable).

Ideally, this is how I would like the UX to be:

$ dotnet add package Foo
There are no stable packages for Foo. Consider specifying --pre to install the latest pre-release version.
$ dotnet add package Foo --pre
Installed package Foo 1.0.0-beta-5.

/cc @timheuer @bjorg

@timheuer
Copy link

@terrajobst is right. There are actually two things here. Bug: the error message is WRONG. Feature: add support for grabbing prerelease.

How can we at least fix the error message?

@mishra14 mishra14 added this to the 4.3 milestone Mar 29, 2017
@billwert
Copy link

billwert commented Apr 4, 2017

@richlander and I hit this last night as well. The experience must get better. I really like @terrajobst's suggestion of informing the user that no packages were found; I'd go a step further and only suggest --pre if pre-release packages exist. Otherwise just inform the user the package doesn't exist.

This sort of output is just frustrating:

error: Unable to resolve 'thiscantbeapackage' for '.NETCoreApp,Version=v2.0'.
error: Package 'thiscantbeapackage' is incompatible with 'all' frameworks in project 'whatever.csproj'.

@rrelyea
Copy link
Contributor

rrelyea commented Apr 5, 2017

We are doing some error/warning rework in nuget restore in our 4.3 release. If things go well, internal consumers of restore (like dotnet add package) could have better ability to understand those errors, beyond just passing along the log output.
/cc @mishra14

@rrelyea rrelyea modified the milestones: 4.4, 4.3 Jun 27, 2017
@rrelyea
Copy link
Contributor

rrelyea commented Jun 27, 2017

blocked by lack of 4.4.- support in versions right now.

@rrelyea rrelyea modified the milestones: Backlog, 4.4 Aug 15, 2017
@mishra14 mishra14 added the Priority:2 Issues for the current backlog. label Sep 1, 2017
@nietras
Copy link

nietras commented Feb 21, 2018

What is the status of this? It's been several months, and this does not seem to have been added yet. I need this as well.

@terrajobst
Copy link

terrajobst commented Feb 21, 2018

@rrelyea, what are your thoughts on making the cut for an upcoming release? It's probably too late for 2.1, but it's a high hitter in the UX. What's the next train this could catch?

@mishra14 mishra14 added Priority:1 High priority issues that must be resolved in the current sprint. and removed Priority:2 Issues for the current backlog. labels Feb 22, 2018
@mishra14
Copy link
Contributor

@terrajobst I have moved it to Priority 0 to reflect the request.

@terrajobst
Copy link

Thanks!

@nietras
Copy link

nietras commented Jun 19, 2018

@mishra14 @terrajobst this issue is still open, has it not been resolved yet?

@aortiz-msft aortiz-msft assigned zkat and unassigned aortiz-msft Mar 23, 2020
@zkat zkat assigned nkolev92 and unassigned zkat Jun 15, 2020
@nkolev92 nkolev92 assigned martinrrm and unassigned nkolev92 Jun 18, 2020
@nkolev92 nkolev92 changed the title dotnet add package - support for Nuget "Pre" version dotnet add package - support for NuGet "Pre" version Jun 18, 2020
@nkolev92 nkolev92 removed the Category:Quality Week Issues that should be considered for quality week label Jun 22, 2020
@aortiz-msft aortiz-msft changed the title dotnet add package - support for NuGet "Pre" version Add "prerelease" option to dotnet add package Aug 6, 2020
@arnotes
Copy link

arnotes commented Oct 25, 2020

still not working as of dotnet 3.1.4
Your.Package 0.41.7-pre.1 was not found

I can confirm this doesnt work even with the "-v 1.1.1-pre1.1" argument

@nkolev92
Copy link
Member

@arnotes

The fix for this bug has not been released yet.

3.1.400 matches 5.7 of NuGet, but this was fixed in 5.0.100 of the SDK, matching 5.8 of NuGet and 16.8 of Visual Studio.

@dominoFire dominoFire changed the title Add "prerelease" option to dotnet add package Add --prerelease option to dotnet add package Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.