Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 680
Thomas Avatar asked Dec 07 '16 15:12

Thomas


2 Answers

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.

like image 101
Thomas Avatar answered Sep 25 '22 07:09

Thomas


The command msbuild /t:pack /p:Configuration=Release is specifying that MSBuild should run the pack target within the build script. The error indicates that MSBuild isn't able to find that target within the build script (or one of it's imports). Have you double checked your prerequisites? You're either using the wrong build script or it's missing an <import> tag.

like image 1
Matt Ruwe Avatar answered Sep 25 '22 07:09

Matt Ruwe