Reputation: 379
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 :
Upvotes: 2
Views: 2579
Reputation: 51073
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.
Upvotes: 2
Reputation: 379
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://learn.microsoft.com/en-us/nuget/reference/nuspec
A default nuspec is found here https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package
Upvotes: 0