I'm trying to create a layer for my lambda function developed with Net core 3.1, but I get the following error:
zipping: Failed to compress file: open
dotnetcore\store\x64\netcoreapp3.1\microsoft.extensions.dependencyinjection.abstractions\
5.0.0\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll:
The system cannot find the path specified.
The command that I'm using is:
dotnet lambda publish-layer --region us-east-1 --layer-name my-Layers --layer-type runtime-package-store -sb sb-layers -f netcoreapp3.1 --package-manifest package-manifest.xml
The package manifest is the following:
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.4.0" />
<PackageReference Include="Amazon.Lambda.Core" Version="2.0.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.1.0" />
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.0.73" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
I see that the file path with the error has "netstandard2.0" but I don't know why. Maybe my question is silly, does this mean that I cannot used "microsoft.extensions.dependencyinjection.abstractions" with Net Core 3.1?
Thanks a lot for any information about how to deal with this issue.
I tried creating the package and didnt fail at any point
So, this is what i did.
Updated the dotnet distribution and fresh install aws lambda tools
sudo apt-get install -y dotnet-sdk-5.0
dotnet tool install -g Amazon.Lambda.Tools
I used the sample DemoLayer as instructed by the AWS tutorials
AWS tutorial
dotnet lambda publish-layer DemoLayer --layer-type runtime-package-store -sb <s3bucket> --package-manifest manifest.xml
and above command line uploads all the Package Reference without any error.
Related
I use visual studio to create the new web project which is MVC in .net Framework 4.8 under .net core 2.2.
When I use nuget to get the Microsoft.EntityFrameworkCore.SqlServer
and start to run (debug), I got the below exception
System.MethodAccessException: 'Attempt by method 'Microsoft.Extensions.Logging.Configuration.LoggerProviderConfigurationFactory.GetConfiguration(System.Type)'
to access method 'Microsoft.Extensions.Logging.ProviderAliasUtilities.GetAlias(System.Type)' failed.'
My Project properties is only this
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.2.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
</ItemGroup>
</Project>
Can you help to solve this problem ?
Thank you
the solution was downloading the Microsoft.Extensions packages and updating the versions so it can be equivalents.
here were the main answer and the discussions:
I suspect the issue is due to mismatched package versions. You will
certainly need to update all EntityFrameworkCore packages to the same
version. I expect you will also need to pull in the latest 3.1
versions of Microsoft.Extensions packages, since the EF packages
depend on the 3.1 versions of these packages.
discussion
I'm creating a new MVC application using visual studio code and I want to add entity framework core to my project. My application is using the latest .net core 3 but when I tried to install package Microsoft.EntityFrameworkCore.SqlServer its show an error like this
Unable to resolve 'Microsoft.EntityFrameworkCore.SqlServer (>= 3.0.0)' for '.NETCoreApp,Version=v3.0'
How can I solve this issue?
ASP.NET Core 3.0 removes some assemblies that were previously part of the Microsoft.AspNetCore.App package reference.
You should add the package references for removed assemblies.
In XML project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>My-secret</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0" />
</ItemGroup>
</Project>
Take a look here.
Ive started getting this error out of the blue
This only happens when I deploy the application via teamcity. If I run it locally it works fine.
What ive tried doing .
Added the nuget package manually to the class libraries
Debug Locally - My local solution runs fine
I have never seen anything like this before.
UPDATE
Ive browsed to my output directory and the DLL Version is this .
This would explain the error but I have no clue why its using this version.
UPDATE 2 - As Requested .csproj file
<ItemGroup>
<PackageReference Include="Autofac" Version="4.8.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.0.4" />
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="3.1.66" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.6.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
</ItemGroup>
So Im not sure why this happened but on the publish the Microsoft.Extensions.ObjectPool.dll in the publish folder was never being updated .
Simply marking <DeleteExistingFiles>True</DeleteExistingFiles> as true in my publish .pubxml and republishing magically fixed the issue. Hope this helps someone in the future.
I am developing a netcoreapp2.0 console application and I need access to the whole encoding package from .NET.
I have already added the System.Text.Encoding.CodePages Version=4.4.0 Nuget package from this page to my project and cleaned/restored the project several time.
However I can't get the extra encoding I need.
The following code:
Console.WriteLine(Encoding.GetEncodings().Length);
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.WriteLine(Encoding.GetEncodings().Length);
returns:
8
8
and no extra encoding is added to Encoding class.
These are all the references I have in my project:
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
<PackageReference Include="System.Data.HashFunction.xxHash" Version="2.0.0-ci-00012" />
<PackageReference Include="Nager.PublicSuffix" Version="1.1.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
Am I doing something wrong here?
Update
After reinstalling the .NET Core SDK 2.0.2 again, things started to work fine and I can use the extended Encoding code pages using Encoding.GetEncoding() method, however the Encoding.GetEncodings() still returns the initial 8 Encoding code pages.
Update August 2022:
Thanks to a comment from zapoo, we know that while the solution is not required in .net framework 4.8, it is needed for .net 6.0
I am adding this as the answer regarding Gabriel Rainha's suggestion that it might help other people in the future too.
I cleaned the Nuget cache, repaired my ".NET Core SDK 2.0.2" installation, did a "Solution and Project Cleanup" and rebuilt my project, and the Encoding.RegisterProvider(CodePagesEncodingProvider.Instance) code started to work fine.
Now I can access the extra code pages using the Encoding.GetEncoding() method, however I still get the same list of encodings from Encoding.GetEncodings() method after adding the extra encodings.
From my perspective the Encoding.GetEncodings() method should return all the encodings available after more of them have been added.
install nuget packages:
System.Text.Encoding & System.Text.Encoding.CodePages
For the last couple of days, I've been trying to compile my .NET Core console application, and upload it to a VPS running "Windows Server 2012 R2". The reason I am using .NET Core is because this is needed for the library - Discord.Net 1.0.
The first thing I tried was simply taking my release DLL file and data, with the following file structure:
LeveledStudios.deps
LeveledStudios.dll
LeveledStudios.pdb
LeveledStudios.runtimeconfig.dev
LeveledStdios.runtimeconfig
This worked fine for execution on the PC I developed it on, however I then went into my server, ran "dotnet LeveledStudios.dll", and was faced with the error
Error: assembly specified in the dependencies manifest was not found -- package: 'discord.net.commands', version '1.0.0-rc-00546', path: 'lib/netstandard1.3/Discord.Net.Commands.dll`
Noticing this fitted the structure of the .nuget folder on my development PC. I copied it across and faced the same issue, and tried to copy it into the same folder as leveledstudios.dll, only to run into some .dll's which refused to work. This also included missing system DLL files, like System.Net.Http, etc.
I did some googling, and saw information about self contained .NET Core applications. This sounds perfect because clearly my problem was that it was not compiling with all my additional libraries. I was a little confused because I did not have a project.json file, as mentioned in all the documentation I read on it.
However when running:
dotnet restore
dotnet build -r win10-x64
I get a host of errors, suggesting none of the system libraries are compiled:
Errors
The contents of LeveledStudios.csproj:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.Commands" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.Core" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.WebSocket" Version="1.0.0-rc-00546" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.2-beta2" />
</ItemGroup>
</Project>
How can I fix this?
...self contained .NET Core applications [sound] perfect... however... I get a host of errors, suggesting none of the system libraries are compiled.
To resolve the errors that happened when you built as a self-contained application, add this one line to your *.csproj file:
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
Restore will then bring down the runtime, allowing you to build and publish as a self-contained application.
dotnet restore
dotnet build -r win10-x64
dotnet publish -c release -r win10-x64
The final *.csproj file looks like this:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<OutputType>exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.Commands" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.Core" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.WebSocket" Version="1.0.0-rc-00546" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.2-beta2" />
</ItemGroup>
</Project>
That's how to publish as a self-contained application, which is one alternative to resolve your initial problem.
The other alternative (which Ryan suggested and which you said did not work) is to use a framework-dependent application, in which case you do not need the RuntimeIdentifiers property. You can then run the same commands but without specifying the runtime.
dotnet restore
dotnet build
dotnet publish
The publish files, which will include the Discord dependencies, will be here:
bin\Debug\netcoreapp1.0\publish