【问题标题】:NuGet init.ps1 causing debug into in consoleNuGet init.ps1 导致在控制台中进行调试
【发布时间】:2015-01-27 00:16:21
【问题描述】:

我们有一个内部 NuGet 包,其中包含一个我们希望在安装包时显示的 readme.txt 文件。为此,我们为包创建了一个非常简单的 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) 行,输出不会显示在包管理器控制台中。我无法弄清楚的是我做错了什么导致每次都显示输出。

【问题讨论】:

    标签: powershell visual-studio-2013 nuget-package


    【解决方案1】:

    您不需要 init.ps1 文件来显示 readme.txt。只要包的根文件夹中有 readme.txt,NuGet 本身就支持这一点。注意 NuGet 仅显示正在安装的包的 readme.txt,而不显示它所依赖的任何包。

    但是,如果您想坚持当前的方法,请将此方法的返回值转换为 [void]

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

    【讨论】:

    • 我了解 NuGet 会在根文件夹中原生显示 readme.txt。不幸的是,我们不想把它放在那里,我们想把它放在内容子文件夹中。我会试试 void cast 看看会发生什么。
    • FWIW 我们将自述文件放在两个地方。根为 readme.txt,因此它会自动出现在 的内容中,如 ReadMe.txt 因此它出现在项目中。
    猜你喜欢
    • 1970-01-01
    • 2016-04-03
    • 1970-01-01
    • 1970-01-01
    • 2019-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-22
    相关资源
    最近更新 更多