我有一个使用 Visual Studio 2017 创建的 UWP 项目.它在这台机器(机器 1)上构建良好.
I have a UWP project that was created using Visual Studio 2017. It builds fine on this machine (machine 1).
但是,当我将项目复制到仅安装了 Visual Studio 2017 构建工具的机器(机器 2)并尝试使用 MSBuild 构建它时,我收到以下错误:
However, when I copy the project over to a machine (machine 2) where I only have the Visual Studio 2017 Build Tools installed, and attempt to build it using MSBuild, I get the following error:
C:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuild15.0BinMicrosoft.Common.CurrentVersion.targets
(1126,5): error MSB3644: The reference assemblies for framework ".NETCore,Version=v5.0" were not found. To resolve this
, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framewo
rk for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assemb
ly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted
for the framework you intend. [<path_to_my_UWP_project>UWP.csproj]
我怀疑我的 UWP.csproj 文件中的这一行需要 .NetCore v5.0:
I suspect the need for .NetCore v5.0 arises from this line in my UWP.csproj file:
<包参考包括="Microsoft.NETCore.UniversalWindowsPlatform" 版本="6.0.1"/>
< PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.0.1" />
我在机器 2 上构建之前进行了 nuget 恢复,我可以看到 microsoft.netcore.universalwindowsplatform 在 < 下成功恢复C_Users_me >/.nuget/packages,microsoft.netcore 也是如此.
I do a nuget restore before I build on machine 2, and I can see that microsoft.netcore.universalwindowsplatform successfully gets restored under < C_Users_me >/.nuget/packages, and so does microsoft.netcore.
然而,在机器 1 上,只有 microsoft.netcore.universalwindowsplatform 得到恢复,但它仍然可以通过 Visual Studio 正常构建.
On machine 1 however, only microsoft.netcore.universalwindowsplatform gets restored but it still builds fine via Visual Studio.
问题:为什么会出现此错误?如何解决此问题?
Question: Why am I getting this error and how do I fix the problem?
没有找到框架 .NETCore 的参考程序集,Version=v5.0
The reference assemblies for framework .NETCore, Version=v5.0 were not found
根据错误日志,您的机器 2 上似乎缺少 .NET 框架 SDK(.NET 核心,v5.0).您可以从以下目录检查它:
According to the error log, it seems you are missing the .NET framework SDK (. NET core, v5.0) on your machine 2. You can check the it from following directory:
C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETCorev5.0
要安装它,请确保安装以下单个组件:
To install it, make sure you are install following individual components:
如果您仍然有该错误,请尝试从机器复制目录 C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETCorev5.0
1 到机器 2.
If you still have that error, please try to copy the directory C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETCorev5.0
from machine 1 to machine 2.
希望这会有所帮助.
这篇关于未找到框架 .NETCore,Version=v5.0 的参考程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!