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

Can't use pre-release nuget packages? #180

Open
knocte opened this issue Sep 21, 2021 · 10 comments
Open

Can't use pre-release nuget packages? #180

knocte opened this issue Sep 21, 2021 · 10 comments

Comments

@knocte
Copy link
Contributor

knocte commented Sep 21, 2021

Description

Trying to add a pre-release nuget package reference to my projects yields an error.

Repro steps

  1. Use the adviced command: dotnet add myProject/myProject.fsproj package FSharpx.Collections --version 3.0.0-alpha2021.09.17.065817

  2. Try adding the --source flag too: dotnet add myProject/myProject.fsproj package FSharpx.Collections --version 3.0.0-alpha2021.09.17.065817 --source https://nuget.pkg.github.com/fsprojects/index.json

Expected behavior

Should add the PackageReference to the .fsproj file.

Actual behavior

Gives this error:

  Determining projects to restore...
  Writing /var/folders/kj/152c8zjj40lfmxd3dbjf_2kw0000gp/T/tmpG5r3iC.tmp
info : Adding PackageReference for package 'FSharpx.Collections' into project 'myProject/myProject.fsproj'.
error: '3.0.0-alpha2021.09.17.065817' is not a valid version string.

Related information

  • Operating system: tested with macOS 11.6
  • Branch: master (latest pre-release from master branch)
  • .NET Runtime: 5.0.401
@sergey-tihon
Copy link
Member

@knocte can you please try once again? I've published version without dots 3.0.0-alpha20210929190241

@knocte
Copy link
Contributor Author

knocte commented Sep 30, 2021

@sergey-tihon thanks! looks like we're progressing, because now I get a different error:

% dotnet add myProject/myProject.fsproj package FSharpx.Collections --source https://nuget.pkg.github.com/fsprojects/index.json --version 3.0.0-alpha20210929190241
  Determining projects to restore...
  Writing /var/folders/kj/152c8zjj40lfmxd3dbjf_2kw0000gp/T/tmpjmY94a.tmp
info : Adding PackageReference for package 'FSharpx.Collections' into project 'myProject/myProject.fsproj'.
info : Restoring packages for /Users/knocte/Documents/Code/MyProject/myProject/myProject.fsproj...
info :   GET https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json
warn : Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
info :   Unauthorized https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json 823ms
log  : Retrying 'FindPackagesByIdAsync' for source 'https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json'.
log  : Response status code does not indicate success: 401 (Unauthorized).
info :   GET https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json
warn : Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
info :   Unauthorized https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json 598ms
log  : Retrying 'FindPackagesByIdAsync' for source 'https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json'.
log  : Response status code does not indicate success: 401 (Unauthorized).
info :   GET https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json
warn : Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.
info :   Unauthorized https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json 574ms
error: Failed to retrieve information about 'FSharpx.Collections' from remote source 'https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json'.
error:   Response status code does not indicate success: 401 (Unauthorized).

@sergey-tihon
Copy link
Member

According to GitHub docs Installing NuGet package you need to authenticate first

@knocte
Copy link
Contributor Author

knocte commented Oct 12, 2021

According to GitHub docs Installing NuGet package you need to authenticate first

Ehmm, what? If the packages are from an opensource repo that is public, I don't understand why authentication is needed.

I hope this doesn't mean that the restore stage needs authentication too? Will test...

@knocte
Copy link
Contributor Author

knocte commented Oct 12, 2021

Strangely enough, I get again the error that I was getting at the beginning (before you pushed 4bdfae2 ):

% cat nuget.config 
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <clear />
        <add key="github" value="https://nuget.pkg.github.com/fsprojects/index.json" />
    </packageSources>
    <packageSourceCredentials>
        <github>
            <add key="Username" value="knocte" />
            <add key="ClearTextPassword" value="myPersonalAccessToken" />
        </github>
    </packageSourceCredentials>
</configuration>
% dotnet add myProject/myProject.fsproj package FSharpx.Collections --source https://nuget.pkg.github.com/fsprojects/index.json --version 3.0.0-alpha20210929190241
  Determining projects to restore...
  Writing /var/folders/kj/152c8zjj40lfmxd3dbjf_2kw0000gp/T/tmpjH44Td.tmp
info : Adding PackageReference for package 'FSharpx.Collections' into project 'NOnion/NOnion.fsproj'.
info : Restoring packages for /Users/knocte/Documents/Code/NOnion/NOnion/NOnion.fsproj...
info :   GET https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json
info :   OK https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json 1223ms
warn : The file '/Users/knocte/.local/share/NuGet/v3-cache/9f53714eb423b2f2c9fa5544820ecfa8484db3a9$github.com_fsprojects_index.json/list_fsharpx.collections.dat' is corrupt.
log  : Retrying 'FindPackagesByIdAsync' for source 'https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json'.
log  : '3.0.0-alpha2021.09.17.065817' is not a valid version string. (Parameter 'value')
info :   GET https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json
info :   OK https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json 1161ms
warn : The file '/var/folders/kj/152c8zjj40lfmxd3dbjf_2kw0000gp/T/NuGet/TempCache/fe7c0b31-58cc-4999-bcd1-7d0125674502/esmqk3jb.x0b' is corrupt.
log  : Retrying 'FindPackagesByIdAsync' for source 'https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json'.
log  : '3.0.0-alpha2021.09.17.065817' is not a valid version string. (Parameter 'value')
info :   GET https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json
info :   OK https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json 3860ms
warn : The file '/var/folders/kj/152c8zjj40lfmxd3dbjf_2kw0000gp/T/NuGet/TempCache/fe7c0b31-58cc-4999-bcd1-7d0125674502/3ckseefj.g35' is corrupt.
error: Failed to retrieve information about 'FSharpx.Collections' from remote source 'https://nuget.pkg.github.com/fsprojects/download/fsharpx.collections/index.json'.
error:   '3.0.0-alpha2021.09.17.065817' is not a valid version string. (Parameter 'value')

Maybe the authentication is failing and somehow the exposed error is this one by mistake? Take in account that I don't belong to the fsprojects organization.

@knocte
Copy link
Contributor Author

knocte commented Oct 12, 2021

Tried to more things, FYI, to no avail:

% dotnet add myProject/myProject.fsproj package FSharpx.Collections --source https://nuget.pkg.github.com/fsprojects/index.json --version 3.0.0-alpha20210929190241 --prerelease
  Determining projects to restore...
  Writing /var/folders/kj/152c8zjj40lfmxd3dbjf_2kw0000gp/T/tmpYgGlnA.tmp
error: The --prerelease and --version options are not supported in the same command.


Usage: NuGet.CommandLine.XPlat.dll package add [options]

Options:
  -h|--help               Show help information
  --force-english-output  Forces the application to run using an invariant, English-based culture.
  --package               Id of the package to be added.
  --version               Version of the package to be added.
  -d|--dg-file            Path to the dependency graph file to be used to restore preview and compatibility check.
  -p|--project            Path to the project file.
  -f|--framework          Frameworks for which the package reference should be added.
  -n|--no-restore         Do not perform restore preview and compatibility check. The added package reference will be unconditional.
  -s|--source             Specifies NuGet package sources to use during the restore.
  --package-directory     Directory to restore packages in.
  --interactive           Allow the command to block and require manual action for operations like authentication.
  --prerelease            Allows prerelease packages to be installed.
knocte@apples-MacBook-Pro NOnion % dotnet add myProject/myProject.fsproj package FSharpx.Collections --source https://nuget.pkg.github.com/fsprojects/index.json --prerelease 
  Determining projects to restore...
  Writing /var/folders/kj/152c8zjj40lfmxd3dbjf_2kw0000gp/T/tmpJypRRa.tmp
info : Adding PackageReference for package 'FSharpx.Collections' into project 'NOnion/NOnion.fsproj'.
info :   GET https://nuget.pkg.github.com/fsprojects/fsharpx.collections/index.json
info :   OK https://nuget.pkg.github.com/fsprojects/fsharpx.collections/index.json 1191ms
error: '3.0.0-alpha2021.09.17.065817' is not a valid version string. (Parameter 'value')

@sergey-tihon
Copy link
Member

error: The --prerelease and --version options are not supported in the same command.

message say that you should not use --prerelease when you specify exact version.
Can you please try

dotnet add myProject/myProject.fsproj package FSharpx.Collections --source https://nuget.pkg.github.com/fsprojects/index.json --version 3.0.0-alpha20210929190241

@knocte
Copy link
Contributor Author

knocte commented Oct 18, 2021

@sergey-tihon judging by your last reply, it seems you only read my last message, but not the previous one.

That is, the error I got about prerelease was just my last attempt at trying to find out if I was doing something wrong. I was aware of its error message, but just pasted it anyway, in case you were going to suggest me to use that flag.

Can you please try

Already tried, check my previous message (previous to the one where I pasted the --prerelease error).

@knocte
Copy link
Contributor Author

knocte commented Oct 22, 2021

@sergey-tihon friendly ping :)

I was just wondering, that if these pre-release packages cannot be used by anyone that is not part of the fsprojects organization, wouldn't it be better to just publish these packages in nuget? By marking them as pre-release packages they wouldn't be used by anyone by default, only via opt-in for people who want unstable(prerelease) grade packages.

@sergey-tihon
Copy link
Member

@knocte sorry, I missed one your message.

I hope this doesn't mean that the restore stage needs authentication too? Will test...

I think that you will need to commit nuget.config in the repo in order to restore packages.
But if your personal token contains only one scope read:packages it should not be dangerous because there is no ways to misuse it.

image

pre-release packages cannot be used by anyone that is not part of the fsprojects organization

It cannot be so, because can download them manually even you not authenticated here https://github.com/orgs/fsprojects/packages?repo_name=FSharpx.Collections

log : '3.0.0-alpha2021.09.17.065817' is not a valid version string. (Parameter 'value')
Looks like nugget cannot work feed that contains versions that nuget count as invalid.
I've deleted all packages with incorrect version and able to install it without issue.

May I ask you try one time?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants