Itiviti / gradle-dotnet-plugin

Gradle plugin for interacting with dotnet cli
Apache License 2.0
19 stars 8 forks source link

Unable to apply source for Restore task #7

Closed vinoth-karunanithy closed 3 years ago

vinoth-karunanithy commented 3 years ago

Hi @ngyukman ,

I am looking to apply my own custom nuget package url instead of default or offline package. But whenever I tried the below, I am getting errors.

In my build.gradle,

dotnet {

    restore {

        noCache = true

        force = true

        beforeBuild = true

        source = ['https://api.nuget.org/v3/index.json'] //This is just the default nuget package source. This will be changed once the source is working
    }
}

I am receiving the below exception:

  • What went wrong: Could not determine the dependencies of task ':dotnetBuild'. Failed to calculate the value of task ':dotnetBuild' property 'sources'. Failed to parse project, output: C:\Test\build\tmp\dotnet\ProjectFileParser.csproj : error NU1101: Unable to find package Microsoft.Build. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages C:\Test\build\tmp\dotnet\ProjectFileParser.csproj : error NU1101: Unable to find package Microsoft.Build.Locator. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages C:\Test\build\tmp\dotnet\ProjectFileParser.csproj : error NU1101: Unable to find package Microsoft.Win32.Registry. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages C:\Test\build\tmp\dotnet\ProjectFileParser.csproj : error NU1102: Unable to find package System.Security.Principal.Windows with version (>= 5.0.0) C:\Test\build\tmp\dotnet\ProjectFileParser.csproj : error NU1102: - Found 1 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 4.7.0 ] C:\Test\build\tmp\dotnet\ProjectFileParser.csproj : error NU1101: Unable to find package Microsoft.NETCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages C:\Test\build\tmp\dotnet\ProjectFileParser.csproj : error NU1101: Unable to find package Microsoft.WindowsDesktop.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages C:\Test\build\tmp\dotnet\ProjectFileParser.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.App.Ref. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages , error: The build failed. Fix the build errors and run again.

Also, When I tried to give the source as below,

source = List(...) or source = mutableListOf(...)

I am getting the below error.

As a newbie to gradle and also to your plugin, I am not sure what am I missing. So, please help me understand, how the restore source should be set. I am not able to find any sample for passing the sources, even in your README.md. It would also be better, if you provide some working sample to make sure that it works fine.

Thanks, Vinoth Karunanithy