Mark
Mark

Reputation: 11750

NuGet pack fails with "Unable to find '@(_OutputPathItem->'%(FullPath)..."

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>

When I run NuGet pack with this command line:

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

I get this error:

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)

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

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.

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.

Upvotes: 26

Views: 10882

Answers (3)

StingyJack
StingyJack

Reputation: 19489

This could also have the same error if the .NET Framework version is set to 4.0 for the assembly.

Upvotes: 0

llewellyn falco
llewellyn falco

Reputation: 2351

We had the same problem. adding

-Prop Platform=AnyCPU

to the command line made it work for us.

Upvotes: 58

Mark
Mark

Reputation: 11750

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.

I have created an issue for the NuGet project team here: https://nuget.codeplex.com/workitem/4012

Upvotes: 1

Related Questions