NuGet包失败,"无法找到"@(_ OutputPathItem - >'%(FullPath)..."

Mar*_*ark 25 nuget

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

<?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>
Run Code Online (Sandbox Code Playgroud)

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

NuGet.exe pack mylibrary.csproj -Verbosity detailed -Properties Configuration=Debug
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

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)
Run Code Online (Sandbox Code Playgroud)

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

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

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

lle*_*lco 57

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

-Prop Platform=AnyCPU
Run Code Online (Sandbox Code Playgroud)

到命令行使它对我们有用.

  • 有没有办法从nuspec中完成这项工作,而无需从命令行中指定它? (3认同)
  • 还有一种语法要分享:`-Prop Platform = x86 -Prop Configuration = Release` (3认同)
  • 在最新版本的(2.7)中,似乎-Prop现在称为-Properties.对我来说,一个工作的例子是:nuget pack my.csproj -Properties"Platform = AnyCpu; version = 1.0; configuration = Debug" (2认同)

Mar*_*ark 1

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

我在这里为 NuGet 项目团队创建了一个问题:https ://nuget.codeplex.com/workitem/4012