“Error MSB4057 missing target pack” when building .netstandard nuget package

纵然是瞬间 提交于 2019-12-07 01:06:01

问题


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?


回答1:


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.




回答2:


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.




回答3:


You must import targets before using them. In project file before using targets write:

  <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />


来源:https://stackoverflow.com/questions/41021034/error-msb4057-missing-target-pack-when-building-netstandard-nuget-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!