我正在尝试在macOS(10.14.3)上设置Visual Studio 2019,但是在尝试构建默认的Web MVC项目时出现此依赖项错误:
Target _CheckForNETCoreSdkIsPreview:
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
Target ResolvePackageAssets:
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: The "ResolvePackageAssets" task failed unexpectedly.
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: System.TypeLoadException: Could not resolve type with token 0100003f from typeref (expected class 'NuGet.Packaging.Core.PackageDependency' in assembly 'NuGet.Packaging, Version=5.0.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35')
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter.GetPlatformPackageExclusions () [0x000d7] in <9524e6fbf1724027a475d15b01fab866>:0
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheWriter..ctor (Microsoft.NET.Build.Tasks.ResolvePackageAssets task, System.IO.Stream stream) [0x0009b] in <9524e6fbf1724027a475d15b01fab866>:0
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheReader.CreateReaderFromDisk (Microsoft.NET.Build.Tasks.ResolvePackageAssets task, System.Byte[] settingsHash) [0x0003a] in <9524e6fbf1724027a475d15b01fab866>:0
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets+CacheReader..ctor (Microsoft.NET.Build.Tasks.ResolvePackageAssets task) [0x00015] in <9524e6fbf1724027a475d15b01fab866>:0
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups () [0x00000] in <9524e6fbf1724027a475d15b01fab866>:0
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore () [0x00018] in <9524e6fbf1724027a475d15b01fab866>:0
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute () [0x00000] in <9524e6fbf1724027a475d15b01fab866>:0
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-10/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:573
/usr/local/share/dotnet/sdk/3.0.100-preview3-010431/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(228,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x00212] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-10/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:784
Done building target "ResolvePackageAssets" in project "TestingApp.csproj" -- FAILED.
Done building project "TestingApp.csproj" -- FAILED.
Build FAILED.
我也尝试使用dotnet run
从终端运行它,并且可以运行,但是我不能使用Visual Studio。谢谢。
答案 0 :(得分:13)
只需从项目中删除 BIN 和 OBJ 目录并重建即可。
答案 1 :(得分:0)
答案 2 :(得分:0)
根本原因:-
由于Nuget软件包版本兼容性在项目(共享项目,iOS项目,Android项目)中不同而导致的此错误。
解决方案:-
1。更新每个Nuget软件包,其中会在nuget软件包的前面显示更新版本。
2。清洁溶液。
3.Build Solution,
答案 3 :(得分:0)
也有同样的问题。 原因是,在主项目Build-General的Project Options中,目标框架已更改,不知道为什么。 对于我的项目,它应该是Xamarin.Mac Full Net 4.7.2,但是无论出于什么原因,现在它都是Xamarin.Mac Modern。 变回完整,一切都很好。
我记得,不久前又发生了另一次VS Mac更新。 作为Xamarin的用户,在此期间,我知道很多Xamarin-Update都在破坏事情,以前还不错。
答案 4 :(得分:0)
在您的项目/库中尝试以下步骤:
它对我有用。
答案 5 :(得分:0)
只需重建项目。它会自动清理和恢复所需的文件,然后构建项目
答案 6 :(得分:0)
使用提升的权限打开 Visual Studio(以管理员身份运行) 然后尝试清理和重建。
答案 7 :(得分:-1)
对我来说,这里的解决方案都不起作用,但 Visual Studio 软件更新完成了这项工作。
这通常发生在 Mono 的 MSBuild
(Visual Studio 正在使用它来构建项目)不支持您正在使用的 SDK
版本时,它可以生成许多包 (例如)为 .NET 5
构建并要求 Nuget 5 Packaging
无法使用 MSBuild
构建。
您通常会收到以下错误之一:
Microsoft.NET.Sdk.targets(124, 5): [MSB4018] The "PACKAGE_NAME" task failed unexpectedly.
Microsoft.PackageDependencyResolution.targets(234, 5): [MSB4018] The "ResolvePackageAssets" task failed unexpectedly.
因此,安装或更改为兼容的 MSBuild
,或者更改 SDK
通常应该可以解决问题。
您可以在这里找到更多有用的信息: