Invoking IISExpress using command line to host ASP

2019-02-25 06:04发布

问题:

I have a service that depends on lot of other services, during the development time, I just start all other services (manually using VS 2017). In order to avoid that step, I am trying to create a batch file with the below command to Host my ASP.NET Core Web API using IISExpress.

dotnet build 
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\Web Tools\ProjectSystem\VSIISExeLauncher.exe" -p "C:\Program Files\dotnet\dotnet.exe" -a "exec \".\Service\bin\Debug\netcoreapp2.0\MyService.dll\"" -pidFile [System.IO.Path]::GetTempFileName() -wd ".\"

When invoking the batch file from PS command prompt(Administrator) I am getting the below error

Failed to launch processs: C:\Program Files\dotnet\dotnet.exe

Last error = 267

Is there anything wrong with the above command?

回答1:

You have to also set environment variables, which I documented clearly in the following blog post,

https://blog.lextudio.com/how-visual-studio-launches-iis-express-to-debug-asp-net-core-apps-d7fd3677e3c3