I don't understand how csproj and references play together. And I created a basic .Net Core app and it's building fine locally. But when I am trying to publish it I am getting exception as below.
error NETSDK1047: Assets file 'C:\Users\source\repos\AWSLambda7\AWSLambda7\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v3.1/linux-x64'. Ensure that restore has run and that you have included 'netcoreapp3.1' in the TargetFrameworks for your project. You may also need to include 'linux-x64' in your project's RuntimeIdentifiers. [C:\Users\source\repos\AWSLambda7\AWSLambda7\AWSLambda7.csproj]
Below is the code snippet
public class Function
{
public async Task FunctionHandler(SQSEvent evnt, ILambdaContext context)
{
foreach (var message in evnt.Records)
{
await Task.CompletedTask;
}
}
}
The csproj file looks like below
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.0.0" />
<PackageReference Include="Amazon.Lambda.SQSEvents" Version="1.1.0" />
</ItemGroup>
</Project>
The obj\project.assets.json file looks like below
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.1": {
"Amazon.Lambda.Core/1.1.0": {
"type": "package",
"compile": {
"lib/netstandard2.0/Amazon.Lambda.Core.dll": {}
},
"runtime": {
"lib/netstandard2.0/Amazon.Lambda.Core.dll": {}
}
},
"Amazon.Lambda.Serialization.SystemTextJson/2.0.0": {
"type": "package",
"dependencies": {
"Amazon.Lambda.Core": "1.1.0"
},
"compile": {
"lib/netcoreapp3.1/Amazon.Lambda.Serialization.SystemTextJson.dll": {}
},
"runtime": {
"lib/netcoreapp3.1/Amazon.Lambda.Serialization.SystemTextJson.dll": {}
}
},
"Amazon.Lambda.SQSEvents/1.1.0": {
"type": "package",
"compile": {
"lib/netstandard2.0/Amazon.Lambda.SQSEvents.dll": {}
},
"runtime": {
"lib/netstandard2.0/Amazon.Lambda.SQSEvents.dll": {}
}
}
}
},
"libraries": {
"Amazon.Lambda.Core/1.1.0": {
"sha512": "ueGId8b4DEHoVWkHDs3iAJH8IUSAUGu5AqkoI/Syl4RuByzik7lz9IjoImQ==",
"type": "package",
"path": "amazon.lambda.core/1.1.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"amazon.lambda.core.1.1.0.nupkg.sha512",
"amazon.lambda.core.nuspec",
"lib/netstandard1.3/Amazon.Lambda.Core.dll",
"lib/netstandard1.3/Amazon.Lambda.Core.xml",
"lib/netstandard2.0/Amazon.Lambda.Core.dll",
"lib/netstandard2.0/Amazon.Lambda.Core.xml"
]
},
"Amazon.Lambda.Serialization.SystemTextJson/2.0.0": {
"sha512": "En67XZpjBILNrLdb/7HqGtqkPjoRYDjViY4+PEn1CAe53FNStU/vbcVtDvDyvQeUnFgMui3zvMdlsjJIzBPHdQ==",
"type": "package",
"path": "amazon.lambda.serialization.systemtextjson/2.0.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"amazon.lambda.serialization.systemtextjson.2.0.0.nupkg.sha512",
"amazon.lambda.serialization.systemtextjson.nuspec",
"lib/netcoreapp3.1/Amazon.Lambda.Serialization.SystemTextJson.dll",
"lib/netcoreapp3.1/Amazon.Lambda.Serialization.SystemTextJson.xml"
]
},
"Amazon.Lambda.SQSEvents/1.1.0": {
"sha512": "AD6rELASxItdSSR1Vj7X7pEE8OeGIADJkYer9dvHtXP+2Nhp==",
"type": "package",
"path": "amazon.lambda.sqsevents/1.1.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"amazon.lambda.sqsevents.1.1.0.nupkg.sha512",
"amazon.lambda.sqsevents.nuspec",
"lib/netstandard1.3/Amazon.Lambda.SQSEvents.dll",
"lib/netstandard1.3/Amazon.Lambda.SQSEvents.xml",
"lib/netstandard2.0/Amazon.Lambda.SQSEvents.dll",
"lib/netstandard2.0/Amazon.Lambda.SQSEvents.xml"
]
}
},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.1": [
"Amazon.Lambda.Core >= 1.1.0",
"Amazon.Lambda.SQSEvents >= 1.1.0",
"Amazon.Lambda.Serialization.SystemTextJson >= 2.0.0"
]
},
"packageFolders": {
"C:\\Users\\.nuget\\packages\\": {},
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\source\\repos\\AWSLambda7\\AWSLambda7\\AWSLambda7.csproj",
"projectName": "AWSLambda7",
"projectPath": "C:\\Users\\source\\repos\\AWSLambda7\\AWSLambda7\\AWSLambda7.csproj",
"packagesPath": "C:\\Users\\.nuget\\packages\\",
"outputPath": "C:\\Users\\source\\repos\\AWSLambda7\\AWSLambda7\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"netcoreapp3.1"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.1": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.1": {
"dependencies": {
"Amazon.Lambda.Core": {
"target": "Package",
"version": "[1.1.0, )"
},
"Amazon.Lambda.SQSEvents": {
"target": "Package",
"version": "[1.1.0, )"
},
"Amazon.Lambda.Serialization.SystemTextJson": {
"target": "Package",
"version": "[2.0.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.301\\RuntimeIdentifierGraph.json"
}
}
}
}
Note that project builds fine in VS-2019 in Windows 10 machine.