I am publishing ASP.NET Core 2 application and seeing the following error.
Error:
An assembly specified in the application dependencies manifest (MyApp.deps.js
I have resolved this issue by installing nuget package
"Microsoft.AspNetCore.ApplicationInsights.HostingStartup"
This assembly was expected to be in the local runtime store
You are getting this error because you don't have the ASP.NET Core Runtime Store installed. You have two options to fix this.
Install the ASP.NET Core Runtime Store. It comes bundled with the .NET Core SDK, which is why installing the SDK fixed this. You can also install just the store, without the SDK, by downloading it here: https://www.microsoft.com/net/download/all.
Don't use runtime store trimming. You can disable the trimming by setting this property in your csproj file.
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
You can also pass this in on command line.
dotnet publish /property:PublishWithAspNetCoreTargetManifest=false
Update: June 25, 2018
This answer only applies to ASP.NET Core 2.0 projects. In ASP.NET Core 2.1, there is no runtime store anymore.
Make sure your project have matching versions for Microsoft.NETCore.App (your project target framework) and Microsoft.AspNetCore.All (NuGet dependency included by default for .NET Core 2.0 projects) or Microsoft.AspNetCore.App (for .NET Core 2.1+ projects).
If you've ever updated your project target framework from .NET Core 2.0 to .Net Core 2.1, remember to update your NuGet dependencies accordingly, as they won't got updated automatically.
This problem is discussed in great detail here: https://github.com/dotnet/coreclr/issues/13542 It seems to be related to updating Microsoft.AspNetCore.All to version 2.0.3 or higher in your project.
Following the above discussion it seems that for some time a solution was to install the latest .NET Core SDK on the hosting machine. But at least with the current SDK 2.1.300 this did not solve the problem for me.
The solution for me was, to add the following line to the .csproj of my main project:
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
With this line ALL framework dependencies will be packed into the publishing folder! The published data of one of my projects grew from 15 Mb to 55 Mb with this switch. But at least this works, until there is a better solution.
I want to add something to @pallxk's answer. He gave me the hints to solve my issue. I'm familiar with using Visual Studio but not so familiar with VS Code.
With Visual Studio I had no issue but with VS Code as he mentioned I have to update the Nuget dependencies manually. I didn't know where to update them. They were located under my project folder in :
.vscode/launch.json
I have to update
"program": "${workspaceFolder}/Ghaseel.RestApi/bin/Debug/netcoreapp2.1/myProject.dll
to this
"program": "${workspaceFolder}/Ghaseel.RestApi/bin/Debug/netcoreapp2.2/myProject.dll
I hope this may help someone else to solve their issues.