Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 309
Mark Avatar asked Feb 05 '14 16:02

Mark


Video Answer


1 Answers

We had the same problem. adding

-Prop Platform=AnyCPU 

to the command line made it work for us.

like image 164
llewellyn falco Avatar answered Oct 15 '22 19:10

llewellyn falco