本文介绍了错误 MSB4057:目标“Pack"项目中不存在 - Visual Studio for Mac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 https://github.com/PandaWood/Simple-MAPI 上有一个项目.网络

我一直使用 Build |创建 Nuget 包 - 这总是有效的 - 创建一个 nuget 包.

I have always used Build | Create Nuget Package - which always worked - to create a nuget package.

我在 Visual Studio for Mac 上构建它(使用 Mono)

I build it on Visual Studio for Mac (using Mono)

截至今天(假设 Visual Studio 中的更新导致了此问题)- 我收到上述错误(目标Pack"不存在)

As of today (assuming an update in Visual Studio has caused this) - I get the error above (the target "Pack" does not exist")

我认为这是一个错误,因为自从它起作用以来我没有更改任何代码或配置.

I presume this is a bug since I changed no code or configuration since this worked.

关于如何重新开始工作的任何建议?在这种情况下,错误对我来说毫无意义

Any advice on how to get this working again?The error makes no sense to me in this context

=== Visual Studio Enterprise 2017 for Mac ===

Version 7.3.3 (build 12)
Runtime:
    Mono 5.4.1.7 (2017-06/e66d9abbb27) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)

    Package version: 504010007

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    2.0.0
    1.1.2
    1.0.5
SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks
SDK Versions:
    2.0.0
    1.0.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Mac ===

Version: 4.0.0.216 (Visual Studio Enterprise)

=== Build Information ===

Release ID: 703030012
Git revision: b07492f1e48be596bad92dc4b7a3bc2d128ed0f9
Build date: 2018-01-30 13:15:55-05
Xamarin addins: 7c8f967d67207118dd99a1d0cc9c228045b30c5f
Build lane: monodevelop-lion-d15-5

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
    Thu Jan 11 22:59:40 PST 2018
    root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64

推荐答案

问题是项目文件中 NuGet.Build.Packaging.props 和 NuGet.Build.Packaging.targets 的导入不正确.导入当前指向 src/Mapi/packages 目录.

The problem is that the imports for the NuGet.Build.Packaging.props and NuGet.Build.Packaging.targets are incorrect in your project file. The imports currently are pointing to the src/Mapi/packages directory.

<Import Project="packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.props" Condition="Exists('packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.props')" />

<Import Project="packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.targets" Condition="Exists('packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.targets')" />

您的解决方案位于 GitHub 存储库的根目录,因此软件包将在那里恢复,而不是在 Mapi 文件夹中.因此,按如下方式更改路径应该可以解决 Pack 目标不可用的问题:

Your solution is at the root of the GitHub repository so the packages are being restored there and not in the Mapi folder. So changing the paths as follows should fix the problem with the Pack target not being available:

<Import Project="..\..\packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.props" Condition="Exists('..\..\packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.props')" />

<Import Project="..\..\packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.targets" Condition="Exists('..\..\packages\NuGet.Build.Packaging.0.1.248\build\NuGet.Build.Packaging.targets')" />

这篇关于错误 MSB4057:目标“Pack"项目中不存在 - Visual Studio for Mac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:08