10

I am currently trying to setup some UI tests on a Core web app, however I am not able to get the web app started. Using the command line directly with "dotnet run" from the web app directory works. The problem comes when I try to use Process to run it before executing my tests nothing happens.

    var process = new Process
    {
        StartInfo =
        {
            FileName = "dotnet",
            Arguments = "run",
            WorkingDirectory = applicationPath
        }
    };
    process.Start();

Has anyone been confronted to a similar issue before and/or managed to solve it? I may be misusing Process.

2 Answers 2

8

Turns that adding UseShellExecute to my StartInfo and setting it to false made it work:

var process = new Process
{
    StartInfo =
    {
        FileName = "dotnet",
        Arguments = "run",
        UseShellExecute = false,
        WorkingDirectory = applicationPath
    }
};
process.Start();

The default for UseShellExecute is true but it would be similar to running cmd dotnet run instead of dotnet run which is what I needed.

Sign up to request clarification or add additional context in comments.

5 Comments

after you started it, were you able to stop it?
nm. I got it to close using the following if (_webprocess != null && _webprocess.HasExited == false) { _webprocess.CloseMainWindow(); _webprocess.Close(); } calling Kill() wasn't working.
In my case it stops when the program ends
What if dotnet installed but not in PATH?
Upon installation, it should be in PATH. If you are working within a terminal or application that should use it you need to restart it so that it has the right PATH value. Then it should work. However, if it is not in PATH then you may either re-install or manually add it.
0

Try this

ProcessStartInfo Startinfo = new ProcessStartInfo();
Startinfo.FileName = "D:\\TFS\\QA\\SH_LoadTest\\SH_LoadTest\\bin\\Debug\\SH_LoadTest.exe";
StartInfo.Arguments = "Your Arguments";

Process pro = Process.Start(Startinfo);

2 Comments

You can actually use Autoit to start .net core application
It gives me the same result as before :/

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.