Ash*_*Ash 18 c# msbuild visual-studio .net-core
我有一个使用 Visual Studio 2017 创建的 UWP 项目。它在这台机器(机器 1)上构建得很好。
但是,当我将项目复制到仅安装了 Visual Studio 2017 构建工具的机器(机器 2)并尝试使用 MSBuild 构建它时,出现以下错误:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.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]
Run Code Online (Sandbox Code Playgroud)
我怀疑我的 UWP.csproj 文件中的这一行需要 .NetCore v5.0:
< PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" 版本="6.0.1" />
我在机器 2 上构建之前进行了 nuget 恢复,我可以看到 microsoft.netcore.universalwindowsplatform 在 < C_Users_me >/.nuget/packages 下成功恢复,microsoft.netcore 也是如此。
然而,在机器 1 上,只有 microsoft.netcore.universalwindowsplatform 被恢复,但它仍然通过 Visual Studio 构建良好。
问题:为什么会出现此错误以及如何解决此问题?
Fra*_*tal 22
我收到了同样的错误信息。解决方案是安装最新版本的 Visual Studio 2019。我的计算机上安装了 16.6 版。我需要安装 16.8 版。一旦我完成安装,错误消息就消失了。
此问题的最初原因:我从另一个人那里收到了 VS C# 解决方案。显然,解决方案中有一些内容表明它需要一些库 (.NETFramework v=5.0),而该库不在 16.4 中,而是在 16.8 中。
VS错误信息上的帮助说明没有帮助;目前没有.NETFramework,版本=v5.0。只有 .NET Core Version=5.0 或 .NetFramework Version=v4.8
这个gitHub帖子引导我找到正确的解决方案。
您需要使用 Visual Studio 2019 16.8 Preview 2 或更新版本才能使用 .NET 5 Preview 8。.NET 5 在此处下载https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-预览
我正在追寻完全相同的问题,但就我所见,我安装了正确的 SDK。事实证明,我自己在根目录中放置了一个 global.json,并将 SDK 版本固定为 3.1.404,从而导致了这个问题。dotnet 遵循 global.json 设置,因此无法找到 5.0 的参考程序集。删除 global.json 为我解决了这个问题。
找不到框架 .NETCore、Version=v5.0 的参考程序集
根据错误日志,您的机器上似乎缺少.NET Framework SDK(.NET core,v5.0)2。您可以从以下目录检查它:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v5.0
Run Code Online (Sandbox Code Playgroud)
要安装它,请确保安装以下各个组件:
如果仍然出现该错误,请尝试将目录C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v5.0从计算机 1 复制到计算机 2。
希望这可以帮助。