-
Notifications
You must be signed in to change notification settings - Fork 252
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
NuGetSdkResolver doesn't respect pivots that come through msbuild properties (example --config-file, RestoreSources) #7855
Comments
This is becoming kind of challenge, because restore itself has various configuration pivots that likely don't work with the SDK resolver. --config-file is one. I imagine RestoreSources & similar msbuild settings for NuGet don't work. I'd imagine the whole list from https://github.com/NuGet/Home/wiki/%5BSpec%5D-NuGet-settings-in-MSBuild is an issue. And that'll continue to be a moving target in the future. //cc @rrelyea |
Anything settings coming from MSBuild will not work with the SDK resolver because the project has not been evaluated yet. So no properties or items are loaded to even pass along. The feeds must be defined in the root We could possibly plumb the custom path to the nuget.config to the SDK resolver but that wouldn't be available until 16.1 at the earliest. I would like to find a workaround that unblocks people immediately. Doesn't the newer credential provider use environment variables to pass along auth tokens? Editing the |
A similar issue was raised in #8183 |
What the current state of this issue? We (.NET Core) are running into this as well and are curious what the current thinking is. cc/ @jcagme |
No progress has been made on it. Note that this scenario adds some inconvenient coupling so if you can at all avoid it, please do so. |
You are saying we should not try restoring SDK packages from a private feed? |
Don't specify the config file directly & allow the tooling to discover it by convention. If you put the config file at the repo root and/or near the solution files, ti will be discovered by the tooling automatically. |
Well, at least for our case explained here we don't pass in the location of |
The cred providers were enabled for the sdk resolver so that should be working the same as regular restore. I'm not sure why it's having trouble detecting the plugin however. |
I should note that the Azure Pipelines DotNetCoreCLI task does not use the credential provider today. It uses a flow where it generates a temporary config, and passes --configfile to dotnet. That means that the DotNetCoreCLI task definitely won't work today with MSBuild SDKs in authenticated feeds. If I understand correctly, @jcagme might be seeing another issue where nuget doesn't invoke the credential properly for MSBuild SDKs. I think we need to investigate that further - I haven't had a chance to look into that yet. |
Yes, the installation script put the plugin in
Yeah, for our builds we don't use the task but use Windows
Mac
Azure DevOps build agent
|
Is it possible your VSS_NUGET_EXTERNAL_FEED_ENDPOINTS envvar isn't getting set or is incorrect? If it's a domain account perhaps the windows case is working because it's silently / non-interactively authenticating and thus doesn't need VSS_NUGET_EXTERNAL_FEED_ENDPOINTS? Not sure what identities are in play here for you. |
I thought that to be the case but I then included a step to echo the variable value and it is correct. It looks like BotPAT is the PAT of an account I explicitly added as a contributor of the feed. |
pkgs.dev.azure.com/<organization> vs <organization>.pkgs.visualstudio.com mismatch? |
True, although |
It must match up exactly between nuget.config and endpointCredentials. Putting both forms into endpointCredentials won't hurt. |
It fails with both endpoints. Both endpoints live in |
@jeffkl
|
The only thing we could plumb through would be global properties since they are loaded before a project is evaluated. You could then set the global property via the command-line or The issue for this proposed feature is here: dotnet/msbuild#2095 |
I do not think we'll be adding support for this any time soon. The workaround is to just check in your NuGet.config and use the same sources for all builds. The ability to dynamically use different sources at build time is just not a very common scenario. If you want to dynamically change sources at build time, you'll need to write a script that changes the NuGet.config before restore and build. |
I'm aware of the workaround, but it wastes developer time to have a documented feature that doesn't work. Would highly recommend updating the docs for --config-file to indicate that it doesnt' work for Sdk imports. |
Also, consider piping the appropriate config parameters as environment variables. E.g. add NUGETSDKRESOLVER_CONFIG_FILE and update |
Having an env variable would indeed be helpful... |
Running into the same issue, the |
I just wasted several hours tracking down this issue in a CI pipeline. I'd go one step further than the documentation and suggest changing the error message shown by NuGet in this case from "error MSB4236: The SDK .. specified could not be found" to something more explicit about NuGet not being able to restore SDKs when |
The NuGet-based SDK resolver doesn't appear to respect --configfile, and instead just uses the nuget.config next to the project.
e.g. if I have a project-level nuget.config with a single source 'sourcenexttoproject', and a separate --configfile nuget.config with a single source 'differentsource':
The SDK is trying to restore from sourcenexttoproject, instead of from differentsource as I would expect it to. Note the sources are both invalid themselves, so the fact that there are "unable to load" errors on each is expected.
This bug completely breaks the DotNetCoreCli build task in Azure Pipelines when used against authed sources, as the task writes a temporary nuget.config with credentials and passes it via --configfile.
@jeffkl as FYI since I had discussed with him using his project SDKs for our own codebase, and this is blocking our adoption.
The text was updated successfully, but these errors were encountered: