可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am updating some applications from .NET Core 1.1 to 2.0. The apps work fine locally but after updating the Runtime on my linux VM and deploying, I am getting errors:
An assembly specified in the application dependencies manifest (foo.deps.json) was not found: package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1' path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'
This assembly was expected to be in the local runtime store as the application was published using the following target manifest files: aspnetcore-store-2.0.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetcore-store-2.0.0-win7-x86.xml
I think this is because the Runtime download does not generate the new runtime store folder needed when you use the Microsoft.AspNetCore.All package.
I can install the whole SDK instead and this works fine but I would prefer to continue to use the runtime only.
How do I generate the runtime cache manually without requiring the SDK on the production server?
回答1:
Update 12/4/2017
The ASP.NET Core runtime is now listed on the main downloads page for .NET Core. https://www.microsoft.com/net/download/linux
Update 10/3/2017
You can also install from a package feed.
See this link for instructions on adding the .NET Core package feeds for apt, yum, zypper, and others: https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.0-download.md#installing-net-core-on-linux
For example, if you wanted to install on Ubuntu 16, you would do this:
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list' sudo apt update sudo apt install aspnetcore-store-2.0.0
Original answer
You can download just the ASP.NET Core runtime store from here:
https://dist.asp.net/runtimestore/2.0.0/linux-x64/aspnetcore.runtimestore.tar.gz
You'll also need to download the .NET Core 2.0.0 runtime (see https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.0-download.md).
Extract both of these into the same folder, i.e. the "store" and "additionalDeps" folder from the runtime store archive should be parallel to the dotnet executable.
回答2:
Per the Runtime package store documentation, you can add the following to your .csproj file:
false
and the dependencies will be included when you use dotnet publish.
回答3:
For CentOS 7, the following worked for me:
Download and install the runtime:
mkdir -p /home/dotnet && tar zxf dotnet-runtime-2.0.0-linux-x64.tar.gz -C /home/dotnet
Download and install the SDK "This is a MUST to get Asp.Net Core store folder"
mkdir -p /home/dotnetSDK && tar zxf dotnet-sdk-2.0.0-linux-x64.tar.gz -C /home/dotnetSDK
Copy the store folder from the SDK to the runtime:
cp -rp /home/dotnetSDK/store /home/dotnet/store
Remove the SDK:
rm -dfr /home/dotnetSDK
set 'dotnet' to the PATH as explained in official docs (below is not permanent):
export PATH=$PATH:/home/dotnet
Now you can test and confirm its working:
# dotnet WebApiTest.dll info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest. info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58] Creating key {87d17c5a-120f-4204-b316-52027a264791} with creation date 2017-08-17 16:34:49Z, activation date 2017-08-17 16:34:49Z, and expiration date 2017-11-15 16:34:49Z. warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35] No XML encryptor configured. Key {87d17c5a-120f-4204-b316-52027a264791} may be persisted to storage in unencrypted form. info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39] Writing data to file '/root/.aspnet/DataProtection-Keys/key-87d17c5a-120f-4204-b316-52027a264791.xml'. Hosting environment: Production Content root path: /home/dotnet/WebApiTest Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down.
Finally: Compress/Archive /home/dotnet so that you won't need Steps 2, 3 & 4 in future deployments of same release-2.0.0.
回答4:
I experienced this issue because my dotnet SDK version was behind the Microsoft.AspNetCore.All packages version. Making the versions match (either by reverting the package or upgrading the host SDK) fixed my problem. Silly mistake to make but hopefully it will help someone.