3

I have a .NET Framework project that requires running a built console application from a .NET Core project in the same solution.

Take the example file structure:

  • Test/bin/Debug/Test.exe
  • Service/bin/Debug/netcoreapp2.2/Service.dll

The current approach involves starting a new process, similar to the following:

dotnet run ../../../Service/bin/Debug/netcoreapp2.2/Service.dll

I am fairly new to .NET, and so unsure if the following ideas are possible:

  • Modifying the path when running the Test application so that I can start the Service process with dotnet run Service.dll.
  • Getting the Test project to copy the Service build files into the Test build folder.

For bonus points, if/when the Framework project is upgraded to Core, is it possible to start a Core application process by using it in another application?

Edit:

For clarification, I'm hoping to avoid using that hard-coded relative path to build output folder, since it changes between Framework and Core and different versions of Core. My hope is to find a built-in variable or functionality to get the build location of another project (even if I need to hard-code the Debug/Release part).

For example (excuse the pseudocode):

using Service;
var path = getPathToDebugBuildFolder(Service);
startProcess(Path.Join(path, "Service.dll"));
MattMS
  • 1,106
  • 1
  • 16
  • 32

1 Answers1

0

If you right click your project in Visual Studio you can define your Pre- and PostBuild Tasks (Build Events).

And yes.. if you are using .NET Core for both applications then you can Add a reference to your class library / console application and use the public types.

Peter Schneider
  • 2,879
  • 1
  • 14
  • 17
  • Thanks for your answer. Are you suggesting that I copy the built files from the Service project into the Test project in one of those pre/post-build tasks? If so, I'd currently still be stuck with maintaining a relative path to a possibly changing build folder. I'm hoping to find built-in variables/functionality that may be able to reference the build output folder of the other project. – MattMS Apr 13 '19 at 09:44