The operation could not be completed devenv /setup - visual-studio

I am troubleshooting why my xaf xafml files open in xml instead of the designer
and looking at the help here
Here is my console output of me trying to run devenv /setup
C:\>cd c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE>devenv /setup
Microsoft Visual Studio 2017 Version 15.0.27703.2000.
Copyright (C) Microsoft Corp. All rights reserved.
The operation could not be completed

I have solved the issue by running the console as Administrator.

Related

devenv.exe /upgrade not working as intended

I am trying to use devenv.exe to upgrade Visual Studio 2013 solution files through the command line.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" TimeReportingDataMart.sln /Upgrade
But there is no output, and the solution does not upgrade. Is devenv not the correct tool for this? Or am I just missing something completely?
The problem was that I was calling devenv.exe when I should have been calling devenv.
Calling,
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" TimeReportingDataMart.sln /Upgrade fails.
But calling
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv" TimeReportingDataMart.sln /Upgrade gives me output.
It gives:
Copyright (C) Microsoft Corp. All rights reserved.
Information:
This project/solution does not require migration. It will open without modification.
Which doesn't help me, but at least I got the command to run..

Building CUDA in platformio-ide-terminal

I would like to be able to compile and build CUDA C source code provided here using Windows 10 Powershell. I have no issue doing this using x64 Native Tools Command Prompt for VS 2017.
However, I have tried several ways suggested online to get Powershell to work, but no success. The reason is I want to be able to build my cuda codes in Atom, the editor, using its package platformio-ide-terminal that loads a Powershell inside Atom. So, if I figure out how to setup Visual Studio 2017 Community in a Powershell, I edit my code in Atom and conveniently build them using its Powershell integration.
I tried to set the environment as follows but still nvcc cannot find the path to cl.exe.
Could someone kindly help me?
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\AFP\Downloads\cuda_by_example> cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\"
PS C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build> .\vcvarsall.bat amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.7.3
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
PS C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build> cd C:\Users\AFP\Downloads\cuda_by_example\
PS C:\Users\AFP\Downloads\cuda_by_example> nvcc .\chapter03\hello_world.cu
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
PS C:\Users\AFP\Downloads\cuda_by_example>
You can add the path to cl.exe to the environment variables:
control panel > view advanced system settings > Environment variables > Path > New.
Then add C:\Program Files (x86)\Microsoft Visual Studio\<year >\Community\VC\Tools\MSVC\<toolset>\bin\Hostx64\x64.
Or use this command for compile: nvcc x.cu .\chapter03\hello_world.cu -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\<year >\Community\VC\Tools\MSVC\<toolset>\bin\Hostx64\x64"
Open a Windows Powershell and run the following commands at the prompt:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\AFP\Downloads\cuda_by_example> & 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat' amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.7.3
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
PS C:\Users\AFP\Downloads\cuda_by_example> $ENV:PATH="$ENV:PATH;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\Hostx64\x64"
PS C:\Users\AFP\Downloads\cuda_by_example> nvcc .\chapter03\hello_world.cu
hello_world.cu
Creating library a.lib and object a.exp
PS C:\Users\falah\Downloads\cuda_by_example> .\a.exe
Hello, World!
PS C:\Users\falah\Downloads\cuda_by_example>
Automation
To automate this, create a file named nvcc_setup_for_powershell.ps1 and place the following two commands in it.
& 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat' amd64
$ENV:PATH="$ENV:PATH;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\Hostx64\x64"
Write-Output "Configured PowerShell for NVCC Using Visual Studio 2019 Community x64"
$myshell = New-Object -com "Wscript.Shell"
$myshell.sendkeys("{ENTER}")
the last two commands is to simulate hitting enter button, adopted from here.
Open settings for platformio-ide-terminal under Core > Run Command place the path to the PowerShell script: & "C:\Path\To\Script\nvcc_setup_for_powershell.ps1".
You may need to open a PowerShell as administrator and run the following command
Set-ExecutionPolicy RemoteSigned
to allow you to execute nvcc_setup_for_powershell.ps1.

Different Paths To msbuild in VS2017

OS: Microsoft Windows [Version 10.0.14393]
VS-Version: 2017 Community
When I run vswhere.exe I get the following back and based on on the official vswhere documentation I can build the path to msbuild and this seems to work:
C:\Users\user\Desktop>"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
Visual Studio Locator version 1.0.62 [query version 1.10.80.60812]
Copyright (C) Microsoft Corporation. All rights reserved.
[...]
installationPath: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
[...]
C:\Users\user\Desktop>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"
Microsoft (R)-Buildmodul, Version 15.1.1012.6693
If I start the developer command prompt located in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsMSBuildCmd.bat" I get the following result:
C:\Users\user>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsMSBuildCmd.bat"
**********************************************************************
** Visual Studio 2017 MSBuild Command Prompt
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
C:\Users\user>where msbuild
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
Why and what is the second path returned after starting the developer command prompt
I always use the first path ("C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe") to call msbuild for building C/C++/VC++ Projects. Is this in someway wrong?
VS 2017 switched to local copies of msbuild, if you used a VS 2015 command prompt, you would see a different global path.
The where command lists all the matching executable files that it finds on the PATH, but only the first one will be used by the command prompt when you run an msbuild command.
The second msbuild.exe you see is part of the .NET Framework - this is the version of MSBuild that was integrated into and shipped as part of the .NET Framework. This version is old compared to the ones installed by recent versions of Visual Studio. But it will likely be continued to be included in .NET Framework for compatibility reasons. It is even able to build a lot of projects that will then use the targets and tasks installed by VS - only project format changes that required changes to MSBuild itself will be incompatible (like the new project format used for .NET Core projects).
You should always use the VS 2017 version of msbuild.exe to always get build results consistent with visual studio.

Where is the Microsoft Visual Studio Community executable located?

I just installed it but I don't know where it is. Can anyone help me? I've looked in a lot of places but I still don't know.
Look for devenv.exe, it should be at:
Visual Studio Community 2015
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
Visual Studio Community 2017
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE
Visual Studio Professional 2017
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE
For VS2019 it's now at:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe
I would say instead of looking at a predefined location for the installation which might change in future what you should do is as follows -
Search for visual studio in apps search
Right click and select "Open file location"
Once you have this shortcut, Right click on it and select and open properties and see the target field. This is your executable path.
For me it is -
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe"
Due to this link https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/how-to-set-environment-variables-for-the-visual-studio-command-line
Visual Studio location could be
\Program Files\Microsoft Visual Studio\Version\Offering or
\Program Files (x86)\Microsoft Visual Studio\Version\Offering
where Offering is one of Enterprise, Professional or Community, Version is 2019, etc
For VS 2022 it's now at (Program Files not Program Files x86):
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE
For VS 2020
"C:\Users\Username\AppData\Local\Programs\Microsoft VS Code\Code.exe"

Visual Studio 2015 Installation corruption

I installed Visual Studio 2015 and shortly after selecting a TFS server started to experience issues:
missing package errors
new project had no project types
Team explorer has an error tag (Page '312e8a59-2712-48a1-863e-0ef4e67961fc' not found.)
If I go to Team and click manage connections I get an error (Team Foundation Error Page '3185ed96-1cbcd-4381-a439-636973542e50' not found.)
If I try to re-open the solution I pulled down I get:
(The 'ErrorListPackage' package did not load correctly)
(The 'CSharpPackage' package did not load correctly)
(The 'FileIndicatorPackage' package did not load correctly) and fails to open
Then I get an 'object reference not set to an instance of an object) when I try to close VS.
I tried running the devenv.exe commands to rest everything to no avail:
devenv.exe /debug
devenv.exe /resetsettings
devenv.exe /instalvstemplates
devenv.exe /resetskippings
devenv.exe /resetuserdata
devenv.exe /setup
devenv.exe /safemode
I tried repair: still broken
I uninstalled and reinstalled: still broken
The Fix
Uninstall Visual Studio 2015 from Programs and Features
Reboot machine if prompted.
Rename or delete folders-
C:\Program Files (x86)\Microsoft Visual Studio 14.0
C:\Program Files\Microsoft Visual Studio 14.0
<user>\Documents\Visual Studio 2015
<user>\AppData\Roaming\Microsoft\VisualStudio\14.0
<user>\AppData\Local\Microsoft\VisualStudio\14.0
<user>\AppData\Local\Microsoft\VSCommon\14.0
Go to the registry editor (start >> run >> regedit) and remove/rename the following registries-
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0
HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Config
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Remote
Install Visual Studio 2015

Resources