Publish to AWS… Missing from Visual Studio 2017

2019-08-11 10:15发布

问题:

I am trying to publish a lambda function to AWS but my VS Solution Explorer's Project right-click menu does not have Publish to AWS... option in Visual Studio 2017. This was there just a day back. How or can the Publish to AWS... be added to the Visual Studio 2017 right click menu?

回答1:

  1. You need to add the Amazon.Lambda.Tools package to your project using the nuget package manager
  2. If adding the package using nuget fails, add these lines to your .csproj file inside the <project> tags

    
    <ItemGroup>
        <DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="1.8.0" />
    </ItemGroup>
    
    


回答2:

I ran into the same problem when creating a new .net core app independent of using one of the Lambda template projects. First, I followed this answer to install the tools globally (you no longer need to add to your csproj): https://stackoverflow.com/a/52448951/407188.

That worked great to install the tools locally, but I still couldn't get the right-click "Publish to Lambda" menu to show up. I tried many of the other suggestions including the above but ultimately found my csproj file was missing the following line

<AWSProjectType>Lambda</AWSProjectType>

... located as follows

<PropertyGroup>
   <TargetFramework>netcoreapp2.1</TargetFramework>

   <!--The new property indicating to AWS Toolkit for Visual Studio this is a Lambda project-->
   <AWSProjectType>Lambda</AWSProjectType>      
</PropertyGroup>

More details of this change can be found at https://github.com/aws/aws-extensions-for-dotnet-cli

Finally, I now see