"Error MSB4057 missing target pack" when building .netstandard nuget package

Thomas picture Thomas · Dec 7, 2016 · Viewed 14.9k times · Source

I'm trying to create a .netstandard nuget package following these instructions, using VS2017 RC. It builds fine, but when I try to create the package using

msbuild /t:pack /p:Configuration=Release

I get an error, that the target pack is not available in my solution:

error MSB4057: The target "pack" does not exist in the project.

I'm not really sure what to do with this message or where I should be looking to fix it. Any suggestions?

Answer

Thomas picture Thomas · Dec 26, 2016

Thanks to an answer on the MSDN forums I was able to get it working.

You'll have to specify your .csproj in the build command so it won't try to use the solution file (.sln).

msbuild "C:\Users\Administrator\Documents\visual studio 2017\Projects\AppLogger\AppLogger\AppLogger.csproj" /t:pack /p:Configuration=Release

Additionally I had to install the NuGet.Build.Tasks.Pack" package from NuGet.