我是新来的Nuget,我试图找出上传我的第一个包。到目前为止,一切都很顺利。但是,我试图设置CopyToOutputDirectory的一些内容文件,我想住在Lib子文件夹中。我的目录看起来是这样的:Nuget - 在子文件夹中的内容上设置CopyToOutputDirectory
│ Readme.txt
│ MyPackage.nupkg
│ MyPackage.nuspec
│
├───content
│ └───Lib
│ native1.dll
│ native2.dll
│ native3.dll
│ native4.dll
│
├───lib
│ MyActualAssembly.dll
│
└───tools
Install.ps1
从阅读this StackOverflow question和一些额外的阅读,我已经把一个Install.ps1,看起来像这样:
param($installPath, $toolsPath, $package, $project)
$project.ProjectItems.Item("Lib\native1.dll").Properties.Item("CopyToOutputDirectory").Value = 1
$project.ProjectItems.Item("Lib\native2.dll").Properties.Item("CopyToOutputDirectory").Value = 1
$project.ProjectItems.Item("Lib\native3.dll").Properties.Item("CopyToOutputDirectory").Value = 1
$project.ProjectItems.Item("Lib\native4.dll").Properties.Item("CopyToOutputDirectory").Value = 1
I 1成荫的各种操作看看它是否帮助我理解了这个问题,但它与其他答案几乎相同。
从我的测试中,Install.ps1在查找文件本身时遇到了一些麻烦。当它安装包后运行时,我收到以下错误:
Exception calling "Item" with "1" argument(s): "The parameter is incorrect. (Exception from HRESULT: 0x80070057
(E_INVALIDARG))"
At C:\...\tools\Install.ps1:3 char:1
+ $project.ProjectItems.Item("Lib\native1.dll").Properties.Item("CopyToOutputDirect ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
Exception calling "Item" with "1" argument(s): "The parameter is incorrect. (Exception from HRESULT: 0x80070057
(E_INVALIDARG))"
At C:\...\tools\Install.ps1:4 char:1
+ $project.ProjectItems.Item("Lib\native2.dll").Properties.Item("Copy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
Exception calling "Item" with "1" argument(s): "The parameter is incorrect. (Exception from HRESULT: 0x80070057
(E_INVALIDARG))"
At C:\...\tools\Install.ps1:5 char:1
+ $project.ProjectItems.Item("Lib\native3.dll").Properties.Item("CopyToOutputDirec ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
Exception calling "Item" with "1" argument(s): "The parameter is incorrect. (Exception from HRESULT: 0x80070057
(E_INVALIDARG))"
At C:\...\tools\Install.ps1:6 char:1
+ $project.ProjectItems.Item("Lib\native4.dll").Properties.Item("CopyToOut ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
而且,正如你所期望的,所有的文件都有各自CopyToOutputDirectory设置设置为不复制,添加默认。
我该如何解决这个问题?是否有不同的语法来访问ps脚本中的子文件夹?还是我完全错过了这些错误消息的重点?
对不起,最后的评论,我刚刚重读你的答案,我错过了第一个位置,你先得到了Lib,然后是dll。从使用get-project想法在PM控制台中播放,它看起来是正确的。我现在就试试吧! – 2013-03-18 18:34:15
宾果! Visual Studio错误地告诉我脚本执行被禁用后,我重新启动,现在导入运行顺利,文件的属性正确设置。谢谢。 – 2013-03-18 19:12:35