TFS自动生成:Nuget Pack失败,代码为(1)

TFS自动生成:Nuget Pack失败,代码为(1),tfs,nuget,azure-devops,nuget-package,Tfs,Nuget,Azure Devops,Nuget Package,我正在尝试为WPF项目在TFS中实现自动构建。 自动构建工作得很好,但我无法为项目准备nuget包 以下是我在TFS中的构建过程: 如果我移除NuGet pack和NuGet push,它就可以正常工作 以下是我通过TFS获得的信息: Found packages.config. Using packages listed as dependencies NuGet.CommandLine.CommandLineException: Unable to find 'Extended.Wpf.T

我正在尝试为WPF项目在TFS中实现自动构建。 自动构建工作得很好,但我无法为项目准备nuget包

以下是我在TFS中的构建过程:

如果我移除NuGet pack和NuGet push,它就可以正常工作

以下是我通过TFS获得的信息:

Found packages.config. Using packages listed as dependencies
NuGet.CommandLine.CommandLineException: Unable to find 'Extended.Wpf.Toolkit.3.3.0.nupkg'. Make sure the project has been built.
   at NuGet.CommandLine.ProjectFactory.AddDependencies(Dictionary`2 packagesAndDependencies)
   at NuGet.CommandLine.ProjectFactory.ProcessDependencies(PackageBuilder builder)
   at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded, PackageBuilder builder)
   at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
   at NuGet.CommandLine.PackCommand.ExecuteCommand()
   at NuGet.CommandLine.Command.ExecuteCommandAsync()
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
Unable to find 'Extended.Wpf.Toolkit.3.3.0.nupkg'. Make sure the project has been built.
##[error]The nuget command failed with exit code(1) and error(Unable to find 'Extended.Wpf.Toolkit.3.3.0.nupkg'. Make sure the project has been built.)
在日志中,它说没有找到“Extended.Wpf.Toolkit.3.3.0.nupkg”。我在构建之前确实使用了NuGet Restore,而且构建是正确的。在TFS的日志中,我可以看到它使用了“Extended.Wpf.Toolkit.3.3.0”

我已经尝试在NuGet用于打包的命令上添加
-Prop Platform=AnyCPU
,但它没有改变任何东西。我在我的电脑上运行了这个命令,它成功了

以下是我在搜索修复程序时已检查的页面:


我终于能够解决这个问题

我找到的解决方法是将.nuspec文件添加到我的项目中。我将NuGet pack任务更改为使用nuspec而不是csproj

在那之后一切都很好(就我所见),除了包图标还不可见。但那是另一个故事

这里是nuspec的参考资料


在这里可以找到默认的nuspec

当您进行打包并选择
.csproj
文件时,可能缺少配置

如果选择了
$(BuildConfiguration)
作为要打包的配置选项

您还必须指定BuildConfiguration的值

看看使用
***.csproj
***.nuspec

指定.csproj文件(例如,
***.csproj
)用于简单 项目。在这种情况下:

  • 打包程序编译用于打包的.csproj文件
  • 您必须指定包的配置(见下文)
  • 您不必签入.nuspec文件。如果您确实签入了一个,打包机将接受其设置并替换令牌,如$id$和 $description$
指定.nuspec文件(例如,
***.nuspec
)以获得更复杂的 项目,例如您需要 在单独的步骤中编译和打包。在这种情况下:

  • 打包程序不会编译用于打包的.csproj文件
  • 仅当每个项目签入了.nuspec文件时,才会对其进行打包
  • 打包程序不会替换.nuspec文件中的令牌(元素除外,请参阅使用内部版本号转换打包, 下)。必须为元素提供值,例如

    。最常见的方法是对
    .nuspec
    文件中的值

由于nuspec解决方案目前有效,我不会更改它。但是对于我的下一个包,我一定会尝试这种方法。