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

Irrelevant nuget.config on parent directory makes build failure on project directory #44897

Open
huypn12 opened this issue Nov 15, 2024 · 1 comment
Labels
Area-CLI untriaged Request triage from a team member

Comments

@huypn12
Copy link

huypn12 commented Nov 15, 2024

Describe the bug

Irrelevant nuget.config on parent directory makes build failure on project directory.

To Reproduce

Create a solution directory

$ mkdir $HOME/Projects/some-project

Initialize a solution with a console project inside the solution directory

$ cd $HOME/Projects/some-project
$ dotnet new sln --name SomeProject \
        && dotnet new console --name SomeProject \
        && dotnet sln add SomeProject

Test build success

$ dotnet build
  Determining projects to restore...
  All projects are up-to-date for restore.
  SomeProject -> /home/huypn12/Projects/some-project/SomeProject/bin/Debug/net8.0/SomeProject.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.35

Now create an invalid nuget config on the parent directory:

$ touch $HOME/Projects/nuget.config
$ tee $HOME/Projects/nuget.config <<EOF
<packageSources>
    <add key="some-invalid-source" value="https://some-invalid-source/v3/index.json" protocolVersion="3" />
</packageSources>
EOF

Test build: failed

$ cd $HOME/Projects/some-project
$ dotnet build
  Determining projects to restore...
/usr/share/dotnet/sdk/8.0.404/NuGet.targets(745,5): error : NuGet.Config does not contain the expected root element: 'configuration'. Path: '/home/huypn12/Projects/nuget.config'. [/home/huypn12/Projects/some-project/SomeProject/SomeProject.csproj]

Build FAILED.

/usr/share/dotnet/sdk/8.0.404/NuGet.targets(745,5): error : NuGet.Config does not contain the expected root element: 'configuration'. Path: '/home/huypn12/Projects/nuget.config'. [/home/huypn12/Projects/some-project/SomeProject/SomeProject.csproj]
    0 Warning(s)
    1 Error(s)

Discussion

Why is such behaviour? Is it because of some recursive nuget.config checking?
Perhaps it makes more sense to have dotnet build command to check the nuget.config file of the current project directory?
Which part of the dotnet sdk is responsible for the behaviour?

Further technical details

.NET SDK:
 Version:           8.0.404
 Commit:            7b190310f2
 Workload version:  8.0.400-manifests.4d7d414a
 MSBuild version:   17.11.9+a69bbaaf5

Runtime Environment:
 OS Name:     debian
 OS Version:  12
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/8.0.404/

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.

Host:
  Version:      8.0.11
  Architecture: x64
  Commit:       9cb3b725e3

.NET SDKs installed:
  8.0.404 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.11 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.11 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-CLI untriaged Request triage from a team member labels Nov 15, 2024
@KalleOlaviNiemitalo
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CLI untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants