我在.Net Core Lambda项目中将目标框架从netcoreapp1.0更改为netcoreapp2.0。
打包lambda时,执行命令dotnet lambda package -c Release -f netcoreapp2.0
:
执行Lambda包装时出现未知错误:无法找到部分内容 路径
dotnet lambda package -c Release -f netcoreapp2.0
Executing publish command
Deleted previous publish folder
... invoking 'dotnet publish', working folder 'C:\Source\\Project.Lambda\bin\Release\netcoreapp2.0\publish'
... publish: Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
... publish: Copyright (C) Microsoft Corporation. All rights reserved.
... publish: Restore completed in 32.96 ms for C:\Source\Project\Project.csproj.
... publish: Restore completed in 50.69 ms for C:\Source\Project.Lambda\Project.Lambda.csproj.
... publish: Restore completed in 80.61 ms for C:\Source\Project.Lambda\Project.Lambda.csproj.
... publish: Project -> C:\Source\Project\bin\Release\netcoreapp2.0\Project.dll
... publish: Project.Lambda -> C:\Source\Project.Lambda\bin\Release\netcoreapp2.0\Project.Lambda.dll
... publish: Project.Lambda -> C:\Source\Project.Lambda\bin\Release\netcoreapp2.0\publish\
Flattening platform specific dependencies
... flatten: runtime/unix/lib/_._
Unknown error executing Lambda packaging: Could not find a part of the path 'C:\Source\Project.Lambda\bin\Release\netcoreapp2.0\publish\runtime\unix\lib\_._'.
at System.IO.Win32FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
at System.IO.File.Copy(String sourceFileName, String destFileName)
at Amazon.Lambda.Tools.LambdaPackager.<>c__DisplayClass4_0.<FlattenRuntimeFolder>b__0(String sourceRelativePath)
at Amazon.Lambda.Tools.LambdaPackager.FlattenRuntimeFolder(IToolLogger logger, String publishLocation, JsonData depsJsonTargetNode)
at Amazon.Lambda.Tools.LambdaPackager.CreateApplicationBundle(LambdaToolsDefaults defaults, IToolLogger logger, String workingDirectory, String projectLocation, String configuration, String targetFramework, String& publishLocation, String& zipArchivePath)
at Amazon.Lambda.Tools.Commands.PackageCommand.<ExecuteAsync>b__22_0()
答案 0 :(得分:1)
似乎问题出现了,因为我使用的是旧版<ItemGroup>
<DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="1.7.0" />
</ItemGroup>
:
<ItemGroup>
<DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="2.1.2" />
</ItemGroup>
手动将其更改为最新版本修复了它:
Executing publish command
Deleted previous publish folder
... invoking 'dotnet publish', working folder 'C:\Source\Project.Lambda\bin\Release\netcoreapp2.0\publish'
... publish: Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
... publish: Copyright (C) Microsoft Corporation. All rights reserved.
... publish: Restoring packages for C:\Source\Project\Project.csproj...
... publish: Restoring packages for C:\Source\Project.Lambda\Project.Lambda.csproj...
... publish: Restore completed in 32.96 ms for C:\Source\Project\Project.csproj.
... publish: Restore completed in 50.69 ms for C:\Source\Project.Lambda\Project.Lambda.csproj.
... publish: Project -> C:\Source\Project\bin\Release\netcoreapp2.0\Project.dll
... publish: Project.Lambda -> C:\Source\Project.Lambda\bin\Release\netcoreapp2.0\linux-x64\Project.Lambda.dll
... publish: Project.Lambda -> C:\Source\Project.Lambda\bin\Release\netcoreapp2.0\publish\
Zipping publish folder C:\Source\Project.Lambda\bin\Release\netcoreapp2.0\publish to C:\Source\Project.Lambda\lambda.zip
输出现在看起来像这样:
public static Google.Apis.Drive.v3.Data.FileList ListFiles(DriveService service, string folderId)
{
try
{
var request = service.Files.List();
request.PageSize = 100;
request.Fields = "nextPageToken, files(id, name)";
if (!String.IsNullOrEmpty(folderId))
{
request.Q = "'" + folderId + "' in parents " + " and mimeType='image/jpeg'";
}
return request.Execute();
}
catch (Exception ex)
{
throw new Exception("Request failed.", ex);
}
}