2015-01-27 66 views
1

我们有一个内部的NuGet包,它有一个readme.txt文件,我们希望在安装该包时显示该文件。要做到这一点,我们创建了看起来像包一个非常简单的init.ps1文件:NuGet init.ps1导致在调试台中进行调试

param($installPath, $toolsPath, $package, $project) 

$path = [System.IO.Path] 
$readmefile = $path::Combine($installPath, "content\Content\fonts\globalcons\readme.txt") 
$DTE.ItemOperations.OpenFile($readmefile) 

它做什么它应该并打开安装包时的readme.txt,但它也喷出以下在软件包管理器控制台中。

AutoHides    : False 
Caption    : readme.txt 
Collection   : {Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowBase, Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowBase, Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowBase, 
         Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowBase...} 
CommandBars   : 
ContextAttributes  : System.__ComObject 
DTE     : EnvDTE.DTEClass 
Document    : System.__ComObject 
HWnd     : 0 
Height    : 1039 
IsFloating   : False 
Kind     : Document 
Left     : 1951 
Linkable    : False 
LinkedWindowFrame  : Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowBase 
LinkedWindows   : 
Object    : System.__ComObject 
ObjectKind   : {8E7B96A8-E33D-11D0-A6D5-00C04FB67F6A} 
Project    : System.__ComObject 
ProjectItem   : System.__ComObject 
Selection    : System.__ComObject 
Top     : 106 
Type     : vsWindowTypeDocument 
Visible    : True 
Width     : 1432 
WindowState   : vsWindowStateMaximize 
HasBeenDeleted  : False 
Events    : Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowEvents 
VisibilityEvents  : Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowVisibilityEvents 
Rect     : 1951,106,1432,1039 
OutstandingEventCount : 0 

我知道这是造成它,因为如果我注释掉$DTE.ItemOperations.OpenFile($readmefile)线输出不包管理器控制台显示上述脚本。我无法弄清的是我做错了,导致输出每次都显示出来。

回答

1

您不需要init.ps1文件即可显示readme.txt文件。只要包的根文件夹中有一个readme.txt,NuGet本地支持此操作。注意NuGet只显示正在安装的软件包的readme.txt,而不是它所依赖的任何软件包。

但是,如果你要坚持你目前的做法,此方法将返回值转换到[void]

[void]$DTE.ItemOperations.OpenFile($readmefile) 
+0

或者$ DTE.ItemOperations.OpenFile($ README文件)| Out-Null – 2015-01-27 07:16:59

+0

我知道NuGet会在根文件夹中本地显示一个readme.txt文件。不幸的是,我们不想把它放在那里,我们想把它放在内容子文件夹中。 我会尝试虚空投射,看看会发生什么。 – 2015-01-27 16:22:19

+1

FWIW我们把自述放在两个地方。根作为readme.txt,所以它会自动出现在*和*内容中作为 ReadMe.txt,因此它出现在项目中。 – 2015-01-27 18:36:10