aws / aws-toolkit-azure-devops

AWS Toolkit for Azure DevOps
Other
235 stars 100 forks source link

LambdaNETCoreDeploy fails with nuget.config referencing Azure Devops artifacts #316

Open boro2g opened 4 years ago

boro2g commented 4 years ago

Describe the bug When you try to deploy to a lambda function, it performs an upgrade of Amazon.Lambda.Tools during the setup. We hit an issue where if you have a global nuget.config which references an azure devops package repo the command"C:\Program Files\dotnet\dotnet.exe" tool update -g Amazon.Lambda.Tools errors. To workaround we had to remove the common project nuget config

To reproduce

  1. setup new solution
  2. at root of sln add nuget.config with packageSource reference to a private nuget feed e.g.
    <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="AzureDevops" value="https://pkgs.dev.azure.com/###/_packaging/###/nuget/v3/index.json" />    
    </packageSources>
  3. Create a c# dotnetcore3.0 lambda function
  4. Setup a yaml pipeline with build task:
    - task: AmazonWebServices.aws-vsts-tools.LambdaNETCoreDeploy.LambdaNETCoreDeploy@1
      displayName: 'Deploy .NET Core to Lambda:  '
      inputs:
        awsCredentials: '###'
        regionName: 'eu-west-1'    
        lambdaProjectPath: '###'
        functionName: '###'
        functionRole: 'arn:aws:iam::###:role/###'
        functionHandler: 'not_required_for_custom_runtime'
        functionMemory: 256
        functionTimeout: 30

Expected behavior The deployment runs thorugh fine

Screenshots N/A. The error from the console is:

"C:\Program Files\dotnet\dotnet.exe" tool update -g Amazon.Lambda.Tools
C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/###/_packaging/###/nuget/v3/index.json. [C:\Users\VssAdministrator\AppData\Local\Temp\hqfr4phi.yr2\restore.csproj]
C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error :   Response status code does not indicate success: 401 (Unauthorized). [C:\Users\VssAdministrator\AppData\Local\Temp\hqfr4phi.yr2\restore.csproj]
Tool 'amazon.lambda.tools' failed to update due to the following:
The tool package could not be restored.
Tool 'amazon.lambda.tools' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool
##[error]Unable to install global Amazon.Lambda.Tools! The old package based version of Amazon.Lambda.Tools is now deprecated. Newer .NET core versions will need to use a newer hosted agent and the global tools (which this task auto installs). Refer to Microsoft's guide for the correct hosted agent for which hosted agent you need to use newer .NET Core versions:https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted
"C:\Program Files\dotnet\dotnet.exe" restore

Your Environment

Additional context N/A

fabiomilheiro commented 4 years ago

Any progress on this please?

hunterwerlla commented 4 years ago

It seems like nuget/the .netcore build tools do not have the right credentials:

 Response status code does not indicate success: 401 (Unauthorized).

How do you provide it with credentials to access your internal feed?

santoror commented 4 years ago

Same issue here. If the repository is internal to your org you don't need to provide any credential.

3GDXC commented 4 years ago

any update on this; I believe I'm also running into this same issue #336 I've included logs and have a step which deletes the nuget.config just prior the the lambda task; which allow the tools to insstall, but the execution fails as the command is unable to locate the tools?

Jacko1394 commented 4 years ago

SAME PROBLEM

mithewt commented 3 years ago

Same error here after commenting out all other nuget sources inside nuget.config, it still fails. At the very least, there needs to be a flag to disable update!