如何从 init.ps1 中确定当前 运行 的 nuget 版本
How to determine the version of nuget that is currently running from inside init.ps1
在 nuget init 中。ps1 https://docs.nuget.org/create/creating-and-publishing-a-package#automatically-running-powershell-scripts-during-package-installation-and-removal 我如何访问当前 运行 版本的 nuget 以便在其上执行一些切换逻辑?
请注意,我 运行 在 Visual Studio 上下文中
获取 WmiObject -Class Win32_Product | Where-Object {$_.name -like "nuget"}
你还需要知道 VS 的版本,12 和 13 有 2 个版本的 VS。
您可以在 init.ps1 中获取 NuGet 程序集文件版本和产品版本:
// Returns the file version (e.g. 2.8.60723.765) as a string
$package.GetType().Assembly.GetName().Version.ToString()
// Returns the product version (e.g. 2.8.7) as a string
[System.Diagnostics.FileVersionInfo]::GetVersionInfo($package.GetType().Assembly.Location).ProductVersion
在 nuget init 中。ps1 https://docs.nuget.org/create/creating-and-publishing-a-package#automatically-running-powershell-scripts-during-package-installation-and-removal 我如何访问当前 运行 版本的 nuget 以便在其上执行一些切换逻辑?
请注意,我 运行 在 Visual Studio 上下文中
获取 WmiObject -Class Win32_Product | Where-Object {$_.name -like "nuget"} 你还需要知道 VS 的版本,12 和 13 有 2 个版本的 VS。
您可以在 init.ps1 中获取 NuGet 程序集文件版本和产品版本:
// Returns the file version (e.g. 2.8.60723.765) as a string
$package.GetType().Assembly.GetName().Version.ToString()
// Returns the product version (e.g. 2.8.7) as a string
[System.Diagnostics.FileVersionInfo]::GetVersionInfo($package.GetType().Assembly.Location).ProductVersion