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

Sdk resolver does not honor --configfile; and fails silently #17319

Closed
ghost opened this issue Apr 30, 2021 · 9 comments
Closed

Sdk resolver does not honor --configfile; and fails silently #17319

ghost opened this issue Apr 30, 2021 · 9 comments
Labels
Area-NuGet untriaged Request triage from a team member

Comments

@ghost
Copy link

ghost commented Apr 30, 2021

When performing dotnet restore using the --configfile argument, the nuget Sdk resolver does not honor the --configfile setting.

This results in two problems:

  1. restore fails to restore the SDKs in question.
  2. the restore exist with a success exit code, when it should not.

This issue is tracking the first problem.

Repro steps

  1. create the files described below in "Reference files"
  2. install the dotnetsdk as described in global.json
  3. from shell, run dotnet restore --configfile custom_nuget.config && dotnet build --no-restore

Expected

Project restores and builds successfully, producing no output

Actual

Project fails to restore, silently exiting with exit code zero and no console output. The subsequent build then fails with the following errors:

aaronla@aaronla-rabbit:repro_sdk$ dotnet restore --configfile custom_nuget.config

aaronla@aaronla-rabbit:repro_sdk$ echo %ERRORLEVEL%
0

aaronla@aaronla-rabbit:repro_sdk$ dotnet build --no-restore
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

C:\scratch\repro_sdk\my.csproj : error MSB4236: The SDK 'Microsoft.Build.Traversal' specified could not be found.

Build FAILED.

C:\scratch\repro_sdk\my.csproj : error MSB4236: The SDK 'Microsoft.Build.Traversal' specified could not be found.
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.11

Reference files

aaronla@aaronla-rabbit:repro_sdk$ powershell "ls * | % { echo ''; echo ('// '+ $_.Name); cat $_ }"

// custom_nuget.config
<configuration>
  <config>
    <add key="repositoryPath" value="packages_custom" />
    <add key="globalPackagesFolder" value="packages_custom" />
  </config>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

// global.json
{
    "sdk": {
        "version": "5.0.202"
    },
    "msbuild-sdks": {
        "Microsoft.Build.NoTargets": "2.0.1"
    }
}

// my.csproj
<Project Sdk="Microsoft.Build.Traversal">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
</Project>

// nuget.config
<configuration>
  <config>
    <add key="repositoryPath" value="packages" />
    <add key="globalPackagesFolder" value="packages" />
  </config>
  <packageSources>
    <clear />
    <add key="badfeed" value="Z:\badfeed" protocolVersion="3" />
  </packageSources>
</configuration>
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Apr 30, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost
Copy link
Author

ghost commented Apr 30, 2021

@rainersigwald Heya, this is the issue we were discussing the other day about config files.

@rainersigwald
Copy link
Member

From that conversation I think the ask here is: do something in the restore verb to communicate to NuGet running in the SDK resolver the new config file location. I think NuGet would respect an environment variable if it was set.

The compat impact of mapping --configfile to that env var instead of the current MSBuild property is not clear to me.

@erdembayar
Copy link
Contributor

@aaronla-ms
Could you be able to share sample repro project? I was unable to repro my local.
If you provide repro sample then I can investigate end to end.

@ghost
Copy link
Author

ghost commented May 13, 2021

@erdembayar
Copy link
Contributor

erdembayar commented May 21, 2021

@aaronla-ms
I can repro this. Could you be able to create issue in https://github.com/NuGet/Home/issues/new? Somehow I can't transfer this to our repo.

@ghost
Copy link
Author

ghost commented May 21, 2021

@erdembayar Sure thing. I copied the issue over to that project.

@erdembayar
Copy link
Contributor

@aaronla-ms
Please put link for new issue here and better to close this one as duplicate.

@ghost
Copy link
Author

ghost commented May 21, 2021

reopened as NuGet/Home#10886

@ghost ghost closed this as completed May 21, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NuGet untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants