1

This is not duplicate of this thread, although goal is the same, but the error is not.

I want to build my ASP.NET Core on machine without Visual Studio installed.

I need this, because I am setting GitLab CI/CD.

Just for test purpose I open console I execute dotnet restore and dotnet build in folder where .sln file is. I get the following error in both cases:

C:\Program Files\dotnet\sdk\2.1.4\NuGet.targets(103,5): error : The local source 'C:\Users\matjaz.cof\.dotnet\NuGetFallbackFolder' doesn't exist.

Full log:

C:\GitLab-Runner\builds\7cab42e4\0\web\app>dotnet restore
  Restoring packages for C:\GitLab-Runner\builds\7cab42e4\0\web\app\App.Web.Core\App.Web.Core.csproj...
  Restoring packages for C:\GitLab-Runner\builds\7cab42e4\0\web\app\App.Web.Library.Tests\App.Web.Library.Tests.csproj...
  Restoring packages for C:\GitLab-Runner\builds\7cab42e4\0\web\app\App.Web.Core.Tests\App.Web.Core.Tests.csproj...
  Restoring packages for C:\GitLab-Runner\builds\7cab42e4\0\web\app\App.Web.Library\App.Web.Library.csproj...
  Restoring packages for C:\GitLab-Runner\builds\7cab42e4\0\web\app\App.Web.Hosting\App.Web.Hosting.csproj...
  Restore completed in 93,72 ms for C:\GitLab-Runner\builds\7cab42e4\0\web\app\App.Web.Hosting\App.Web.Hosting.csproj.
C:\Program Files\dotnet\sdk\2.1.4\NuGet.targets(103,5): error : The local source 'C:\Users\matjaz.cof\.dotnet\NuGetFallbackFolder' doesn't exist. [C:\GitLab-Runner\builds\7cab42e4\0\web\app\App.Web.sln]

Answer in provided thread says that all I need is Dotnet SDK, which I installed:

C:\GitLab-Runner\builds\7cab42e4\0\web\app>dotnet --version
2.1.4

Folder really doesn't exists on Windows server, but it exists on my development machine (with VS 2017 installed).
I search entire c: on Windows Server for folder NuGetFallbackFolder and found it in c:\Program Files\dotnet\sdk\NuGetFallbackFolder.

Why dotnet restore/build search for folder under username and what do I need to change?

Edited: (@MartinUllrich)

This is the content of c:\Users\matjaz.cof\AppData\Roaming\NuGet\NuGet.Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>
Makla
  • 9,899
  • 16
  • 72
  • 142

2 Answers2

3

This fallback folder path was used during the 2.0 preview timeframe of .NET Core.

You can delete package sources referencing this directory from the C:\Users\ matjaz.cof\AppData\Roaming\NuGet\NuGet.Config file.

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
  • I deleted complete folder `C:\Users\ matjaz.cof\AppData\Roaming\NuGet` there was only `NuGet.Config` file inside, but the error stays and it is the same. I also close and open cmd and powershell (just in case if something is cached). – Makla Feb 21 '18 at 07:26
  • is a nuget.config file recreated? does it contain a reference to that directory? I'd suggest just editing the nuget.config to remove the directory – Martin Ullrich Feb 21 '18 at 07:29
  • Yes, folder is recreated and no, there is no reference to `NuGetFallbackFolder`. I edited my question with content of `NuGet.Config` file. – Makla Feb 21 '18 at 07:45
  • I event restart the server, but I still get the error. Any other idea? – Makla Feb 22 '18 at 11:13
0

I simply solved it by coping c:\Program Files\dotnet\sdk\NuGetFallbackFolder\ to c:\Users\matjaz.cof\.dotnet\NuGetFallbackFolder\.

I couldn't think of anything else. Maybe uninstalling old .NET Core runtimes and SDKs would also do the trick.

Makla
  • 9,899
  • 16
  • 72
  • 142