[CSHARP-4608] cannot install C# driver using Windows and .NET SDK 6.0 (or 7.0) Created: 10/Apr/23  Updated: 11/May/23  Resolved: 05/May/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Boris Dogadov
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-3626 Fix NuGet install fail Closed
related to CSHARP-3798 Cannot install 2.13.1 MongoDB.Driver ... Closed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Summary

NuGet says it can't find a version of the C# driver to install on my Windows spawnhost after I install .NET 6.0 SDK

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

N/A

How to Reproduce

1. start windows-2022-small spawnhost.
2. download and run .NET 6.0.407 SDK installer.
3. in a Command Prompt, run dotnet new console and then dotnet add package MongoDB.Driver; expectation is that these commands work. Actual result is that NuGet says "There are no versions available for that package"

Additional Background

I just need to compile a simple test program that uses the C# driver, plus some things that need .NET 6.0. Is there a better spawnhost flavor to use? Should I give up and try using .NET on Linux instead?



 Comments   
Comment by Eric Milkie [ 05/May/23 ]

Ah I see, it is something specific to how we set up our Evergreen instances then.
I think that's all for now!

Comment by Boris Dogadov [ 05/May/23 ]

Thanks for validating this,

I don't think any docs changes are required as having the correct nuget source is just a part of regular dotnet environment setup, and not tied to our driver.
It's not clear why the host lacks the official nuget source.

Comment by Eric Milkie [ 05/May/23 ]

Thanks, that does work.
Do we have to change the Quick Start page now? Following our documented steps there will not work due to this NuGet problem.
https://www.mongodb.com/docs/drivers/csharp/current/quick-start/#std-label-csharp-quickstart

Comment by Boris Dogadov [ 05/May/23 ]

Hi milkie@mongodb.com 

I was able to reproduce that issue following the mentioned steps (I have RDPed into the host).
But then adding nuget source resolved the issue:

dotnet nuget Add source -n "nuget.org" "https://api.nuget.org/v3/index.json".

The default source was missing from the initial config for some reason:

C:\Users\Administrator>dotnet nuget list source
No sources found.

.NET frameworks installed:

.NET SDKs installed:
  3.1.426 [C:\Program Files\dotnet\sdk]
  6.0.408 [C:\Program Files\dotnet\sdk]

Please let us know if you observe any other problems in this area.

Comment by Eric Milkie [ 12/Apr/23 ]

Thanks James, I'm using Linux for my purposes now. I really thought I needed to use Windows to get the best experience here – I was sorely mistaken!

Comment by James Kovacs [ 12/Apr/23 ]

I tried installing .NET 7 on our Windows spawnhosts - specifically windows-2022-small and windows-64-vs2019-small - and saw similar though not identical failures. .NET 7 installed but then complained bitterly about HOME and USERPROFILE environment variables not being defined. Even when I set them it still complained that they were unset. My best guess is something weird with cygwin (because I ssh'd into the boxes), but I saw the same problem when I ran powershell.exe.

Our EG scripts are bash running on cygwin and launch powershell.exe as needed. We use Microsoft's dotnet-install.ps1 to download and install .NET Core 2.1, .NET Core 3.1, .NET 5, and .NET 6 on the Windows spawnhosts to run our driver tests. So I know this works.

We will continue investigating but in the meantime if you're not doing anything Windows specific, .NET on Linux (and MacOS) works quite well. Feel free to reach out if you have any questions.

Comment by Eric Milkie [ 12/Apr/23 ]

Interesting data point: I have now successfully installed the driver on both MacOS and on Fedora Linux with .NET 7.0, so it's really mysterious why it's not working for me on Windows.

Comment by Eric Milkie [ 10/Apr/23 ]

Output of Command Prompt during step 3 reproducer step:

C:\Users\Administrator>dotnet --version
6.0.407
 
C:\Users\Administrator>dotnet new console
 
Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.407
 
Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
 
Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
 
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
The template "Console App" was created successfully.
 
Processing post-creation actions...
Running 'dotnet restore' on C:\Users\Administrator\Administrator.csproj...
  Determining projects to restore...
  Restored C:\Users\Administrator\Administrator.csproj (in 67 ms).
Restore succeeded.
 
 
 
C:\Users\Administrator>dotnet add package MongoDB.Driver
  Determining projects to restore...
  Writing C:\Users\Administrator\AppData\Local\Temp\2\tmpB9C6.tmp
info : X.509 certificate chain validation will use the default trust store selected by .NET.
info : Adding PackageReference for package 'MongoDB.Driver' into project 'C:\Users\Administrator\Administrator.csproj'.
error: There are no versions available for the package 'MongoDB.Driver'.
 
 
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.

Generated at Wed Feb 07 21:48:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.