简体   繁体   中英

TFS Automatic Build : Nuget Pack fail with code(1)

I'm trying to implement automatic builds in TFS for a WPF project. The automatic build works great, but I can't prepare a nuget package with the project.

Here is my build process in TFS :

失败后捕获构建过程

If I remove NuGet pack and NuGet push, it works without trouble.

Here is the messages I get by 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.)

In the logs, it says it doesn't find 'Extended.Wpf.Toolkit.3.3.0.nupkg'. I do use NuGet Restore before my build, and the build is correct. In the logs of TFS, I can see it uses 'Extended.Wpf.Toolkit.3.3.0'

I already tried to add -Prop Platform=AnyCPU on the commands used by NuGet for packing but it didn't change anything. I ran the command on my computer and it worked.

Here are the pages I already checked in my search of a fix :

You may lack the configuration when you do the pack and select .csproj file.

If you have selected the $(BuildConfiguration) as your Configuration to package option.

You have to also specify the value of BuildConfiguration

在此处输入图片说明

Take a look at the difference of using **\\*.csproj and **\\*.nuspec

Specify .csproj files (for example, **\\*.csproj ) for simple projects. In this case:

  • The packager compiles the .csproj files for packaging.
  • You must specify Configuration to Package (see below).
  • You do not have to check in a .nuspec file. If you do check one in, the packager honors its settings and replaces tokens such as $id$ and $description$.

Specify .nuspec files (for example, **\\*.nuspec ) for more complex projects, such as multi-platform scenarios in which you need to compile and package in separate steps. In this case:

  • The packager does not compile the .csproj files for packaging.
  • Each project is packaged only if it has a .nuspec file checked in.
  • The packager does not replace tokens in the .nuspec file (except the element, see Use build number to version package, below). You must supply values for elements such as <id/> and
    <description/> . The most common way to do this is to hardcode the
    values in the .nuspec file.

Finally I was able to fix this

The workaround I found was to add a .nuspec file to my project. I changed the NuGet pack task to use the nuspec instead of the csproj.

Everything worked fine after that (as far as I can see) except for the package icon which is not visible yet. But that's another story !

The reference for nuspec is here https://docs.microsoft.com/en-us/nuget/reference/nuspec

A default nuspec is found here https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM