cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.87k stars 728 forks source link

Nuget.config not found for version 0.25 #2010

Open masterkawaster opened 6 years ago

masterkawaster commented 6 years ago

What You Are Seeing?

in Diagnostic log: Nuget.config not found.

What is Expected?

Nuget.config being next to build.ps1 should be used.

What version of Cake are you using?

0.25

Are you running on a 32 or 64 bit system?

windows server 2012 r2, 64bit.

What environment are you running on? Windows? Linux? Mac?

windows server 2012 r2, 64bit.

Are you running on a CI Server? If so, which one?

TFS v. 15.117.26615.0 on premise. powershell task: PowerShell on Target Machines v.1.* But the error looks like generic.

How Did You Get This To Happen? (Steps to Reproduce)

  1. Put the following files here: c:\some\path\ Nuget.config
    <?xml version="1.0" encoding="utf-8"?>
    <configuration> 
    <activePackageSources>
        <clear />
    </activePackageSources>
    <packageSources>
        <clear />   
    </packageSources>
    <disabledPackageSources>
        <clear />
    </disabledPackageSources>
    </configuration>

    build.ps1 from here: https://raw.githubusercontent.com/cake-build/cake/develop/build.ps1

build.cake

#addin nuget:?package=Cake.Git;

Task("Clean")
    .Does(() =>
{
    Information("Do something"); 
}
);

RunTarget(target);
  1. Execute this command (yes being in c:\ as TFS does it also like that): Invoke-Expression "c:\some\path\build.ps1 -Script C:\some\path\build.cake -Verbosity Diagnostic"

Output Log

PS C:\> Invoke-Expression "c:\some\path\build.ps1 -Script C:\some\path\build.cake -Verbosity Diagnostic"
Preparing to run build script...
Running build script...
Module directory does not exist.
NuGet.config not found.
Analyzing build script...
Analyzing C:/some/path/build.cake...
Processing build script...
Installing addins...

So even though latest (0.25 https://cakebuild.net/blog/2018/01/cake-v0.25.0-released) change in cake provided nuget client inside cake.exe, I think it should still look for nuget.config in cake.exe directory or above up to drive directory. The documentation: https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior#how-settings-are-applied

jnm2 commented 6 years ago

I wonder if one of the NuGet packages contains the NuGet CLI's config resolution logic.

bjorkstromm commented 6 years ago

The "resolution magic" is in the libs we are referencing, see https://github.com/NuGet/NuGet.Client/blob/release-4.3.0-rtm/src/NuGet.Core/NuGet.Configuration/Settings/Settings.cs#L213-L221

We might be "doing it wrong" and there might also be an issue with the Working directory (this has changed since we no longer call nuget.exe from within whatever directory it was previous).

timschps commented 6 years ago

if you put the nuget.config file in the folder where nuget.exe file resides, then it works again

minimaltesty commented 6 years ago

@timschps by using a build agent that always checks out the repository the work around does not work. do you have any other ideas except adding nuget.config to the source code project?

kll commented 6 years ago

I've noticed a related bug that is definitely in the referenced library mentioned above and not in Cake that has to do with NuGet.Config resolution. The docs here say that on Mac/Linux the default user nuget.config file could be at ~/.config/NuGet/NuGet.Config or ~/.nuget/NuGet/NuGet.Config depending on your distribution. However the library is only checking the second place. My config is at ~/.config/NuGet/NuGet.Config and isn't picked up. I added a symlink to mine from ~/.nuget/NuGet/NuGet.Config and it started working.