命令" nuget pack ..."退出代码1

时间:2016-10-21 19:25:24

标签: asp.net visual-studio visual-studio-2013 nuget nuget-package

我'米'尝试执行基于.nuspec文件构建nuget包的post build事件。我使用的是Visual Studio 2013.我的post build事件命令行是:

nuget pack $(ProjectPath) -Symbols -Properties Configuration=$(ConfigurationName) -IncludeReferencedProjects

当我构建项目时,我收到以下错误:

The command "nuget pack C:\Users\user\Documebts\Code\BookProject\BookProject.Nuget\
BookProject.Nuget.csproj -Symbols -Properties Configuration=Debug 
-IncludeReferencedProjects" exited with code 1.

我不知道发生了什么 - 我将Visual Studio构建输出更改为Diagnostic并找到了:

>Using 'BookProject.nuspec' for metadata. (TaskId:44)
>Access to the path 'C:\BookProject.1.0.3.4.nupkg' is denied. (TaskId:44)
>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): error MSB3073: The command "nuget pack C:\Users\user\Documebts\Code\BookProject\BookProject.Nuget\  BookProject.Nuget.csproj -Symbols -Properties Configuration=Debug -IncludeReferencedProjects" exited with code 1.
>Done executing task "Exec" -- FAILED. (TaskId:44)
>Done building target "PostBuildEvent" in project "Miw.Mshdf.Net.Nuget.csproj" -- FAILED.: (TargetId:72)

如果我打开命令提示符并输入post build事件命令,它可以正常工作并构建nuget包而不会出现任何问题。有什么想法吗?

2 个答案:

答案 0 :(得分:1)

根据错误代码,您的问题应该与路径“C:\”的访问权限相关。请以管理员身份运行Visual Studio,以确保它具有足够的权限来执行任何操作。

确保您当前的Windows用户也有足够的权限访问“C:\”。

答案 1 :(得分:0)

我使用的解决方法是

 1. Right click on solution -> manage nuget package for solution
 2. On top there is text "install missing packages" -> click restore
 3. Also i manually given the package sources in -tools ->Nuget package manager -> 
 package sources
 4. run VS 2013 in administrator mode and gave permission to the required folders