Skip to content

PsTest NuGet package

knutkj edited this page Oct 2, 2012 · 6 revisions

The PsTest NuGet package is uploaded to the NuGet gallery. You may download it from here: http://nuget.org/packages/PsTest.

Package initialization

The PsTest NuGet package has an Init.ps1 script (about NuGet init scripts). The script will:

  1. Create a copy of the PsTest PowerShell module if not already done
  2. Automatically load the PsTest PowerShell module in Visual Studio

This happens:

  1. The first time a package is installed in a solution
  2. Every time the solution is opened

Test that the module has been loaded correctly by invoking Get-Module in Visual Studio NuGet Package Manager Console. The result should look something like:

ModuleType Name   ExportedCommands
---------- ----   ----------------
Script     NuGet  {Get-Package, Register-TabExpansion, Get-Project, Open-PackagePage...}
Binary     PsTest {Format-TestResult, Invoke-Test, New-Test}

Update/upgrade notice

After updating/upgrading the PsTest NuGet package you need to restart Visual Studio before the changes take effect.

About the copy

The PsTest PowerShell module is a binary module located in the tools folder and has the name pstest.dll. When you install the PsTest NuGet package a copy of pstest.dll is created. The copy is placed in temp\pstest\version\pstest.dll, where temp is equal to [System.IO.Path]::GetTempPath() and version is like 1.0.4653.42174. Here is a sample location:

C:\Users\knut\AppData\Local\Temp\PsTest\1.0.4654.251\pstest.dll

Why copy?

A .NET assembly may not be unloaded, and PowerShell locks an assembly when it is loaded. That means that it may not be deleted until the PowerShell host has been closed. The only way to close the NuGet Package Manager Console is to quit Visual Studio. When the copy gets loaded, the original assembly provided by the package is not locked, and may be deleted if you want to uninstall or upgrade the PsTest NuGet package.