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

3

我正在尝试执行一个后期构建事件,该事件基于.nuspec文件构建nuget包。 我正在使用Visual Studio 2013。我的后期构建事件命令行是:

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 构建输出更改为诊断级别,并发现了以下信息:

>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)

如果我打开命令提示符并输入后构建事件命令,它能正常工作并构建NuGet包,没有任何问题。有什么想法吗?
2个回答

2
根据错误代码,你的问题应该与路径"C:\"的访问权限有关。请以管理员身份运行Visual Studio,确保它有足够的权限执行任何操作。
同时,请确保你当前的Windows用户也有足够的权限访问"C:\"。

1
我使用的解决方法是:
 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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接