-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Multiple -s/--source flags on "dotnet build" and "dotnet restore" not working #27202
Comments
had same exact issue only happen on windows, it works fine on linux and macos |
What version of the SDK are you using? I didn't see this issue on windows on 7.0.1xx but maybe it's an older version impacted. |
Is this known to be fixed in version 7? |
Any news regarding this? |
I'm still experiencing this with the .NET SDK 7.0.202 (on Windows only, as already mentioned by @anggape). The workaround I'm using is to specify the sources in a custom nuget.config: <?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" value="packages" />
</config>
<packageSources>
<clear />
<add key="local" value="." />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration> Note that in this sample |
… command line This works around dotnet/sdk#27202 It also has the benefit of using settings _only_ from the specified config file, ignoring the global nuget.config where package source mapping could interfere with the local source.
Another workaround, discussed in dotnet/msbuild#1622 (comment) is to pass the http source first. I.e.
instead of
|
Thank you all for your comments! |
Coming back to old bugs. I was about to reproduce this as it specifically requires a local source first and then the https source second. From a binlog, the SDK creates a RestoreSources property that is passed through to msbuild and then passed to nuget as a semicolon delimited list. I don't see a bad path anywhere in the sdk and msbuild side of things so I think this is getting messed up in the nuget tasks. I can also reproduce by specifing -p:RestoreSources to an msbuild call as long as the local source is first. @nkolev92 does this look like it could be a nuget bug? Passing the restore sources in the other order appears to work correctly. _OutputSources = C:\test\bug\feed%3bhttps:\api.nuget.org\v3\index.json GetRestoreDotnetCliToolsTask RestoreGraphItems |
Unsure honestly. dotnet/msbuild#1622 seems to be where a lot of bugs point back to. |
I have stuck most probably on the same root issue, just with And this broke after updating from .net 6.x SDK (exact version not known) to .net 7.0.306 SDK And occurs with http/https-sources, not just file-paths. This behaviour is on Windows using either a CMD or PowerShell Core 7 CLI. I can't confirm, whether this happens or not on Linux or on Mac. Examples: "C:\Program Files\dotnet\dotnet.exe" pack "MyProj.csproj" --configuration "Debug" "-p:RestoreSources=https://api.nuget.org/v3/index.json;http://my-private-v2-http-nuget-server.com/nuget" --nologo --force Also the alternative parametrizing of "C:\Program Files\dotnet\dotnet.exe" pack "MyProj.csproj" --configuration "Debug" "-restoreProperty:RestoreSources=https://api.nuget.org/v3/index.json;http://my-private-v2-http-nuget-server.com/nuget" --nologo --force Error message on both is: MSBuild version 17.6.8+c70978d4d for .NET
MSBUILD : error MSB1006: Property is not valid.
Switch: http://my-private-v2-http-nuget-server.com/nuget Also changing the order of the elements in semi-colon-separated list (first http-source and then https-source) did not help. Then the command just errors for the latter source. MSBuild version 17.6.8+c70978d4d for .NET
MSBUILD : error MSB1006: Property is not valid.
Switch: https://api.nuget.org/v3/index.json A single http-source works. The workaround to use nuget.config on project or user-level with omitting the And anyway |
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):
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?
The text was updated successfully, but these errors were encountered: