Support
Quality
Security
License
Reuse
kandi has reviewed MyAPIProject and discovered the below as its top functions. This is intended to give you an instant insight into MyAPIProject implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
Sample Google Cloud Endpoints Project
QUESTION
How to get PowerShell to execute all lines in the script? (and not take a rest on dotnet?)
Asked 2021-Mar-31 at 03:24I have a PowerShell version 5.1.19041.610 script that does roughly the following
Do Command 1
Do Command 2
dotnet run "..\MyApiProject\API.csproj" --no-build
Do Command 4
It works fine until dotnet run
hijacks the session and outputs:
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
The script just stops there. I need it to Do Command 4. How can I get PowerShell to start dotnet and just carry on to the next command?
ANSWER
Answered 2021-Mar-31 at 03:24You have two options to prevent the synchronous dotnet run ...
command from blocking your script.
dotnet run ...
command in a new window (works on Windows only), using Start-Process
:Start-Process dotnet 'run "..\MyApiProject\API.csproj" --no-build'
dotnet run ...
command invisibly in a background job, using Start-Job
:[1]Start-Job { $using:PWD | Set-Location; dotnet run ..\MyApiProject\API.csproj --no-build }
&
, the background operator:
dotnet run ..\MyApiProject\API.csproj --no-build &
Also, a more light-weight option is to use a thread job instead of a (child process-based) background job (the ThreadJob
module that provides the Start-ThreadJob
cmdlet comes with PowerShell (Core) 7+, but can also be installed in Windows PowerShell)
Start-ThreadJob { dotnet run ..\MyApiProject\API.csproj --no-build }
[1] See the conceptual about_Jobs topic for information on how to manage jobs. Note that using $using:PWD | Set-Location
is needed in Windows PowerShell to ensure that the background job uses the same current location as the caller; in PowerShell (Core) 7+ this is no longer necessary, because the caller's location is automatically inherited.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Find more information at:
Save this library and start creating your kit
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source