Giter VIP home page Giter VIP logo

posh-vs's Introduction

posh-vs

Makes Visual Studio command line tools available in PowerShell. Supports Visual Studio 2015 and later versions.

Usage

Install posh-vs from the PowerShell Gallery:

PS> Install-Module posh-vs -Scope CurrentUser

Change your PowerShell profile to automatically import Visual Studio developer environment.

PS> Install-PoshVs

Start a new PowerShell session or reload your profile:

PS> . $profile

Use Visual Studio command line tools in PowerShell:

PS> msbuild /?

How it works

Install-PoshVs adds an Import-VisualStudioEnvironment call to the PowerShell profile. It will import the environment variables set by the VsDevCmd.bat of the latest version of Visual Studio installed on your computer. If multiple instances of Visual Studio are installed, Import-VisualStudioEnvironment will use whichever instance happens to be listed first.

To use a specific instance of Visual Studio, manually change your profile to import a specific batch file.

Import-BatchEnvironment 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat'

Uninstall

Remove posh-vs from your PowerShell profile.

PS> Uninstall-PoshVs
PS> exit

Uninstall posh-vs from your computer.

PS> Uninstall-Module posh-vs

Develop

Build status

Install pre-requisites.

PS> .\init.ps1

Ctrl+Shift+B to build and test in VSCode or

PS> Invoke-psake

F5 to debug tests in VSCode.

Credits

posh-vs was inspired by Alen Mack, StackOverflow contributors and posh-git.

posh-vs's People

Contributors

leon99 avatar olegsych avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

posh-vs's Issues

posh-vs adds 1s to powershell startup

On a system with nothing but Visual Studio 2019 installed, posh-vs adds 1 second (well over 1s on cold start) to powershell startup. It invokes VsDevCmd.bat which in turn spawns a ton of cmd.exe processes just to call reg.exe. This is almost entirely the fault of vsdevcmd, but it would be nice to.. just do something better :| Perhaps pull in the common setup into this module itself (making direct calls to query the registry instead of going through reg.exe), and only call vsdevcmd if explicitly asked to import the more exact user environment.

image

Import-VisualStudioEnvironment is cumulative

I tend to reload my profile with .$profile on occasion. I started noticing this error:

The input line is too long.
The syntax of the command is incorrect.

$env:path will show redundant lines added by Import-VisualStudioEnvironment.

This may or may not be considered a bug, but the workaround is something like this:

if (!(Test-Path env:DevEnvDir)) {Import-VisualStudioEnvironment}

Allow passing arguments to vsdevcmd.bat

It would be nice if it was possible to forward arguments from Import-VisualStudioEnvironment to vsdevcmd.bat. A typical use case would be to pass -arch=amd64 to it. Thanks!

Import-BatchEnvironment: 'The input line is too long'

I am importing the VS2019 x64 environment from my PowerShell profile like this:

Import-BatchEnvironment 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat'

After updating to VS2019 v16.2, the following warning appears on startup:

The input line is too long.
The syntax of the command is incorrect.

Not sure what changed between 16.1 and 16.2 to cause this.

VS 2017

The readme says:

Makes Visual Studio 2015 command line tools available in PowerShell.

Is there any chance of making this support VS 2017 as well?

Install-PoshVs should respect encoding

My profile is utf-8 but it converted it to UTF-16 LE. It actually made the file unreadable the first time I tried it, but I haven't been able to reproduce that.

An alternative would be to just say something like this during module import: "Hey, go add this to your profile - Import-Module posh-vs; Import-VisualStudioEnvironment"

Cryptic error message when Visual Studio is not installed

  • Install-PoshVs succeeds silently when Visual Studio is not installed.
  • Import-VisualStudioEnvironment displays a cryptic error message if Visual Studio is not installed.
Import-BatchEnvironment : Cannot bind argument to parameter 'batchFile' because it is an empty string.
At C:\Users\olegsych\Documents\WindowsPowerShell\Modules\posh-vs\0.2.1\posh-vs.psm1:62 char:29
+     Import-BatchEnvironment $batchFile
+                             ~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Import-BatchEnvironment], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Import-BatchEnvironment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.