0

I have a .net core 2 project where I want to run another .net core 2 project in the pre-build events.

All my previous projects were developed using framework 4.x, which upon building generated .exe files. This .net core does not. How can I achieve the same result as the old code from my previous projects:

  $(MSBuildProjectDirectory)\..\MyProjectName\bin\$(Configuration)\MyProjectName.exe

Thank you in advance !

Nick Peelman
  • 145
  • 1
  • 11
  • If the problem is only with lack of `exe` file, the solution is to use `dotnet blabla\MyProjectName.dll` – Pavel Tupitsyn Aug 23 '18 at 17:51
  • I tried that, the filepath is now `dotnet $(MSBuildProjectDirectory)\..\ProjectName\bin\$(Configuration)\netcoreapp2.0\ProjectName.dll` but it's throwing me the error "-532462766" – Nick Peelman Aug 23 '18 at 18:03
  • This might be relevant to your dotnet error: https://stackoverflow.com/a/43841481/507793 – Matthew Aug 23 '18 at 18:47
  • @Matthew I'll take a look when I'm home. How did you find a relevant search for that error code? When pasting that into google I literally get nothing. – Nick Peelman Aug 24 '18 at 08:46
  • I know nothing of that specific error code, I just know that I have issues running apps from the `/bin` directory due to not all dependencies being copied there. – Matthew Aug 24 '18 at 13:09

1 Answers1

0
  • Actually i had the same issue before then i tried another solution, run the 2nd .net core app during the startup of the 1st one.
  • as we can run .net core app from command prompt if we navigated to the directory that contains (.csproj) and opened new command prompt window then run command

dotnet run

  • here is the code
public static void ExecuteCommand(string command, string workingDirectory)
{
var processStartInfo = new ProcessStartInfo();
processStartInfo.WorkingDirectory = workingDirectory;
processStartInfo.FileName = "cmd.exe";
processStartInfo.Arguments = "/k " + command;
processStartInfo.CreateNoWindow = false;
processStartInfo.UseShellExecute = true;
Process proc = Process.Start(processStartInfo);
}
  • then you can call it like that
// the directory that contains (.csproj)
var appWorkingDirectory = @"D:\\Examples\\MyApp";
ExecuteCommand("dotnet run", appWorkingDirectory);
  • notice that will open a show the command prompt window and if you want to hide it just set

processStartInfo.CreateNoWindow = true;

hope this can help you