question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple -s/--source flags on "dotnet build" and "dotnet restore" not working

See original GitHub issue

The “dotnet restore” page: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-restore says

  • -s|--source <SOURCE>

    Specifies the URI of the NuGet package source to use during the restore operation. This setting overrides all of the sources specified in the nuget.config files. Multiple sources can be provided by specifying this option multiple times.

I believe the same should apply to the -s|–source flag of “dotnet build” (even though its page fails to mention the “Multiple sources can be provided by specifying this option multiple times” part).

But specifying -s|--source multiple times does not seem to work if you try to list a folder and a URL, on either “dotnet build” or “dotnet restore”.

My problem: We are building a C# SDK that is entering private preview, hence in order to use it you have to download the NuGet file to your local disk and install it (it is not available on any public feed). So I need to tell dotnet/nuget to use a local folder as one of its sources. On the other hand, our sample application also needs other (public) nuget packages (e.g. Azure.Core). So I need to tell dotnet/nuget to use both a local folder feed and the public nuget.org feed.

I know I can do always add a local nuget source using this separate command to add the local feed (this works fine):

dotnet nuget add source c:\packages --name local

But I don’t want users to run that extra command (and then another command to delete this local source).

I want to give them one “dotnet build” command that will also specify the nuget sources, like this:

dotnet build ImageAnalysisQuickstart.csproj --source c:\users\dcohen\downloads --source https://api.nuget.org/v3/index.json

When I run the above I get the following error:

error NU1301: The local source ‘d:\git\cognitive-services-vision-sdk-private-preview\https:\api.nuget.org\v3\index.json’ doesn’t exist.

Looks like it’s treating the nuget.org URL as a folder path and adding it to the path where I’m running the command.

Does anyone know the right way to specify multiple nuget sources on the “dotnet build” command?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
anggapecommented, Sep 4, 2022

had same exact issue only happen on windows, it works fine on linux and macos

1reaction
dargilcocommented, Mar 28, 2023

Thank you all for your comments!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet restore using local and server sources
I would like to use dotnet restore command to provide two sources using --source flag. First one is in local folder inside project...
Read more >
dotnet restore command - .NET CLI
Learn how to restore dependencies and project-specific tools with the dotnet restore command.
Read more >
dotnet build command - .NET CLI
This command supports the dotnet restore options when passed in the long form (for example, --source ). Short form options, such as -s...
Read more >
dotnet publish command - .NET CLI
Doesn't build the project before publishing. It also implicitly sets the --no-restore flag. --no-dependencies. Ignores project-to-project ...
Read more >
dotnet pack command - .NET CLI
This command supports the dotnet restore options when passed in the long form (for example, --source ). Short form options, such as -s...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found