A collection of powershell macros for Visual Studio.
- Clone the repository into %userprofile%\Documents\WindowsPowerShell:
C:\> git clone https://github.com/aaubry/VsPowershellLib.git %userprofile%\Documents\WindowsPowerShell
- Restart Visual Studio or execute the following command inside Package Manager Console:
PM> . "$($env:userprofile)\Documents\WindowsPowerShell\NuGet_profile.ps1"
Inside the Package Manager Console, execute the functions that are available inside the powershell files. When a function manipulates source code, the current type is the type that contains the location of the cursor in the currently open file.
- Place the cursor inside the desired type.
PM> Move-TypeToOwnFile
- Place the cursor inside the desired type.
PM> Add-Dependency IMyDependency
PM> Get-Projects | % { $_.ConfigurationManager.DeleteConfigurationRow('PreRelease') }
PM> Get-Projects | % { $_.Properties.Item("TargetFramework").Value = 262149 }
Downgrade-Package SixPack 1.2.3
This will uninstall any installed package named 'SixPack' with a version number greater than '1.2.3'. And install that version instead.
Increment the package version number of the specified project and the minor version of all dependent packages
Increment-PackageVersion MyProject Major
Increment-PackageVersion MyProject Minor
Increment-PackageVersion MyProject Build
This assumes that the package version is stored in a file named '_Package.cs' with the following structure:
internal static class Package
{
public const string Name = "MyPackage";
public const string Version_Major = "2";
public const string Version_Minor = "1";
public const string Version_Build = "0";
}
PM> Update-PackageQuickly SixPack 1.2.36
This command is simmilar to the Update-Package command, except that it is much quicker to run. It does NOT perform the following:
- Validate dependencies
- Update dependent packages
- Run install scripts
Use this command only if you know what you are doing.