I'm trying programmatically with C# base code to restore packageReference for .NET framework & .NET core projects.
I thought about using dotnet.exe / msbuild.exe but I don't know how!
I want to simulate what we can do with dotnet CLI:
dotnet restore '.\myproject.csproj' --packages '.\OutputFolder'
but I want to do it programmatically.
Thanks for the answers.
System.Diagnostics.Process.Start("CMD.exe", "dotnet restore '.\myproject.csproj' --packages '.\OutputFolder'");you can run your dotnet command programmatically.Environment.OSVersion.Platformto check platform. Orvar values = Environment.GetEnvironmentVariable("PATH");to checkcmd.exe. It is always a risk to execute 3rd party. It is the same for dotnet. You have to proof dotnet exist as enviroment PATH variable before.