NuGet - install.ps1 没有被调用
我正在尝试创建我的第一个 NuGet 包。我不知道为什么我的 install.ps1 脚本没有被调用。这是
--Package
|
- MyPackage.nuspec
- tools
|
- Install.ps1
- some_xml_file
我使用此命令行构建包的 目录结构 nuget.exe pack MyPackage.nuspec
当我从 VS 包管理器控制台安装包时 install.ps1 不会被调用。
我想也许我在脚本中遇到了一些错误,这就是原因,所以我注释掉了所有内容,但
param($installPath, $toolsPath, $package, $project)
"ECHO"
我没有看到 ECHO 出现在包管理器控制台中。有什么问题吗?
I'm trying to create my first NuGet package. I don't know why my install.ps1 script does not get called. This is directory structure
--Package
|
- MyPackage.nuspec
- tools
|
- Install.ps1
- some_xml_file
I build package using this command linenuget.exe pack MyPackage.nuspec
When I Install-Package from VS Package Manager Console install.ps1 does not get called.
I thought that maybe I had some errors in script and that's the reason so I commented out everything but
param($installPath, $toolsPath, $package, $project)
"ECHO"
But I don't see ECHO appearing in Package Manager Console. What can be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
仅当
\lib
和/或\content
文件夹中有内容时才会调用Install.ps
,而不是“仅工具”不过,包裹。请参阅此处:请改用
Init.ps1
(但是,每次打开解决方案时都会执行此操作)。Install.ps
will only be invoked if there is something in the\lib
and/or\content
folder, not for a "tools only" package, though. See here:Use the
Init.ps1
instead (however, this will be executed every time the solution is opened).在 v3 中不再调用
Install.ps1
(和Uninstall.ps1
),但您可以使用Init.ps1
。请参阅此处:Install.ps1
(andUninstall.ps1
) are no longer called in v3, but you can useInit.ps1
. See here:有时,安装脚本的替代方案可以是包目标文件。该目标文件会自动编织到项目文件(csproj,...)中,并通过构建进行调用。
要允许 Nuget 找到此目标文件并将其编入其中,必须执行以下两件事:
build
在包的顶层如果您想将某些内容复制到输出文件夹(例如一些其他二进制文件,如本机 DLL),您可以将这些二进制文件放入文件夹
binaries< 下的包中/code> 并在中使用此片段用于复制的目标文件:
An alternative to the install script can sometimes be a package targets file. This targets file is automatically weaved into the project file (csproj, ...) and gets called with a build.
To allow Nuget to find this targets file and to weave it in, these two things are mandatory:
<package-name>.targets
build
at the top level of the packageIf you like to copy something to the output folder (e.g. some additional binaries, like native DLLs) you can put these binaries into the package under folder
binaries
and use this fragment in the targets file for the copying: