NuGet 包因“无法找到 '@(_OutputPathItem->'%(FullPath)..."而失败) [英] NuGet pack fails with "Unable to find '@(_OutputPathItem->'%(FullPath)..."

查看:52
本文介绍了NuGet 包因“无法找到 '@(_OutputPathItem->'%(FullPath)..."而失败)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试我的第一个 NuGet 包,但遇到了一些麻烦.我有一个相当简单的项目和一个非常简单的 .nuspec 文件:

I'm attempting my first NuGet package, and I'm running into some trouble. I have a fairly simple project, and a very simple .nuspec file:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <description>$description$</description>
  </metadata>
</package>

当我使用此命令行运行 NuGet 包时:

When I run NuGet pack with this command line:

NuGet.exe pack mylibrary.csproj -Verbosity detailed -Properties Configuration=Debug

我收到此错误:

NuGet.CommandLineException: Unable to find '@(_OutputPathItem->'%(FullPath)mylibrary.dll')'. Make sure the project has been built.
   at NuGet.Commands.ProjectFactory.BuildProject()
   at NuGet.Commands.ProjectFactory.CreateBuilder(String basePath)
   at NuGet.Commands.PackCommand.BuildFromProjectFile(String path)
   at NuGet.Commands.PackCommand.BuildPackage(String path)
   at NuGet.Commands.PackCommand.ExecuteCommand()
   at NuGet.Commands.Command.Execute()
   at NuGet.Program.Main(String[] args)

输出文件肯定在 bin\Debug 文件夹中,但 NuGet 显然没有找到它们.

The output files are definitely in the bin\Debug folder, but NuGet is apparently not finding them.

这显然只有在 .csproj 文件的 ToolsVersion 设置为 3.5 或更低时才会发生.将 ToolsVersion 设置为 4.0 即可解决问题.

This apparently only happens when the .csproj file's ToolsVersion is set to 3.5 or lower. Setting ToolsVersion to 4.0 resolves the problem.

似乎 MSBuild 3.5 在调用 _project.GetPropertyValue("TargetPath") (ProjectFactory.cs ~296) 时返回未扩展的属性值,其中 MSBuild 4.0 返回扩展的属性值.

It seems that MSBuild 3.5 returns the unexpanded property value when calling _project.GetPropertyValue("TargetPath") (ProjectFactory.cs ~296), where MSBuild 4.0 returns the expanded property value.

推荐答案

我们遇到了同样的问题.添加

We had the same problem. adding

-Prop Platform=AnyCPU

命令行使其对我们有用.

to the command line made it work for us.

这篇关于NuGet 包因“无法找到 '@(_OutputPathItem->'%(FullPath)..."而失败)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆