Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Conversation

ph1ll
Copy link
Contributor

@ph1ll ph1ll commented Jul 21, 2015

Using the new release of VS 2015 an error is thrown in the DNVM output window when VS attempts to install a runtime when none was found in the user .dnx folder.

Invoke-Command : The term 'x86' is not recognized as the name of a cmdlet, 
Invoke-Command : The term 'x86' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or 
function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
if a path was included, verify that the path is correct and try again.
At C:\Program Files\Microsoft DNX\Dnvm\dnvm.ps1:1488 char:9
+         Invoke-Command ([ScriptBlock]::Create("dnvm-$cmd $cmdargs"))
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [Invoke-Command], C 
   ommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Co 
   mmands.InvokeCommandCommand

This is caused by the script attempting to execute:

dnvm-install C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg

Naturally this path should be quoted. This MR resolves this by quoting the $cmdargs variable, resulting in the execution of:

dnvm-install "C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg"

And VS is once again happy.

A side effect of this bug (VS not being able to load DNX) is that all DNX projects are loaded as "Miscellaneous Files" and no intellisense is provided and builds within VS are broken. Restarting VS following copying the patched dnvm.ps1 to C:\Program Files\Microsoft DNX\Dnvm resolves this.

@dnfclas
Copy link

dnfclas commented Jul 21, 2015

Hi @ph1ll, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. Real humans will now evaluate your PR.

TTYL, DNFBOT;

@ph1ll
Copy link
Contributor Author

ph1ll commented Jul 21, 2015

The tests are failing for this, but it also seems they were failing prior to the change. I am not familiar with this script so not sure how/where else this is called and what the expected format for $cmdargs is. It may be better to leave this and instead have the issue fixed in VS when VS attempts to install DNX.

@ph1ll
Copy link
Contributor Author

ph1ll commented Jul 22, 2015

Closing as causes issues with other dnvm commands

@ph1ll ph1ll closed this Jul 22, 2015
@davidfowl
Copy link
Member

/cc @PradeepKadubandi @muratg

@ph1ll
Copy link
Contributor Author

ph1ll commented Jul 22, 2015

Ok, following a bit more debugging, the steps to reproduce this problem in PowerShell are:

dnvm install "C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg"

This results in

Invoke-Command : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Program Files\Microsoft DNX\Dnvm\dnvm.ps1:1488 char:9
+         Invoke-Command ([ScriptBlock]::Create("dnvm-$cmd $cmdargs"))
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [Invoke-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeCommandCommand

As Invoke-Command ([ScriptBlock]::Create("dnvm-$cmd $cmdargs")) effectively strips the original quotes from the argument (this occurs when the arguments are read into $cmdargs), resulting in an attempt to invoke the following command:

dnvm-install C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg

This fails firstly due to the unescaped/unquoted parenthesis but would also fail due to the unquoted path. It appears that Visual Studio is attempting to install dnx-clr-win-x86.1.0.0-beta5.nupkg using a correctly quoted path, but then dnvm.ps1 strips the quotes. My initial fix of simply quoting $cmdargs is a valid workaround for this particular case, but will break most other DNVM commands, as it would be grouping arguments into a single string.

My PowerShell isn't great, but if I come up with a fix I will update the PR. Is it preferable to open this as an issue for now?

@ph1ll ph1ll reopened this Jul 22, 2015
@dnfclas
Copy link

dnfclas commented Jul 22, 2015

Hi @ph1ll, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. Real humans will now evaluate your PR.

TTYL, DNFBOT;

@ph1ll ph1ll closed this Jul 22, 2015
@ph1ll ph1ll reopened this Jul 22, 2015
@dnfclas
Copy link

dnfclas commented Jul 22, 2015

Hi @ph1ll, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. Real humans will now evaluate your PR.

TTYL, DNFBOT;

@ph1ll
Copy link
Contributor Author

ph1ll commented Jul 22, 2015

Apologies for the spam while rebasing then. Updated to loop over arguments and check whether they contain whitespace or parenthesis, and if so, ensure they are quoted prior to adding to $cmdargs

@ph1ll
Copy link
Contributor Author

ph1ll commented Jul 22, 2015

People on Stack Overflow also appear to be affected by this issue.

http://stackoverflow.com/questions/31546274/how-to-fix-dnx-dnvm-in-visual-studio-2015/31571324

@dnfclas
Copy link

dnfclas commented Aug 1, 2015

@ph1ll, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@muratg
Copy link

muratg commented Sep 22, 2015

@BrennanConroy please review in early RC1. Thanks.

@muratg muratg added this to the 1.0.0-rc1 milestone Sep 29, 2015
@muratg
Copy link

muratg commented Oct 1, 2015

@BrennanConroy When you get the time :)

@BrennanConroy
Copy link
Member

Could you rebase this on the latest changes, then I'll merge it in

@ph1ll
Copy link
Contributor Author

ph1ll commented Oct 5, 2015

@BrennanConroy PR has been rebased on the latest dev branch. Let me know if you need anything else.

@BrennanConroy
Copy link
Member

Any idea why AppVeyor is failing?

@ph1ll
Copy link
Contributor Author

ph1ll commented Oct 5, 2015

Just looking into that now, will update when I work it out

@ph1ll
Copy link
Contributor Author

ph1ll commented Oct 5, 2015

I had missed the initial $cmdargs = @() so += was appending to a string rather than adding to the array. Will fix and double check now.

@ph1ll
Copy link
Contributor Author

ph1ll commented Oct 5, 2015

Ok, updated and I also fixed tabs/whitespace in my changes. Hopefully appveryor and travis will be happy now.

As a comparison, the behavior of the current dev branch is:

PS> dnvm install "C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta6.nupkg"
Invoke-Command : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At [redacted]\dnvm.ps1:1487 char:9
+         Invoke-Command ([ScriptBlock]::Create("dnvm-$cmd $cmdargs"))
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [Invoke-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeCommandCommand

Where as with this PR:

PS> .\dnvm.ps1 install "C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta6.nupkg"
'dnx-clr-win-x86.1.0.0-beta6' is already installed in [redacted]\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6.
Adding [redacted]\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin to process PATH

BrennanConroy added a commit that referenced this pull request Oct 5, 2015
Quote $cmdargs string to prevent path errors
@BrennanConroy BrennanConroy merged commit 8aa7b4d into aspnet:dev Oct 5, 2015
@BrennanConroy
Copy link
Member

b1ae8a9
Thanks for your contribution!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants