How to run a command in Developer command prompt 2019 using Python - python-3.x

I'm trying to do build in Developer Command Prompt of VS 2019 using Python script.
Here is piece of code i'm using:
import os
os.system('start /wait C:/Windows/System32/cmd.exe "msbuild C:/Users/Desktop/Project/Project.sln"')
os.system("pause")
But it is not working.Developer command prompt is appearing for just 1sec and disappearing .
When i took variable to check if command was succesful or not ,it is giving variable result as zero,which means command is successful but i'm not able to see it in Developer command prompt.
result= os.system('start /wait C:/Windows/System32/cmd.exe /k ipconfig')
print (result)
Whereas when i'm trying the same command in windows command prompt it's working fine.

How to run a command in Developer command prompt 2019 using Python
Developer command prompt 2019 is a tool which is integrated into VS2019 IDE and provides environment parameters for various development modules.
However, the CMD.exe does not have these environment variables for these, so you cannot just use CMD.exe directly. Sorry that I am not familiar with python code and script. I suggest you could configure Developer command prompt 2019 into System environment variable PATHand then call cmd.exe which integrates the related variables to build your projects without any errors.
Suggestion
First, if you build your project on another new agent, you should install one of tool from step 1.
1) If you install VS2019 IDE in your local agent,please make sure that your local agent has VS2019 IDE and install the related workload about your project type.
Besides, if you install Build Tool for VS2019, please also install the related workload.
2) set the below path under System environment variable PATH
VS2019 IDE:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin
Build Tool for VS2019:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
3) Then you can call your python script as you described to build your projects.
Any feedback and concern will be expected.

Related

Run Windows batch script in POST_BUILD command even when generating on Linux machine

I'm using Visual Studio 2019 combined with CMake to cross compile my project on both PC environment (generating .sln file) and remote Linux machine (Generating Makefile file). I'm switching between the environments using Visual Studio's Cross Compilation feature.
Is it somehow possible to run a Windows batch script on POST_BUILD command even when I'm generating CMake on the Linux environment ?
I want this (or any other solution which will achieve the same) to work even when generating on Linux:
add_custom_command(
POST_BUILD
myTarget
COMMAND cmd /c H:/pathToMyCommand/myCommand.bat
)
(remember that I'm in Windows enviroment as Visual Studio is invoking CMake on the remote Linux machine)
I currently adding a custom command which run a shell script directly from the Linux machine and connecting to the Windows environment, but I prefer to run a batch directly from Windows.
Is it possible?

Can I launch az login with cmd rather than PowerShell in Visual Studio Code?

What's the problem I'm having?
I get the following error when running 'az login' from the terminal in Visual Studio code:
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe: Invalid
argument
What's the environment?
I'm running Visual Studio code in Windows 10 (version 1809, OS build 17763. 1158). I'm using Ubuntu 18.04 with WSL 1 and I've set my terminal to use "C:\Windows\System32\bash.exe"
I seem to have problems with PowerShell launching from VS code. Does anyone know if it's possible to configure VS code to use cmd rather than PowerShell when doing an az login? Any other suggestions are welcome. Thanks.
For the Visual Code, you can set the default shell as cmd if you want to use the cmd when you need the terminal. It looks like this:
1.
2.
When you finish these two actions, then you can get the cmd terminal when you want a new one. In this way, the cmd is the default.

'npm ERR! Please try running this command again as root/Administrator' => Worked in one terminal but not the other => WHY?

I am using Visual Studio Code to create a REACT application and when using the built in terminal I received the error message below and it failed to add the dependency (npm install fixed-data-table)
npm ERR! Please try running this command again as root/Administrator
Instead, I opened the Node Command Prompt and ran the same install and it worked!
Just curious as to why this happened if anyone knows as I'd much prefer to use the built in terminal.
Since VS Code is an application, it doesn't have the same pre-existing rights as the Node Command Prompt specifically it isn't an "administrator" account. If you want to use the powershell in VS Code for everything though, try launching VS Code as an administrator (right click on the logo and click run as admin)
Source: https://github.com/Microsoft/vscode/issues/7407
This error can also occur due to file locks, possibly from having multiple instances of the project loaded. I ran into this when I had the same project loaded in both Visual Studio and VS Code.

VSCode with WSL - How to use Bash for the launch configurations?

I use Visual Studio Code to develop a TypeScript Node application on Windows 10, with WSL enabled.
Thanks to other threads, I'm almost able to run a VSCode task with Bash on Ubuntu on Windows.
But now I try to do the same with a launch configuration. How can I make a launch configuration to use the node executable installed in WSL instead of the one installed on Windows?
If I run this command directly in the integrated terminal, with Bash, it works :
node src/start.js
But when I press "[F5]" and start a launch configuration that runs this same file, I get an error : "Error: %1 is not a valid Win32 application". This is because the oracledb library is used and has been compiled in Bash, not in Windows.
How can I make a launch configuration use Bash to run Node?
UPDATE : I opened an issue about that on VSCode's GitHub page.
Not if sure you still need help.
open bash outside of the vs code.
then run the following command, to install node.
sudo apt install nodejs-legacy
and you should be able to run node with bash in vs code.

Why do node tasks spawn new console when run from PowerShell?

On Windows 10, when I run Node.js commands (e.g. node -v) from a PowerShell console, they always spawn a new Windows Command console. When I run the same commands from a Windows Command prompt, they run in that same console session. Interestingly, whatever this is appears to cause the same behavior when running Node commands via the Task runner in Visual Studio Code and when Visual Studio 2017 build steps contain Node commands - each Node command run spawns a new console. This only started about a week or so ago. I don't recall any updates to my PC that could be related. Other developers on my team that use the same tools don't experience this same behavior. I have another PC that this doesn't occur on. What could be causing this?
Windows 10
Node.js v7.8

Resources